testaro 5.14.2 → 5.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.14.2",
3
+ "version": "5.14.3",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -113,6 +113,12 @@
113
113
  "withItems": true,
114
114
  "what": "keyboard navigation within true-focus menus"
115
115
  },
116
+ {
117
+ "type": "test",
118
+ "which": "nonTable",
119
+ "withItems": true,
120
+ "what": "tables used for layout"
121
+ },
116
122
  {
117
123
  "type": "test",
118
124
  "which": "radioSet",
package/tests/nonTable.js CHANGED
@@ -4,17 +4,21 @@
4
4
  This test reports tables used for layout.
5
5
  */
6
6
  exports.reporter = async (page, withItems) => {
7
- // Identify the visible links without href attributes.
7
+ // Identify the tables used for layout.
8
8
  const badTableTexts = await page.$$eval('table', tables => {
9
+ // Initialiyze an array of pseudotable texts.
9
10
  const badTableTexts = [];
10
11
  // FUNCTION DEFINITIONS START
11
12
  // Returns a space-minimized copy of a string.
12
13
  const compact = string => string.replace(/[\t\n]/g, '').replace(/\s{2,}/g, ' ').trim();
14
+ // Adds the first 100 characters of the code of a pseudotable to the array of pseudotable texts.
13
15
  const addBad = table => {
14
16
  badTableTexts.push(compact(table.outerHTML).slice(0, 100));
15
17
  };
16
18
  // FUNCTION DEFINITIONS END
19
+ // For each table on the page:
17
20
  tables.forEach(table => {
21
+ // Ignore it if it has a grid or treegrid role, a caption, or a table-like element.
18
22
  const role = table.getAttribute('role');
19
23
  if (
20
24
  table.caption
@@ -23,10 +27,13 @@ exports.reporter = async (page, withItems) => {
23
27
  ) {
24
28
  return;
25
29
  }
30
+ // Otherwise, if the table contains another table:
26
31
  else if (table.querySelector('table')) {
32
+ // Treat it as a pseudotable.
27
33
  addBad(table);
28
34
  return;
29
35
  }
36
+ // Otherwise, if the table has only 1 row or 1 column:
30
37
  else if (
31
38
  table.querySelectorAll('tr').length === 1
32
39
  || Math.max(
@@ -35,18 +42,23 @@ exports.reporter = async (page, withItems) => {
35
42
  .map(row => Array.from(row.querySelectorAll('td')).length)
36
43
  ) === 1
37
44
  ) {
45
+ // Treat it as a pseudotable.
38
46
  addBad(table);
39
47
  return;
40
48
  }
49
+ // Otherwise, if the table contains an object or player:
41
50
  else if (table.querySelector('object, embed, applet, audio, video')) {
51
+ // Treat it as a pseudotable.
42
52
  addBad(table);
43
53
  return;
44
54
  }
45
55
  });
56
+ // Return the array of pseudotable text beginnings.
46
57
  return badTableTexts;
47
58
  });
59
+ // Return the result.
48
60
  const data = {
49
- totals: badTableTexts.length
61
+ total: badTableTexts.length
50
62
  };
51
63
  if (withItems) {
52
64
  data.items = badTableTexts;
@@ -0,0 +1,28 @@
1
+ {
2
+ "what": "validation of nonTable test",
3
+ "strict": true,
4
+ "commands": [
5
+ {
6
+ "type": "launch",
7
+ "which": "chromium",
8
+ "what": "usual browser"
9
+ },
10
+ {
11
+ "type": "url",
12
+ "which": "__targets__/nonTable/index.html",
13
+ "what": "page with a real table and 3 pseudotables"
14
+ },
15
+ {
16
+ "type": "test",
17
+ "which": "nonTable",
18
+ "what": "tables used for layout",
19
+ "withItems": true,
20
+ "expect": [
21
+ ["total", "=", 3],
22
+ ["items.0", "i", "Unit"],
23
+ ["items.1", "i", "Sales"],
24
+ ["items.2", "i", "Chime"]
25
+ ]
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,73 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-US">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Page with a real table and pseudotables</title>
6
+ <meta name="description" content="tester">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <style>
9
+ table {
10
+ border-collapse: collapse;
11
+ }
12
+ td, th {
13
+ padding: 0.3rem;
14
+ border: 0.2rem black solid;
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <main>
20
+ <h1>Page with a real table and pseudotables</h1>
21
+ <h2>Real table</h2>
22
+ <table>
23
+ <caption>Personnel</caption>
24
+ <thead>
25
+ <tr><th>Name</th><th>Department</th></tr>
26
+ </thead>
27
+ <tbody>
28
+ <tr><th>Amy</th><td>Accessibility</td></tr>
29
+ <tr><th>Abe</th><td>Marketing</td></tr>
30
+ </tbody>
31
+ </table>
32
+ <h2>Pseudotables 0 and 1</h2>
33
+ <table>
34
+ <caption>Personnel</caption>
35
+ <thead>
36
+ <tr><th>Given name</th><th>Unit</th></tr>
37
+ </thead>
38
+ <tbody>
39
+ <tr><th>Kim</th><td>Usability</td></tr>
40
+ <tr><th>Ken</th><td><table><tr><td>Advertising</td><td>Sales</td></tr></table></td></tr>
41
+ </tbody>
42
+ </table>
43
+ <h2>Pseudotable 2</h2>
44
+ <table>
45
+ <caption>Ringtones</caption>
46
+ <tbody>
47
+ <tr>
48
+ <th>Chime</th>
49
+ <td>
50
+ <object
51
+ title="chime"
52
+ type="audio/mpeg"
53
+ data="https://ia600704.us.archive.org/18/items/Ding-A-Ling-8294/Lee_Rosevere_-_10_-_Life_in_a_Tube.mp3"
54
+ >
55
+ </object>
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <th>Gong</th>
60
+ <td>
61
+ <object
62
+ title="gong"
63
+ type="audio/mpeg"
64
+ data="https://ia800704.us.archive.org/18/items/Ding-A-Ling-8294/Lee_Rosevere_-_11_-_Measurement_of_Risk.mp3"
65
+ >
66
+ </object>
67
+ </td>
68
+ </tr>
69
+ </tbody>
70
+ </table>
71
+ </main>
72
+ </body>
73
+ </html>