testaro 60.15.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "60.15.1",
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": {
@@ -46,7 +46,7 @@ exports.reporter = async (page, withItems) => {
46
46
  }
47
47
  }
48
48
  };
49
- const selector = 'SECTION, ARTICLE, NAV, ASIDE, MAIN';
49
+ const selector = 'section, article, nav, aside, main';
50
50
  const whats = 'First child headings of sectioning containers are deeper than others';
51
51
  return await doTest(
52
52
  page, withItems, 'secHeading', selector, whats, 0, null, getBadWhat.toString()
@@ -48,15 +48,15 @@ exports.reporter = async (page, withItems) => {
48
48
  const instances = [];
49
49
  // For each visible pointer target:
50
50
  visiblePTs.forEach((element, index) => {
51
+ const [centerX, centerY] = ptsData[index];
52
+ const otherPTsData = ptsData.toSpliced(index, 1);
51
53
  // Get the minimum of the vertical distances of its centerpoint from those of the others.
52
- const minYDiff = ptsData[index][1] - Math.abs(
53
- Math.min(...ptsData.splice(index, 1).map(ptData => ptData[1]))
54
- );
54
+ const minYDiff = Math.min(...otherPTsData.map(ptData => Math.abs(centerY - ptData[1])));
55
55
  // If it is close enough to make a violation possible:
56
56
  if (minYDiff < 44) {
57
57
  // Get the centerpoint coordinates of those within that vertical distance.
58
- const yNearPTsData = ptsData.splice(index, 1).filter(
59
- ptData => Math.abs(ptData[1] - ptsData[index][1]) < 44
58
+ const yNearPTsData = otherPTsData.filter(
59
+ ptData => Math.abs(ptData[1] - centerY) < 44
60
60
  );
61
61
  // Get the minimum of their planar distances.
62
62
  const minPlanarDistance = Math.min(...yNearPTsData.map(ptData => {
@@ -13,21 +13,32 @@
13
13
  Report semantically vague inline elements: i, b, small
14
14
  */
15
15
 
16
- const {init, getRuleResult} = require('../procs/testaro');
16
+ // IMPORTS
17
17
 
18
+ const {doTest} = require('../procs/testaro');
19
+
20
+ // FUNCTIONS
21
+
22
+ // Runs the test and returns the result.
18
23
  exports.reporter = async (page, withItems) => {
19
- const all = await init(100, page, 'i, b, small');
20
- for (const loc of all.allLocs) {
21
- // Consider only elements with visible text
22
- const isBad = await loc.evaluate(el => {
23
- const text = (el.textContent || '').trim();
24
- return !!text;
24
+ const getBadWhat = element => {
25
+ const isVisible = element.checkVisibility({
26
+ contentVisibilityAuto: true,
27
+ opacityProperty: true,
28
+ visibilityProperty: true
25
29
  });
26
- if (isBad) all.locs.push(loc);
27
- }
28
- const whats = [
29
- 'Element is semantically vague',
30
- 'Semantically vague elements i, b, and/or small are used'
31
- ];
32
- return await getRuleResult(withItems, all, 'textSem', whats, 0);
30
+ // If the element is visible:
31
+ if (isVisible) {
32
+ // If it has text content:
33
+ if (element.textContent.trim().replace(/\s/g, '')) {
34
+ // Return a violation description.
35
+ return `Element type (${element.tagName}) is semantically vague`;
36
+ }
37
+ }
38
+ };
39
+ const selector = 'i, b, small';
40
+ const whats = 'Semantically vague elements i, b, and/or small are used';
41
+ return await doTest(
42
+ page, withItems, 'textSem', selector, whats, 0, null, getBadWhat.toString()
43
+ );
33
44
  };
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
  };
@@ -5,7 +5,7 @@
5
5
  {
6
6
  "type": "launch",
7
7
  "target": {
8
- "url": "file://validation/tests/targets/targetSize/index.html",
8
+ "url": "file://validation/tests/targetSmall/index.html",
9
9
  "what": "page with variously sized interaction targets"
10
10
  }
11
11
  },
@@ -5,7 +5,7 @@
5
5
  {
6
6
  "type": "launch",
7
7
  "target": {
8
- "url": "file://validation/tests/targets/targetSize/index.html",
8
+ "url": "file://validation/tests/targets/targetSmall/index.html",
9
9
  "what": "page with variously sized interaction targets"
10
10
  }
11
11
  },
@@ -11,7 +11,7 @@
11
11
  <html lang="en-US">
12
12
  <head>
13
13
  <meta charset="utf-8">
14
- <title>Page with variously sized interaction targets</title>
14
+ <title>Page with variously sized and spaced interaction targets</title>
15
15
  <meta name="description" content="tester">
16
16
  <meta name="viewport" content="width=device-width, initial-scale=1">
17
17
  <style>
@@ -34,6 +34,10 @@
34
34
  padding-top: 0;
35
35
  padding-bottom: 0;
36
36
  }
37
+ button.tiny {
38
+ width: 0.25rem;
39
+ height: 0.25rem;
40
+ }
37
41
  #defaultbutton {
38
42
  min-height: 25px;
39
43
  }
@@ -49,9 +53,12 @@
49
53
  <h1>Page with variously sized interaction targets</h1>
50
54
  <h2>Buttons</h2>
51
55
  <p>Here are three buttons:</p>
52
- <p><button style="min-width: 3rem; min-height: 3rem" type="button">Big enough</button></p>
53
- <p><button id="defaultbutton" type="button">Default (small)</button></p>
54
- <p><button style="height: 1.25rem" type="button">Tiny</button></p>
56
+ <p><button style="min-width: 3rem; min-height: 3rem" type="button">Very big</button></p>
57
+ <p><button id="defaultbutton" type="button">Big</button></p>
58
+ <p><button style="height: 1.25rem" type="button">Moderate</button></p>
59
+ <p>Here are three more that are tiny:</p>
60
+ <p><button class="tiny" type="button">X</button><button class="tiny" type="button">Y</button><button class="tiny" type="button">Z</button></p>
61
+ <p><button style="width: 0.5rem; height: 0.5rem" type="button"></button></p>
55
62
  <h2>Inputs</h2>
56
63
  <p>Here are three inputs:</p>
57
64
  <p><label>Big box: <input style="min-width: 3rem; min-height: 3rem" size="20" maxlength="30"></label></p>
@@ -68,9 +75,7 @@
68
75
  <li style="min-height: 3rem">W3C: <a class="deep" href="https://w3c.org">World Wide Web Consortium (big)</a></li>
69
76
  <li>WF: <a href="https://wikimedia.org">Wikimedia Foundation (small but inline)</a></li>
70
77
  <li>WF: <a href="https://wikimedia.org">Wikimedia Foundation (tiny but inline)</a></li>
71
- <h2>Violations</h2>
72
- <p>Small: 2 buttons, 2 inputs, 2 links</p>
73
- <p>Tiny: 1 button, 1 input, 1 link</p>
78
+ <p>Violations to be determined after refactoring and redefinition</p>
74
79
  </ul>
75
80
  </main>
76
81
  </body>