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.
- package/package.json +1 -1
- package/testaro/zIndex.js +20 -27
package/package.json
CHANGED
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
|
|
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
|
|
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
|
-
//
|
|
21
|
+
// IMPORTS
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
const {init, getRuleResult} = require('../procs/testaro');
|
|
23
|
+
const {doTest} = require('../procs/testaro');
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// FUNCTIONS
|
|
26
26
|
|
|
27
27
|
// Runs the test and returns the result.
|
|
28
28
|
exports.reporter = async (page, withItems) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
};
|