testaro 60.15.1 → 60.16.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": "60.15.1",
3
+ "version": "60.16.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": {
@@ -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
  };
@@ -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>