testaro 72.2.3 → 72.3.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": "72.2.3",
3
+ "version": "72.3.0",
4
4
  "description": "Run 1300 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,9 +8,9 @@
8
8
  */
9
9
 
10
10
  /*
11
- targetSmall
11
+ targetsNear
12
12
  Related to Tenon rule 152.
13
- This test reports visible pointer targets, i.e. labels, buttons, inputs, and links, that are small enough or near enough to other targets to make pointer interaction difficult. This test relates to WCAG 2.2 Success Criteria 2.5.5 and 2.5.8, but does not attempt to implement either of them precisely. For example, the test reports a small pointer target that is far from all other targets, although it conforms to the Success Criteria.
13
+ This test reports visible pointer targets, i.e. labels, buttons, inputs, and links, that are near enough to other targets to make pointer interaction difficult. This test relates to WCAG 2.2 Success Criteria 2.5.5 and 2.5.8, but does not attempt to implement either of them precisely. For example, the test reports a small pointer target that is far from all other targets, although it conforms to the Success Criteria.
14
14
  */
15
15
 
16
16
  // IMPORTS
@@ -24,17 +24,41 @@ exports.reporter = async (page, catalog, withItems) => {
24
24
  // Return totals and standard instances for the rule.
25
25
  const protoResult = await page.evaluate(withItems => {
26
26
  // Get all pointer targets.
27
- const allPTs = Array.from(document.body.querySelectorAll('label, button, input, a'));
27
+ const allTargets = Array.from(document.body.querySelectorAll('label, button, input, a'));
28
28
  // Get the visible ones.
29
- const visiblePTs = allPTs.filter(pt => pt.checkVisibility({
29
+ const visibleTargets = allTargets.filter(target => target.checkVisibility({
30
30
  contentVisibilityAuto: true,
31
31
  opacityProperty: true,
32
32
  visibilityProperty: true
33
33
  }));
34
+ // For each visible one:
35
+ const visibleBlockTargets = visibleTargets.filter(target => {
36
+ const style = window.getComputedStyle(target);
37
+ // If it is block-displayed:
38
+ if (['block', 'list-item', 'table-cell'].includes(style.display)) {
39
+ // Include it.
40
+ return true;
41
+ }
42
+ const parent = target.parentElement;
43
+ // Otherwise, if it has a parent:
44
+ if (parent) {
45
+ // If the parent has no additional text:
46
+ if (parent.innerText === target.innerText) {
47
+ const parentStyle = window.getComputedStyle(parent);
48
+ // If the parent is block-displayed:
49
+ if (['block', 'list-item', 'table-cell'].includes(parentStyle.display)) {
50
+ // Include the target.
51
+ return true;
52
+ }
53
+ }
54
+ }
55
+ // Otherwise, exclude it.
56
+ return false;
57
+ });
34
58
  // Initialize the data.
35
59
  const ptsData = [];
36
- // For each visible pointer target:
37
- visiblePTs.forEach(element => {
60
+ // For each visible block-displayed pointer target:
61
+ visibleBlockTargets.forEach(element => {
38
62
  // Get the coordinates of its centerpoint.
39
63
  const rect = element.getBoundingClientRect();
40
64
  const centerX = rect.left + rect.width / 2;
@@ -45,8 +69,8 @@ exports.reporter = async (page, catalog, withItems) => {
45
69
  // Initialize the counts of minor and major violations.
46
70
  let violationCounts = [0, 0];
47
71
  const protoInstances = [];
48
- // For each visible pointer target:
49
- visiblePTs.forEach((element, index) => {
72
+ // For each visible block-displayed pointer target:
73
+ visibleBlockTargets.forEach((element, index) => {
50
74
  const [centerX, centerY] = ptsData[index];
51
75
  const otherPTsData = ptsData.toSpliced(index, 1);
52
76
  // Get the minimum of the vertical distances of its centerpoint from those of the others.
@@ -66,6 +90,7 @@ exports.reporter = async (page, catalog, withItems) => {
66
90
  }));
67
91
  // If the minimum planar distance is less than 44px:
68
92
  if (minPlanarDistance < 44) {
93
+ // Get whether it is less than 24px.
69
94
  const isVeryNear = minPlanarDistance < 24;
70
95
  // Get the ordinal severity of the violation.
71
96
  const ordinalSeverity = isVeryNear ? 3 : 2;
@@ -76,7 +101,7 @@ exports.reporter = async (page, catalog, withItems) => {
76
101
  const what = `Pointer-target centerpoint is only ${Math.round(minPlanarDistance)}px from another one`;
77
102
  // Add a proto-instance to the proto-instances.
78
103
  protoInstances.push({
79
- ruleID: 'targetSmall',
104
+ ruleID: 'targetsNear',
80
105
  what,
81
106
  ordinalSeverity,
82
107
  count: 1,
@@ -92,7 +117,7 @@ exports.reporter = async (page, catalog, withItems) => {
92
117
  if (violationCounts[1]) {
93
118
  // Add a summary instance to the proto-instances.
94
119
  protoInstances.push({
95
- ruleID: 'targetSmall',
120
+ ruleID: 'targetsNear',
96
121
  what: 'Pointer-target centerpoints are less than 24px from others',
97
122
  ordinalSeverity: 1,
98
123
  count: violationCounts[1]
@@ -102,7 +127,7 @@ exports.reporter = async (page, catalog, withItems) => {
102
127
  if (violationCounts[0]) {
103
128
  // Add a summary instance to the proto-instances.
104
129
  protoInstances.push({
105
- ruleID: 'targetSmall',
130
+ ruleID: 'targetsNear',
106
131
  what: 'Pointer-target centerpoints are less than 44px from others',
107
132
  ordinalSeverity: 0,
108
133
  count: violationCounts[0]
package/tests/testaro.js CHANGED
@@ -288,7 +288,7 @@ const allRules = [
288
288
  defaultOn: true
289
289
  },
290
290
  {
291
- id: 'targetSmall',
291
+ id: 'targetsNear',
292
292
  what: 'labels, buttons, inputs, and links too near each other',
293
293
  contaminates: false,
294
294
  needsAccessibleName: false,
@@ -1,11 +1,11 @@
1
1
  {
2
- "rule": "targetSmall",
2
+ "rule": "targetsNear",
3
3
  "timeLimit": 20,
4
4
  "acts": [
5
5
  {
6
6
  "type": "launch",
7
7
  "target": {
8
- "url": "file://validation/tests/targetSmall/index.html",
8
+ "url": "file://validation/tests/targetsNear/index.html",
9
9
  "what": "page with variously sized interaction targets"
10
10
  }
11
11
  },
@@ -28,7 +28,7 @@
28
28
  [
29
29
  "standardResult.instances.0.ruleID",
30
30
  "=",
31
- "targetSmall"
31
+ "targetsNear"
32
32
  ],
33
33
  [
34
34
  "standardResult.instances.0.what",
@@ -103,7 +103,7 @@
103
103
  ],
104
104
  "rules": [
105
105
  "y",
106
- "targetSmall"
106
+ "targetsNear"
107
107
  ]
108
108
  },
109
109
  {
@@ -125,7 +125,7 @@
125
125
  [
126
126
  "standardResult.instances.0.ruleID",
127
127
  "=",
128
- "targetSmall"
128
+ "targetsNear"
129
129
  ],
130
130
  [
131
131
  "standardResult.instances.0.what",
@@ -145,7 +145,7 @@
145
145
  ],
146
146
  "rules": [
147
147
  "y",
148
- "targetSmall"
148
+ "targetsNear"
149
149
  ]
150
150
  }
151
151
  ]
@@ -5,7 +5,7 @@
5
5
  {
6
6
  "type": "launch",
7
7
  "target": {
8
- "url": "file://validation/tests/targets/targetSmall/index.html",
8
+ "url": "file://validation/tests/targets/targetsNear/index.html",
9
9
  "what": "page with variously sized interaction targets"
10
10
  }
11
11
  },