testaro 74.2.3 → 75.0.0

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.
Files changed (63) hide show
  1. package/LICENSE +2 -0
  2. package/README.md +52 -59
  3. package/actSpecs-doc.md +25 -1
  4. package/actSpecs.js +6 -4
  5. package/package.json +1 -1
  6. package/procs/catalog.js +0 -1
  7. package/procs/dateTime.js +4 -2
  8. package/procs/doActs.js +15 -8
  9. package/procs/launch.js +0 -1
  10. package/procs/shoot.js +48 -43
  11. package/testaro/adbID.js +2 -2
  12. package/testaro/allCapStyle.js +2 -2
  13. package/testaro/allCaps.js +3 -3
  14. package/testaro/allHidden.js +2 -2
  15. package/testaro/allSlanted.js +2 -2
  16. package/testaro/altScheme.js +2 -2
  17. package/testaro/attVal.js +2 -2
  18. package/testaro/autocomplete.js +3 -2
  19. package/testaro/bulk.js +2 -2
  20. package/testaro/buttonMenu.js +3 -3
  21. package/testaro/captionLoc.js +2 -2
  22. package/testaro/datalistRef.js +2 -2
  23. package/testaro/distortion.js +2 -2
  24. package/testaro/docType.js +1 -1
  25. package/testaro/dupAtt.js +2 -2
  26. package/testaro/embAc.js +2 -2
  27. package/testaro/focAll.js +2 -2
  28. package/testaro/focAndOp.js +2 -2
  29. package/testaro/focInd.js +2 -2
  30. package/testaro/focVis.js +2 -2
  31. package/testaro/headEl.js +2 -2
  32. package/testaro/headingAmb.js +2 -2
  33. package/testaro/hovInd.js +2 -2
  34. package/testaro/hover.js +2 -2
  35. package/testaro/hr.js +2 -2
  36. package/testaro/imageLink.js +2 -2
  37. package/testaro/labClash.js +2 -2
  38. package/testaro/legendLoc.js +2 -2
  39. package/testaro/lineHeight.js +2 -2
  40. package/testaro/linkAmb.js +2 -2
  41. package/testaro/linkExt.js +2 -2
  42. package/testaro/linkOldAtt.js +2 -2
  43. package/testaro/linkTo.js +2 -2
  44. package/testaro/linkUl.js +2 -2
  45. package/testaro/miniText.js +2 -2
  46. package/testaro/motion.js +6 -6
  47. package/testaro/nonTable.js +2 -2
  48. package/testaro/optRoleSel.js +2 -2
  49. package/testaro/phOnly.js +2 -2
  50. package/testaro/pseudoP.js +2 -2
  51. package/testaro/radioSet.js +2 -2
  52. package/testaro/role.js +2 -2
  53. package/testaro/secHeading.js +2 -2
  54. package/testaro/shoot0.js +11 -2
  55. package/testaro/shoot1.js +12 -4
  56. package/testaro/styleDiff.js +2 -2
  57. package/testaro/tabNav.js +2 -2
  58. package/testaro/targetsNear.js +2 -2
  59. package/testaro/textNodes.js +1 -1
  60. package/testaro/textSem.js +2 -2
  61. package/testaro/titledEl.js +2 -2
  62. package/testaro/zIndex.js +2 -2
  63. package/tests/testaro.js +2 -10
@@ -22,7 +22,7 @@ const {doTest} = require('../procs/testaro');
22
22
  // FUNCTIONS
23
23
 
24
24
  // Runs the test and returns the result.
25
- exports.reporter = async (page, catalog, withItems) => {
25
+ exports.reporter = async (page, report, _, withItems) => {
26
26
  const getBadWhat = element => {
27
27
  // If the element has no aria-selected attribute:
28
28
  if (! element.hasAttribute('aria-selected')) {
@@ -32,6 +32,6 @@ exports.reporter = async (page, catalog, withItems) => {
32
32
  };
33
33
  const whats = 'Elements with role=option have no aria-selected attributes';
34
34
  return await doTest(
35
- page, catalog, withItems, 'optRoleSel', 'body [role="option"]', whats, 1, getBadWhat.toString()
35
+ page, report.catalog, withItems, 'optRoleSel', 'body [role="option"]', whats, 1, getBadWhat.toString()
36
36
  );
37
37
  };
package/testaro/phOnly.js CHANGED
@@ -22,7 +22,7 @@ const {doTest} = require('../procs/testaro');
22
22
  // FUNCTIONS
23
23
 
24
24
  // Runs the test and returns the result.
25
- exports.reporter = async (page, catalog, withItems) => {
25
+ exports.reporter = async (page, report, _, withItems) => {
26
26
  const getBadWhat = element => {
27
27
  // Get the accessible name of the element.
28
28
  const accessibleName = window.getAccessibleName(element);
@@ -34,6 +34,6 @@ exports.reporter = async (page, catalog, withItems) => {
34
34
  };
35
35
  const whats = 'input elements have placeholders but no accessible names';
36
36
  return await doTest(
37
- page, catalog, withItems, 'phOnly', 'body input[placeholder]', whats, 2, getBadWhat.toString()
37
+ page, report.catalog, withItems, 'phOnly', 'body input[placeholder]', whats, 2, getBadWhat.toString()
38
38
  );
39
39
  };
@@ -18,7 +18,7 @@ const {doTest} = require('../procs/testaro');
18
18
  // FUNCTIONS
19
19
 
20
20
  // Runs the test and returns the result.
21
- exports.reporter = async (page, catalog, withItems) => {
21
+ exports.reporter = async (page, report, _, withItems) => {
22
22
  const getBadWhat = element => {
23
23
  // Get the node before the element node.
24
24
  const previousNode = element.previousSibling;
@@ -49,6 +49,6 @@ exports.reporter = async (page, catalog, withItems) => {
49
49
  };
50
50
  const whats = 'br elements follow other br elements, possibly constituting pseudo-paragraphs';
51
51
  return await doTest(
52
- page, catalog, withItems, 'pseudoP', 'body br', whats, 0, getBadWhat.toString()
52
+ page, report.catalog, withItems, 'pseudoP', 'body br', whats, 0, getBadWhat.toString()
53
53
  );
54
54
  };
@@ -19,7 +19,7 @@ const {doTest} = require('../procs/testaro');
19
19
  // FUNCTIONS
20
20
 
21
21
  // Runs the test and returns the result.
22
- exports.reporter = async (page, catalog, withItems) => {
22
+ exports.reporter = async (page, report, _, withItems) => {
23
23
  const getBadWhat = element => {
24
24
  // Get the name of the element.
25
25
  const elName = element.name;
@@ -69,6 +69,6 @@ exports.reporter = async (page, catalog, withItems) => {
69
69
  };
70
70
  const whats = 'Radio buttons are not validly grouped in fieldsets with legends';
71
71
  return await doTest(
72
- page, catalog, withItems, 'radioSet', 'body input[type=radio]', whats, 2, getBadWhat.toString()
72
+ page, report.catalog, withItems, 'radioSet', 'body input[type=radio]', whats, 2, getBadWhat.toString()
73
73
  );
74
74
  };
package/testaro/role.js CHANGED
@@ -25,7 +25,7 @@ const implicitRoles = new Set(Array.from(elementRoles.values()).flat());
25
25
  // FUNCTIONS
26
26
 
27
27
  // Runs the test and returns the result.
28
- exports.reporter = async (page, catalog, withItems) => {
28
+ exports.reporter = async (page, report, _, withItems) => {
29
29
  // Get locators for the elements with explicit roles.
30
30
  const loc = page.locator('[role]');
31
31
  const locs = await loc.all();
@@ -44,5 +44,5 @@ exports.reporter = async (page, catalog, withItems) => {
44
44
  }
45
45
  // Get and return a result.
46
46
  const whats = 'Elements have roles assigned that are also implicit HTML element roles';
47
- return await getBasicResult(catalog, withItems, 'role', 0, whats, {}, violations);
47
+ return await getBasicResult(report.catalog, withItems, 'role', 0, whats, {}, violations);
48
48
  };
@@ -20,7 +20,7 @@ const {doTest} = require('../procs/testaro');
20
20
  // FUNCTIONS
21
21
 
22
22
  // Runs the test and returns the result.
23
- exports.reporter = async (page, catalog, withItems) => {
23
+ exports.reporter = async (page, report, _, withItems) => {
24
24
  const getBadWhat = element => {
25
25
  // Get the children of the element.
26
26
  const children = Array.from(element.children);
@@ -44,6 +44,6 @@ exports.reporter = async (page, catalog, withItems) => {
44
44
  const selector = 'body section, body article, body nav, body aside, body main';
45
45
  const whats = 'First child headings of sectioning containers are deeper than others';
46
46
  return await doTest(
47
- page, catalog, withItems, 'secHeading', selector, whats, 0, getBadWhat.toString()
47
+ page, report.catalog, withItems, 'secHeading', selector, whats, 0, getBadWhat.toString()
48
48
  );
49
49
  };
package/testaro/shoot0.js CHANGED
@@ -15,9 +15,18 @@ const {shoot} = require('../procs/shoot');
15
15
  // FUNCTIONS
16
16
 
17
17
  // Makes and saves the first screenshot.
18
- exports.reporter = async (page, _, __, tmpDir) => {
18
+ exports.reporter = async (page, report) => {
19
19
  // Make and save the screenshot.
20
- const pngPath = await shoot(page, 0, tmpDir);
20
+ const pngPath = await shoot(page, report, {
21
+ exclusionSelector: '',
22
+ colorType: 0,
23
+ action: 'file'
24
+ });
25
+ // If this succeeded:
26
+ if (pngPath) {
27
+ // Add the file path to the report.
28
+ report.jobData.testaroShoot0 = pngPath;
29
+ }
21
30
  // Return whether the screenshot was prevented.
22
31
  return {
23
32
  data: {
package/testaro/shoot1.js CHANGED
@@ -16,13 +16,21 @@ const {shoot} = require('../procs/shoot');
16
16
  // FUNCTIONS
17
17
 
18
18
  // Make and save the second screenshot.
19
- exports.reporter = async (page, _0, _1, tmpDir) => {
20
- const tempFileNames = await fs.readdir(tmpDir);
19
+ exports.reporter = async (page, report) => {
21
20
  let pngPath = '';
22
21
  // If there is a shoot0 file:
23
- if (tempFileNames.includes('testaro-shoot-0.png')) {
22
+ if (report.jobData.testaroShoot0) {
24
23
  // Make and save the screenshot.
25
- pngPath = await shoot(page, 1, tmpDir);
24
+ pngPath = await shoot(page, report, {
25
+ exclusionSelector: null,
26
+ colorType: 0,
27
+ action: 'file'
28
+ });
29
+ // If this succeeded:
30
+ if (pngPath) {
31
+ // Add the file path to the report.
32
+ report.jobData.testaroShoot1 = pngPath;
33
+ }
26
34
  }
27
35
  // Return whether the screenshot was prevented.
28
36
  return {
@@ -81,10 +81,10 @@ const linksByType = async page => await page.evaluateHandle(() => {
81
81
  };
82
82
  });
83
83
  // Runs the test and returns the result.
84
- exports.reporter = async (page, catalog, withItems) => {
84
+ exports.reporter = async (page, report, _, withItems) => {
85
85
  // Get an object with arrays of list links and adjacent links as properties.
86
86
  const linkTypes = await linksByType(page);
87
- const catalogIndex = getXPathCatalogIndex(catalog, '/html/body');
87
+ const catalogIndex = getXPathCatalogIndex(report.catalog, '/html/body');
88
88
  return await page.evaluate(args => {
89
89
  const [linkTypes, withItems, catalogIndex] = args;
90
90
  const {body} = document;
package/testaro/tabNav.js CHANGED
@@ -286,7 +286,7 @@ const testTabLists = async (tabLists, withItems, page) => {
286
286
  }
287
287
  };
288
288
  // Runs the test and returns the result.
289
- exports.reporter = async (page, catalog, withItems) => {
289
+ exports.reporter = async (page, report, _, withItems) => {
290
290
  // Initialize the results.
291
291
  data.totals = {
292
292
  navigations: {
@@ -374,7 +374,7 @@ exports.reporter = async (page, catalog, withItems) => {
374
374
  what: `Tab responds nonstandardly to ${item.navigationErrors.join(', ')}`,
375
375
  ordinalSeverity: 1,
376
376
  count: 1,
377
- catalogIndex: getXPathCatalogIndex(catalog, item.xPath)
377
+ catalogIndex: getXPathCatalogIndex(report.catalog, item.xPath)
378
378
  });
379
379
  });
380
380
  }
@@ -20,7 +20,7 @@ const {getXPathCatalogIndex} = require('../procs/xPath');
20
20
  // FUNCTIONS
21
21
 
22
22
  // Runs the test and returns the result.
23
- exports.reporter = async (page, catalog, withItems) => {
23
+ exports.reporter = async (page, report, _, withItems) => {
24
24
  // Return totals and standard instances for the rule.
25
25
  const protoResult = await page.evaluate(withItems => {
26
26
  // Get all pointer targets.
@@ -142,7 +142,7 @@ exports.reporter = async (page, catalog, withItems) => {
142
142
  }, withItems);
143
143
  // Convert the XPaths of the proto-instances to catalog indexes.
144
144
  protoResult.standardInstances = protoResult.standardInstances.map(instance => {
145
- instance.catalogIndex = getXPathCatalogIndex(catalog, instance.xPath);
145
+ instance.catalogIndex = getXPathCatalogIndex(report.catalog, instance.xPath);
146
146
  delete instance.xPath;
147
147
  return instance;
148
148
  });
@@ -18,7 +18,7 @@
18
18
  // FUNCTIONS
19
19
 
20
20
  // Runs the test and returns the result.
21
- exports.reporter = async (page, _, _, detailLevel, text = '') => {
21
+ exports.reporter = async (page, _0, _1, _2, detailLevel, text = '') => {
22
22
  let data = {};
23
23
  // Get the data on the text nodes.
24
24
  try {
@@ -19,7 +19,7 @@ const {doTest} = require('../procs/testaro');
19
19
  // FUNCTIONS
20
20
 
21
21
  // Runs the test and returns the result.
22
- exports.reporter = async (page, catalog, withItems) => {
22
+ exports.reporter = async (page, report, _, withItems) => {
23
23
  const getBadWhat = element => {
24
24
  const isVisible = element.checkVisibility({
25
25
  contentVisibilityAuto: true,
@@ -38,6 +38,6 @@ exports.reporter = async (page, catalog, withItems) => {
38
38
  const selector = 'body i, body b, body small';
39
39
  const whats = 'Semantically vague elements i, b, and/or small are used';
40
40
  return await doTest(
41
- page, catalog, withItems, 'textSem', selector, whats, 0, getBadWhat.toString()
41
+ page, report.catalog, withItems, 'textSem', selector, whats, 0, getBadWhat.toString()
42
42
  );
43
43
  };
@@ -20,7 +20,7 @@ const {doTest} = require('../procs/testaro');
20
20
  // FUNCTIONS
21
21
 
22
22
  // Runs the test and returns the result.
23
- exports.reporter = async (page, catalog, withItems) => {
23
+ exports.reporter = async (page, report, _, withItems) => {
24
24
  const getBadWhat = element => {
25
25
  const elementType = element.tagName.toLowerCase();
26
26
  // Return a violation description.
@@ -29,6 +29,6 @@ exports.reporter = async (page, catalog, withItems) => {
29
29
  const selector = 'body [title]:not(iframe, link, style)';
30
30
  const whats = 'title attributes are used on elements they are likely ineffective on';
31
31
  return await doTest(
32
- page, catalog, withItems, 'titledEl', selector, whats, 0, getBadWhat.toString()
32
+ page, report.catalog, withItems, 'titledEl', selector, whats, 0, getBadWhat.toString()
33
33
  );
34
34
  };
package/testaro/zIndex.js CHANGED
@@ -20,7 +20,7 @@ const {doTest} = require('../procs/testaro');
20
20
  // FUNCTIONS
21
21
 
22
22
  // Runs the test and returns the result.
23
- exports.reporter = async (page, catalog, withItems) => {
23
+ exports.reporter = async (page, report, _, withItems) => {
24
24
  const getBadWhat = element => {
25
25
  // Get whether the element violates the rule.
26
26
  const styleDec = window.getComputedStyle(element);
@@ -33,6 +33,6 @@ exports.reporter = async (page, catalog, withItems) => {
33
33
  };
34
34
  const whats = 'Elements have non-default Z indexes';
35
35
  return await doTest(
36
- page, catalog, withItems, 'zIndex', 'body, body *', whats, 0, getBadWhat.toString()
36
+ page, report.catalog, withItems, 'zIndex', 'body, body *', whats, 0, getBadWhat.toString()
37
37
  );
38
38
  };
package/tests/testaro.js CHANGED
@@ -459,14 +459,6 @@ process.on('unhandledRejection', reason => {
459
459
 
460
460
  // FUNCTIONS
461
461
 
462
- // Waits.
463
- const wait = ms => {
464
- return new Promise(resolve => {
465
- setTimeout(() => {
466
- resolve('');
467
- }, ms);
468
- });
469
- };
470
462
  // Conducts and reports Testaro tests.
471
463
  exports.reporter = async (page, report, actIndex) => {
472
464
  const act = report.acts[actIndex];
@@ -578,13 +570,13 @@ exports.reporter = async (page, report, actIndex) => {
578
570
  browser.on('disconnected', disconnectHandler);
579
571
  }
580
572
  // Initialize an argument array for the reporter.
581
- const ruleArgs = [page, report.catalog, withItems];
573
+ const ruleArgs = [page, report, actIndex, withItems];
582
574
  // If the rule needs a temporary directory:
583
575
  if (rule.needsTmpDir) {
584
576
  // Add its path to the argument array.
585
577
  ruleArgs.push(report.jobData.tmpDir);
586
578
  }
587
- // If the rule has extra arguments:
579
+ // If the testaro test act specifies extra arguments for this rule:
588
580
  if (argRules?.includes(ruleResult.id)) {
589
581
  // Add them to the argument array.
590
582
  ruleArgs.push(... args[ruleResult.id]);