testaro 60.11.0 → 60.13.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.
@@ -0,0 +1,109 @@
1
+ /*
2
+ © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
+ © 2025 Jonathan Robert Pool. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ */
25
+
26
+ /*
27
+ hover
28
+ This test reports unexpected impacts of hovering. The elements that are subjected to hovering
29
+ (called “triggers”) include all the elements that have ARIA attributes associated with control
30
+ over the visibility of other elements and all the elements that have onmouseenter or
31
+ onmouseover attributes, as well as a sample of all visible elements in the body. If hovering over
32
+ an element results in an increase or decrease in the total count of visible elements in the body,
33
+ the rule is considered violated.
34
+ */
35
+
36
+ // ########## IMPORTS
37
+
38
+ // Module to perform common operations.
39
+ const {init, getRuleResult} = require('../procs/testaro');
40
+
41
+ // ########## FUNCTIONS
42
+
43
+ // Runs the test and returns the result.
44
+ exports.reporter = async (page, withItems) => {
45
+ // Initialize the locators and result.
46
+ const allTrigger = await init(
47
+ 20, page, '[aria-controls], [aria-expanded], [aria-haspopup], [onmouseenter], [onmouseover]'
48
+ );
49
+ const allNonTrigger = await init(
50
+ 30 - allTrigger.result.data.sampleSize,
51
+ page,
52
+ 'body *:not([aria-controls], [aria-expanded], [aria-haspopup], [onmouseenter], [onmouseover])'
53
+ );
54
+ const populationSize
55
+ = allTrigger.result.data.populationSize + allNonTrigger.result.data.populationSize;
56
+ const sampleSize = allTrigger.result.data.sampleSize + allNonTrigger.result.data.sampleSize;
57
+ const all = {
58
+ allLocs: allTrigger.allLocs.concat(allNonTrigger.allLocs),
59
+ locs: [],
60
+ result: {
61
+ data: {
62
+ populationSize,
63
+ sampleSize,
64
+ populationRatio: sampleSize ? populationSize / sampleSize : null
65
+ },
66
+ totals: [0, 0, 0, 0],
67
+ standardInstances: []
68
+ }
69
+ };
70
+ // For each locator:
71
+ for (const loc of all.allLocs) {
72
+ // Get how many elements are added or subtracted when the element is hovered over.
73
+ await page.mouse.move(0, 0);
74
+ const loc0 = page.locator('body *:visible');
75
+ const elementCount0 = await loc0.count();
76
+ // Hover over the element, whether or not covered.
77
+ try {
78
+ await loc.hover({
79
+ force: true,
80
+ timeout: 100
81
+ });
82
+ const loc1 = page.locator('body *:visible');
83
+ const elementCount1 = await loc1.count();
84
+ const additions = elementCount1 - elementCount0;
85
+ // If any elements are added or subtracted:
86
+ if (additions !== 0) {
87
+ // Add the locator and the change of element count to the array of violation locators.
88
+ const impact = additions > 0
89
+ ? `added ${additions} elements to the page`
90
+ : `subtracted ${- additions} from the page`;
91
+ all.locs.push([loc, impact]);
92
+ }
93
+ }
94
+ // If hovering times out:
95
+ catch(error) {
96
+ // Report the test prevented.
97
+ const {data} = all.result;
98
+ data.prevented = true;
99
+ data.error = 'ERROR hovering over an element';
100
+ break;
101
+ }
102
+ }
103
+ // Populate and return the result.
104
+ const whats = [
105
+ 'Hovering over the element __param__',
106
+ 'Hovering over elements adds elements to or subtracts elements from the page'
107
+ ];
108
+ return await getRuleResult(withItems, all, 'hover', whats, 0);
109
+ };
package/testaro/hover.js CHANGED
@@ -26,84 +26,92 @@
26
26
  /*
27
27
  hover
28
28
  This test reports unexpected impacts of hovering. The elements that are subjected to hovering
29
- (called “triggers”) include all the elements that have ARIA attributes associated with control
30
- over the visibility of other elements and all the elements that have onmouseenter or
31
- onmouseover attributes, as well as a sample of all visible elements in the body. If hovering over
32
- an element results in an increase or decrease in the total count of visible elements in the body,
29
+ (called “triggers”) include all the elements that have attributes associated with control over
30
+ the visibility of other elements. If hovering over an element results in an increase or decrease
31
+ in the total count of visible elements in the tree rooted in the grandparent of the trigger,
33
32
  the rule is considered violated.
34
33
  */
35
34
 
36
35
  // ########## IMPORTS
37
36
 
38
37
  // Module to perform common operations.
39
- const {init, getRuleResult} = require('../procs/testaro');
38
+ const {getBasicResult, getVisibleCountChange} = require('../procs/testaro');
40
39
 
41
40
  // ########## FUNCTIONS
42
41
 
42
+ // Gets a violation description.
43
+ const getViolationDescription = (change, elapsedTime) =>
44
+ `Hovering over the element changes the related visible element count by ${change} in ${elapsedTime}ms`;
43
45
  // Runs the test and returns the result.
44
46
  exports.reporter = async (page, withItems) => {
45
47
  // Initialize the locators and result.
46
- const allTrigger = await init(
47
- 20, page, '[aria-controls], [aria-expanded], [aria-haspopup], [onmouseenter], [onmouseover]'
48
- );
49
- const allNonTrigger = await init(
50
- 30 - allTrigger.result.data.sampleSize,
51
- page,
52
- 'body *:not([aria-controls], [aria-expanded], [aria-haspopup], [onmouseenter], [onmouseover])'
53
- );
54
- const populationSize
55
- = allTrigger.result.data.populationSize + allNonTrigger.result.data.populationSize;
56
- const sampleSize = allTrigger.result.data.sampleSize + allNonTrigger.result.data.sampleSize;
57
- const all = {
58
- allLocs: allTrigger.allLocs.concat(allNonTrigger.allLocs),
59
- locs: [],
60
- result: {
61
- data: {
62
- populationSize,
63
- sampleSize,
64
- populationRatio: sampleSize ? populationSize / sampleSize : null
65
- },
66
- totals: [0, 0, 0, 0],
67
- standardInstances: []
68
- }
69
- };
48
+ const candidateLocs = await page.locator([
49
+ '[aria-controls]:visible',
50
+ '[aria-expanded]:visible',
51
+ '[aria-haspopup]:visible',
52
+ '[onmouseenter]:visible',
53
+ '[onmouseover]:visible',
54
+ '[onpointerenter]:visible',
55
+ '[onpointerover]:visible',
56
+ '[role="menu"]:visible',
57
+ '[role="menubar"]:visible',
58
+ '[role="menuitem"]:visible',
59
+ '[data-tooltip]:visible',
60
+ '[data-popover]:visible',
61
+ '[data-hover]:visible',
62
+ '[data-menu]:visible',
63
+ '[data-dropdown]:visible',
64
+ '[role=tab]:visible',
65
+ '[role=combobox]:visible'
66
+ ].join(', '));
67
+ const allLocs = await candidateLocs.all();
68
+ const violations = [];
69
+ const data = {};
70
70
  // For each locator:
71
- for (const loc of all.allLocs) {
72
- // Get how many elements are added or subtracted when the element is hovered over.
73
- await page.mouse.move(0, 0);
74
- const loc0 = page.locator('body *:visible');
71
+ for (const loc of allLocs) {
72
+ // Get the XPath of the element referenced by the locator.
73
+ let xPath = await loc.evaluate(element => getXPath(element));
74
+ const pathSegments = xPath.split('/');
75
+ const {length} = pathSegments;
76
+ // Change it to the XPath of the desired observation root.
77
+ pathSegments.pop();
78
+ if (! ['main', 'body'].includes(pathSegments[length - 2])) {
79
+ pathSegments.pop();
80
+ }
81
+ xPath = pathSegments.join('/');
82
+ // Get a locator for the observation root.
83
+ const rootLoc = page.locator(`xpath=${xPath}`);
84
+ const loc0 = await rootLoc.locator('*:visible');
85
+ // Get a count of the visible elements in the observation tree.
75
86
  const elementCount0 = await loc0.count();
76
- // Hover over the element, whether or not covered.
77
87
  try {
78
- await loc.hover({
79
- force: true,
80
- timeout: 100
81
- });
82
- const loc1 = page.locator('body *:visible');
83
- const elementCount1 = await loc1.count();
84
- const additions = elementCount1 - elementCount0;
85
- // If any elements are added or subtracted:
86
- if (additions !== 0) {
87
- // Add the locator and the change of element count to the array of violation locators.
88
- const impact = additions > 0
89
- ? `added ${additions} elements to the page`
90
- : `subtracted ${- additions} from the page`;
91
- all.locs.push([loc, impact]);
88
+ // Hover over the element.
89
+ await loc.hover({timeout: 400});
90
+ // Get the change in the count of the visible elements in the observation tree.
91
+ const changeData = await getVisibleCountChange(rootLoc, elementCount0, 400, 75);
92
+ const {change, elapsedTime} = changeData;
93
+ // If a change occurred:
94
+ if (change) {
95
+ // Add the locator and a violation description to the array of violations.
96
+ violations.push({
97
+ loc,
98
+ what: getViolationDescription(change, elapsedTime)
99
+ });
92
100
  }
101
+ // Stop hovering over the element.
102
+ await page.mouse.move(0, 0);
103
+ // Await a reverse change in the count of the visible elements in the observation tree.
104
+ await getVisibleCountChange(rootLoc, elementCount0 + change);
93
105
  }
94
- // If hovering times out:
106
+ // If hovering throws an error:
95
107
  catch(error) {
96
- // Report the test prevented.
97
- const {data} = all.result;
108
+ // Report that the test was prevented.
98
109
  data.prevented = true;
99
- data.error = 'ERROR hovering over an element';
110
+ data.error = `ERROR hovering over an element (${error.message})`;
100
111
  break;
101
112
  }
102
113
  }
103
- // Populate and return the result.
104
- const whats = [
105
- 'Hovering over the element __param__',
106
- 'Hovering over elements adds elements to or subtracts elements from the page'
107
- ];
108
- return await getRuleResult(withItems, all, 'hover', whats, 0);
114
+ // Get and return a result.
115
+ const whats = 'Hovering over elements changes the number of related visible elements';
116
+ return await getBasicResult(page, withItems, 'hover', 0, '', whats, data, violations);
109
117
  };
@@ -40,7 +40,6 @@ const {doTest} = require('../procs/testaro');
40
40
 
41
41
  // Runs the test and returns the result.
42
42
  exports.reporter = async (page, withItems) => {
43
- // Define a violation function for execution in the browser.
44
43
  const getBadWhat = element => {
45
44
  // Get whether the element has a non-spacing child text node.
46
45
  const hasText = Array.from(element.childNodes).some(child =>
@@ -65,8 +64,7 @@ exports.reporter = async (page, withItems) => {
65
64
  }
66
65
  };
67
66
  const whats = 'Element line heights are less than 1.5 times their font sizes';
68
- // Perform the test and return the result.
69
- return doTest(
67
+ return await doTest(
70
68
  page, withItems, 'lineHeight', '*', whats, 1, null, getBadWhat.toString()
71
69
  );
72
70
  };
@@ -61,7 +61,7 @@ exports.reporter = async (page, withItems) => {
61
61
  }
62
62
  };
63
63
  const whats = 'Visible elements have font sizes smaller than 11 pixels';
64
- return doTest(
64
+ return await doTest(
65
65
  page, withItems, 'miniText', 'body *:not(script, style)', whats, 2, '', getBadWhat.toString()
66
66
  );
67
67
  };
package/tests/testaro.js CHANGED
@@ -385,17 +385,17 @@ const allRules = [
385
385
  defaultOn: true
386
386
  },
387
387
  {
388
- id: 'focInd',
389
- what: 'missing and nonstandard focus indicators',
388
+ id: 'focAndOp',
389
+ what: 'Tab-focusable elements that are not operable or vice versa',
390
390
  launchRole: 'waster',
391
- timeOut: 10,
391
+ timeOut: 5,
392
392
  defaultOn: true
393
393
  },
394
394
  {
395
- id: 'focOp',
396
- what: 'Tab-focusable elements that are not operable',
395
+ id: 'focInd',
396
+ what: 'missing and nonstandard focus indicators',
397
397
  launchRole: 'waster',
398
- timeOut: 5,
398
+ timeOut: 10,
399
399
  defaultOn: true
400
400
  },
401
401
  {
@@ -409,7 +409,7 @@ const allRules = [
409
409
  id: 'hover',
410
410
  what: 'hover-caused content changes',
411
411
  launchRole: 'waster',
412
- timeOut: 10,
412
+ timeOut: 300,
413
413
  defaultOn: true
414
414
  },
415
415
  {
@@ -419,13 +419,6 @@ const allRules = [
419
419
  timeOut: 10,
420
420
  defaultOn: true
421
421
  },
422
- {
423
- id: 'opFoc',
424
- what: 'operable elements that are not Tab-focusable',
425
- launchRole: 'waster',
426
- timeOut: 10,
427
- defaultOn: true
428
- },
429
422
  {
430
423
  id: 'tabNav',
431
424
  what: 'nonstandard keyboard navigation between elements with the tab role',
@@ -589,8 +582,9 @@ exports.reporter = async (page, report, actIndex) => {
589
582
  ruleArgs.push(... args[ruleID]);
590
583
  }
591
584
  result[ruleID] ??= {};
585
+ const ruleResult = result[ruleID];
592
586
  const {what} = rule;
593
- result[ruleID].what = what || '';
587
+ ruleResult.what = what || '';
594
588
  const startTime = Date.now();
595
589
  let timeout;
596
590
  let testRetries = 2;
@@ -607,8 +601,8 @@ exports.reporter = async (page, report, actIndex) => {
607
601
  testTimes.push([rule, Math.round((endTime - startTime) / 1000)]);
608
602
  data.rulePreventions.push(ruleID);
609
603
  data.rulePreventionMessages[ruleID] = 'Timeout';
610
- result[ruleID].totals = [0, 0, 0, 0];
611
- result[ruleID].standardInstances = [];
604
+ ruleResult.totals = [0, 0, 0, 0];
605
+ ruleResult.standardInstances = [];
612
606
  console.log(`ERROR: Test of testaro rule ${ruleID} timed out`);
613
607
  resolve({timedOut: true});
614
608
  }, timeLimit);
@@ -625,26 +619,32 @@ exports.reporter = async (page, report, actIndex) => {
625
619
  const endTime = Date.now();
626
620
  testTimes.push([ruleID, Math.round((endTime - startTime) / 1000)]);
627
621
  Object.keys(ruleOrTimeoutReport).forEach(key => {
628
- result[ruleID][key] = ruleOrTimeoutReport[key];
622
+ ruleResult[key] = ruleOrTimeoutReport[key];
629
623
  });
624
+ // If the test was prevented:
625
+ if (ruleResult.data?.prevented && ruleResult.data.error) {
626
+ // Add this to the result.
627
+ data.rulePreventions.push(ruleID);
628
+ data.rulePreventionMessages[ruleID] = ruleResult.data.error;
629
+ }
630
630
  // If the result includes totals:
631
- if (result[ruleID].totals) {
631
+ if (ruleResult.totals) {
632
632
  // Round them.
633
- result[ruleID].totals = result[ruleID].totals.map(total => Math.round(total));
633
+ ruleResult.totals = ruleResult.totals.map(total => Math.round(total));
634
634
  }
635
635
  // Prevent a retry of the test.
636
636
  testSuccess = true;
637
637
  // If testing is to stop after a failure and the page failed the test:
638
- if (
639
- stopOnFail
640
- && ruleOrTimeoutReport.totals
641
- && ruleOrTimeoutReport.totals.some(total => total)) {
638
+ if (stopOnFail && ruleResult.totals && ruleResult.totals.some(total => total)) {
642
639
  // Stop testing.
643
640
  break;
644
641
  }
645
642
  }
646
643
  // Otherwise, i.e. if the test timed out:
647
644
  else {
645
+ // Report this.
646
+ data.rulePreventions.push(ruleID);
647
+ data.rulePreventionMessages[ruleID] = 'Timeout';
648
648
  // Stop retrying the test.
649
649
  break;
650
650
  }
package/procs/operable.js DELETED
@@ -1,108 +0,0 @@
1
- /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
3
-
4
- MIT License
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
- */
24
-
25
- /*
26
- operable
27
- Returns whether the element of a locator is operable., i.e. it has a non-inherited pointer cursor
28
- and is not a 'LABEL' element, has an operable tag name, has an interactive explicit role, or has
29
- an 'onclick' attribute. The isOperable function modifies the page.
30
- */
31
-
32
- // ########## FUNCTIONS
33
-
34
- // Gets whether an element is operable.
35
- exports.isOperable = async loc => {
36
- // Get whether and, if so, how the element is operable.
37
- const operabilities = await loc.evaluate(el => {
38
- // Operable tag names.
39
- const opTags = new Set(['A', 'BUTTON', 'IFRAME', 'INPUT', 'SELECT', 'TEXTAREA']);
40
- // Operable roles.
41
- const opRoles = new Set([
42
- 'button',
43
- 'checkbox',
44
- 'combobox',
45
- 'composite',
46
- 'grid',
47
- 'gridcell',
48
- 'input',
49
- 'link',
50
- 'listbox',
51
- 'menu',
52
- 'menubar',
53
- 'menuitem',
54
- 'menuitemcheckbox',
55
- 'option',
56
- 'radio',
57
- 'radiogroup',
58
- 'scrollbar',
59
- 'searchbox',
60
- 'select',
61
- 'slider',
62
- 'spinbutton',
63
- 'switch',
64
- 'tab',
65
- 'tablist',
66
- 'textbox',
67
- 'tree',
68
- 'treegrid',
69
- 'treeitem',
70
- 'widget',
71
- ]);
72
- // Initialize the operabilities.
73
- const opHow = [];
74
- // If the element is not a label and has a non-inherited pointer cursor:
75
- let hasPointer = false;
76
- if (el.tagName !== 'LABEL') {
77
- const styleDec = window.getComputedStyle(el);
78
- hasPointer = styleDec.cursor === 'pointer';
79
- if (hasPointer) {
80
- el.parentElement.style.cursor = 'default';
81
- hasPointer = styleDec.cursor === 'pointer';
82
- }
83
- }
84
- if (hasPointer) {
85
- // Add this to the operabilities.
86
- opHow.push('pointer cursor');
87
- }
88
- // If the element is clickable:
89
- if (el.onclick) {
90
- // Add this to the operabilities.
91
- opHow.push('click listener');
92
- }
93
- // If the element has an operable explicit role:
94
- const role = el.getAttribute('role');
95
- if (opRoles.has(role)) {
96
- // Add this to the operabilities.
97
- opHow.push(`role ${role}`);
98
- }
99
- // If the element has an operable type:
100
- const tagName = el.tagName;
101
- if (opTags.has(tagName)) {
102
- // Add this to the operabilities.
103
- opHow.push(`tag name ${tagName}`);
104
- }
105
- return opHow;
106
- });
107
- return operabilities;
108
- };
package/testaro/focOp.js DELETED
@@ -1,75 +0,0 @@
1
- /*
2
- © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
- © 2025 Jonathan Robert Pool. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all
15
- copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- SOFTWARE.
24
- */
25
-
26
- /*
27
- focOp
28
- Related to Tenon rule 190.
29
-
30
- This test reports Tab-focusable elements that are not operable. The standard practice is to make
31
- focusable elements operable. If focusable elements are not operable, users are likely to be
32
- surprised that nothing happens when they try to operate such elements. The test considers an
33
- element operable if it has a non-inherited pointer cursor and is not a 'LABEL' element, has an
34
- operable tag name, has an interactive explicit role, or has an 'onclick' attribute. The test
35
- considers an element Tab-focusable if its tabIndex property has the value 0.
36
- */
37
-
38
- // ########## IMPORTS
39
-
40
- // Module to perform common operations.
41
- const {init, getRuleResult} = require('../procs/testaro');
42
- // Module to get operabilities.
43
- const {isOperable} = require('../procs/operable');
44
-
45
- // ########## FUNCTIONS
46
-
47
- // Runs the test and returns the result.
48
- exports.reporter = async (page, withItems) => {
49
- // Initialize the locators and result.
50
- const all = await init(100, page, 'body *');
51
- all.result.data.focusableCount = 0;
52
- // For each locator:
53
- for (const loc of all.allLocs) {
54
- // Get whether its element is focusable.
55
- const isFocusable = await loc.evaluate(el => el.tabIndex === 0);
56
- // If it is:
57
- if (isFocusable) {
58
- // Add this to the report.
59
- all.result.data.focusableCount++;
60
- // Get whether it is operable.
61
- const howOperable = await isOperable(loc);
62
- // If it is not:
63
- if (! howOperable.length) {
64
- // Add the locator to the array of violators.
65
- all.locs.push(loc);
66
- }
67
- }
68
- }
69
- // Populate and return the result.
70
- const whats = [
71
- 'Element is Tab-focusable but not operable', 'Elements are Tab-focusable but not operable'
72
- ];
73
- const result = await getRuleResult(withItems, all, 'focOp', whats, 2);
74
- return result;
75
- };
@@ -1,62 +0,0 @@
1
- /*
2
- © 2022–2023 CVS Health and/or one of its affiliates. All rights reserved.
3
-
4
- MIT License
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
- */
24
-
25
- /*
26
- miniText
27
- Derived from the bbc-a11y textCannotBeTooSmall test.
28
- Related to Tenon rule 134.
29
- This test reports elements with font sizes smaller than 11 pixels.
30
- */
31
-
32
- // Module to perform common operations.
33
- const {init, getRuleResult} = require('../procs/testaro');
34
-
35
- // ########## FUNCTIONS
36
-
37
- // Runs the test and returns the result.
38
- exports.reporter = async (page, withItems) => {
39
- // Initialize the locators and result.
40
- const all = await init(100, page, 'body *:not(script, style):visible', {hasText: /[^\s]+/});
41
- // For each locator:
42
- for (const loc of all.allLocs) {
43
- // Get the font size of its element if less than 11 pixels.
44
- const fontSize = await loc.evaluate(el => {
45
- const styleDec = window.getComputedStyle(el);
46
- const fontSizeString = styleDec.fontSize;
47
- const fontSize = Number.parseFloat(fontSizeString);
48
- return fontSize < 11 ? fontSize : null;
49
- });
50
- // If it violates the rule:
51
- if (fontSize) {
52
- // Add the locator to the array of violators.
53
- all.locs.push([loc, fontSize]);
54
- }
55
- }
56
- // Populate and return the result.
57
- const whats = [
58
- 'Element has a font size of __param__ pixels, smaller than 11 pixels',
59
- 'Elements have font sizes smaller than 11 pixels'
60
- ];
61
- return await getRuleResult(withItems, all, 'miniText', whats, 2);
62
- };