testaro 69.0.2 → 69.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "69.0.2",
3
+ "version": "69.1.0",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/procs/catalog.js CHANGED
@@ -110,8 +110,11 @@ exports.getCatalog = async report => {
110
110
  ) {
111
111
  // For each element that has it:
112
112
  textElementIndexes.forEach(index => {
113
- // If it is not in the head:
114
- if (! cat.element[index].pathID.includes('/head[1]')) {
113
+ // If it is not in the head, a script, a style, or a noscript element:
114
+ if (
115
+ ! ['/head[1]', '/script[', '/style[', '/noscript[']
116
+ .some(excluder => cat.element[index].pathID.includes(excluder))
117
+ ) {
115
118
  // Mark it as linkable in the element data in the catalog.
116
119
  cat.element[index].textLinkable = true;
117
120
  }
@@ -23,23 +23,28 @@ const fs = require('fs/promises');
23
23
  exports.getSource = async page => {
24
24
  const url = page.url();
25
25
  const scheme = url.replace(/:.+/, '');
26
+ // Initialize the test data.
26
27
  const data = {
27
28
  prevented: false,
28
29
  source: ''
29
30
  };
31
+ // If the page is a local file:
30
32
  if (scheme === 'file') {
31
33
  const filePath = url.slice(7);
34
+ // Get the source from it.
32
35
  const rawPage = await fs.readFile(filePath, 'utf8');
36
+ // Add the source to the test data.
33
37
  data.source = rawPage;
34
38
  }
39
+ // Otherwise, i.e. if the page is not a local file:
35
40
  else {
36
41
  try {
37
- const rawPageResponse = await fetch(url);
38
- const rawPage = await rawPageResponse.text();
42
+ const response = await page.goto(url);
43
+ const rawPage = await response.text();
39
44
  data.source = rawPage;
40
45
  }
41
46
  catch(error) {
42
- console.log(`ERROR getting source of ${url} (${error.message})`);
47
+ console.log(`ERROR (${error.message}) getting source of ${url}; cause: ${error.cause}`);
43
48
  data.prevented = true;
44
49
  data.error = `ERROR getting source of ${url}`;
45
50
  }
@@ -47,6 +47,11 @@ exports.reporter = async (page, catalog, withItems) => {
47
47
  // Return a violation description.
48
48
  return 'Heading has the same text as the prior same-level sibling heading';
49
49
  }
50
+ // Otherwise, i.e. if they do not have identical text contents:
51
+ else {
52
+ // Stop inspecting.
53
+ break;
54
+ }
50
55
  }
51
56
  // Otherwise, i.e. if it is superior to the element:
52
57
  else {
package/tests/testaro.js CHANGED
@@ -118,14 +118,6 @@ const allRules = [
118
118
  timeOut: 5,
119
119
  defaultOn: true
120
120
  },
121
- {
122
- id: 'dupAtt',
123
- what: 'duplicate attribute values',
124
- contaminates: false,
125
- needsAccessibleName: false,
126
- timeOut: 5,
127
- defaultOn: true
128
- },
129
121
  {
130
122
  id: 'embAc',
131
123
  what: 'active elements embedded in links or buttons',
@@ -350,6 +342,14 @@ const allRules = [
350
342
  timeOut: 5,
351
343
  defaultOn: true
352
344
  },
345
+ {
346
+ id: 'dupAtt',
347
+ what: 'duplicate attribute values',
348
+ contaminates: false,
349
+ needsAccessibleName: false,
350
+ timeOut: 5,
351
+ defaultOn: true
352
+ },
353
353
  {
354
354
  id: 'autocomplete',
355
355
  what: 'name and email inputs without autocomplete attributes',
@@ -508,6 +508,7 @@ exports.reporter = async (page, report, actIndex) => {
508
508
  ? ruleSpec.slice(1)
509
509
  : allRules.filter(rule => rule.defaultOn && ! allRuleIDs.includes(rule.id));
510
510
  const jobRules = allRules.filter(rule => jobRuleIDs.includes(rule.id));
511
+ let justPrevented = false;
511
512
  // For each rule to be tested for:
512
513
  for (let ruleIndex = 0; ruleIndex < jobRules.length; ruleIndex++) {
513
514
  const rule = jobRules[ruleIndex];
@@ -526,6 +527,7 @@ exports.reporter = async (page, report, actIndex) => {
526
527
  const headEmulation = ruleResult.id.startsWith('shoot') ? 'high' : 'high';
527
528
  // Get whether the rule needs a new browser launched.
528
529
  const needsLaunch = ruleIndex === 0
530
+ || justPrevented
529
531
  || jobRules[ruleIndex - 1].contaminates
530
532
  || jobRules[ruleIndex].needsAccessibleName && ! jobRules[ruleIndex - 1].needsAccessibleName;
531
533
  const pageClosed = page && page.isClosed();
@@ -542,6 +544,7 @@ exports.reporter = async (page, report, actIndex) => {
542
544
  actIndex,
543
545
  tempBrowserID: browserID,
544
546
  tempURL: url,
547
+ headEmulation,
545
548
  xPathNeed: 'script',
546
549
  needsAccessibleName: jobRules[ruleIndex].needsAccessibleName,
547
550
  retries: 2
@@ -580,6 +583,7 @@ exports.reporter = async (page, report, actIndex) => {
580
583
  timer = new Promise(resolve => {
581
584
  timeout = setTimeout(() => {
582
585
  // Add data about the timeout to the rule result.
586
+ justPrevented = true;
583
587
  ruleResult.prevented = true;
584
588
  ruleResult.error = 'Timeout';
585
589
  console.log(`ERROR: Test of testaro rule ${ruleResult.id} timed out`);
@@ -609,6 +613,7 @@ exports.reporter = async (page, report, actIndex) => {
609
613
  if (ruleResult.instances) {
610
614
  standardResult.instances.push(... ruleResult.instances);
611
615
  }
616
+ justPrevented = false;
612
617
  // If testing is to stop after a failure and the page failed the test:
613
618
  if (stopOnFail && ruleReport.totals?.some(total => total)) {
614
619
  // Test for no more rules.
@@ -618,6 +623,8 @@ exports.reporter = async (page, report, actIndex) => {
618
623
  }
619
624
  // If an error is thrown by the test:
620
625
  catch(error) {
626
+ ruleResult.prevented = true;
627
+ justPrevented = true;
621
628
  const isPageClosed = ['closed', 'Protocol error', 'Target page'].some(phrase =>
622
629
  error.message.includes(phrase)
623
630
  );
@@ -629,7 +636,6 @@ exports.reporter = async (page, report, actIndex) => {
629
636
  // Otherwise, i.e. if the page is open:
630
637
  else {
631
638
  // Add this to the rule result.
632
- ruleResult.prevented = true;
633
639
  ruleResult.error = error.message;
634
640
  console.log(
635
641
  `ERROR: Test of testaro rule ${ruleResult.id} prevented (${error.message})`