testaro 60.16.0 → 60.16.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/testaro/zIndex.js +20 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "60.16.0",
3
+ "version": "60.16.1",
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/testaro/zIndex.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  © 2021–2023 CVS Health and/or one of its affiliates. All rights reserved.
3
+ © 2025 Jonathan Robert Pool
3
4
 
4
5
  Licensed under the MIT License. See LICENSE file at the project root or
5
6
  https://opensource.org/license/mit/ for details.
@@ -9,42 +10,34 @@
9
10
 
10
11
  /*
11
12
  zIndex
12
- This test reports elements with non-auto z indexes. It assumes that pages are most accessible
13
+ This test reports elements with abnormal Z indexes. It assumes that pages are most accessible
13
14
  when they do not require users to perceive a third dimension (depth). Layers, popups, and dialogs
14
15
  that cover other content make it difficult for some or all users to interpret the content and
15
- know what parts of the content can be acted on. Layering also complicates accessibility control.
16
+ know what parts of the content can be acted on. Layering also complicates accessibility testing.
16
17
  Tests for visibility of focus, for example, may fail if incapable of detecting that a focused
17
- element is covered by another element.
18
+ element is covered by another element. Z indexes other than auto and 0 are considered abnormal.
18
19
  */
19
20
 
20
- // ########## IMPORTS
21
+ // IMPORTS
21
22
 
22
- // Module to perform common operations.
23
- const {init, getRuleResult} = require('../procs/testaro');
23
+ const {doTest} = require('../procs/testaro');
24
24
 
25
- // ########## FUNCTIONS
25
+ // FUNCTIONS
26
26
 
27
27
  // Runs the test and returns the result.
28
28
  exports.reporter = async (page, withItems) => {
29
- // Initialize the locators and result.
30
- const all = await init(100, page, 'body *');
31
- // For each locator:
32
- for (const loc of all.allLocs) {
33
- // Get whether its element violates the rule.
34
- const badZ = await loc.evaluate(el => {
35
- const styleDec = window.getComputedStyle(el);
36
- const {zIndex} = styleDec;
37
- return zIndex !== 'auto' ? zIndex : null;
38
- });
39
- // If it does:
40
- if (badZ) {
41
- // Add the locator to the array of violators.
42
- all.locs.push([loc, badZ]);
29
+ const getBadWhat = element => {
30
+ // Get whether the element violates the rule.
31
+ const styleDec = window.getComputedStyle(element);
32
+ const {zIndex} = styleDec;
33
+ // If the Z index of the element is neither 'auto' nor 0:
34
+ if (! ['auto', '0'].includes(zIndex)) {
35
+ // Return a violation description.
36
+ return `z-index style property of the element is ${zIndex}`;
43
37
  }
44
- }
45
- // Populate and return the result.
46
- const whats = [
47
- 'Element has a non-default Z index (__param__)', 'Elements have non-default Z indexes'
48
- ];
49
- return await getRuleResult(withItems, all, 'zIndex', whats, 0);
38
+ };
39
+ const whats = 'Elements have non-default Z indexes';
40
+ return await doTest(
41
+ page, withItems, 'zIndex', 'body *', whats, 0, null, getBadWhat.toString()
42
+ );
50
43
  };