testaro 4.14.1 → 5.0.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/README.md +9 -7
- package/commands.js +5 -8
- package/htmlcs/HTMLCS.css +1069 -0
- package/htmlcs/HTMLCS.js +7971 -0
- package/htmlcs/Images/HTMLCS-tools.png +0 -0
- package/htmlcs/Images/bgTexture1.gif +0 -0
- package/htmlcs/Images/summaryLoader-error.gif +0 -0
- package/htmlcs/Images/summaryLoader-notice.gif +0 -0
- package/htmlcs/Images/summaryLoader-warning.gif +0 -0
- package/htmlcs/licence.txt +24 -0
- package/package.json +1 -2
- package/run.js +2 -2
- package/samples/scripts/tp11.json +164 -0
- package/samples/scripts/tp12.json +162 -0
- package/tests/hover.js +71 -42
- package/tests/htmlcs.js +55 -0
- package/tests/ibm.js +1 -1
- package/samples/batches/a11yorgs.json +0 -276
- package/samples/batches/doordash.json +0 -11
- package/samples/batches/greiner.json +0 -36
- package/samples/batches/siteimprove.json +0 -11
- package/samples/batches/siteimprovea11y.json +0 -11
- package/tests/aatt.js +0 -127
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2012, Squiz Pty Ltd (ABN 77 084 670 600)
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
* Redistributions of source code must retain the above copyright
|
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
documentation and/or other materials provided with the distribution.
|
|
11
|
+
* Neither the name of Squiz Pty Ltd nor the
|
|
12
|
+
names of its contributors may be used to endorse or promote products
|
|
13
|
+
derived from this software without specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testaro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Automation of accessibility testing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"@siteimprove/alfa-playwright": "*",
|
|
28
28
|
"@siteimprove/alfa-rules": "*",
|
|
29
29
|
"@siteimprove/alfa-scraper": "*",
|
|
30
|
-
"aatt": "*",
|
|
31
30
|
"accessibility-checker": "*",
|
|
32
31
|
"axe-playwright": "*",
|
|
33
32
|
"dotenv": "*",
|
package/run.js
CHANGED
|
@@ -29,7 +29,6 @@ const moves = {
|
|
|
29
29
|
};
|
|
30
30
|
// Names and descriptions of tests.
|
|
31
31
|
const tests = {
|
|
32
|
-
aatt: 'AATT with HTML CodeSniffer WCAG 2.1 AA ruleset',
|
|
33
32
|
alfa: 'alfa',
|
|
34
33
|
axe: 'Axe',
|
|
35
34
|
bulk: 'count of visible elements',
|
|
@@ -38,6 +37,7 @@ const tests = {
|
|
|
38
37
|
focInd: 'focus indicators',
|
|
39
38
|
focOp: 'focusability and operability',
|
|
40
39
|
hover: 'hover-caused content additions',
|
|
40
|
+
htmlcs: 'HTML CodeSniffer WCAG 2.1 A, AA, and AAA rulesets',
|
|
41
41
|
ibm: 'IBM Accessibility Checker',
|
|
42
42
|
labClash: 'labeling inconsistencies',
|
|
43
43
|
linkUl: 'adjacent-link underlining',
|
|
@@ -53,7 +53,7 @@ const tests = {
|
|
|
53
53
|
};
|
|
54
54
|
// Tests that may change the DOM.
|
|
55
55
|
const domChangers = new Set([
|
|
56
|
-
'axe', 'focAll', 'focInd', 'focOp', 'hover', 'ibm', 'menuNav', 'wave'
|
|
56
|
+
'axe', 'focAll', 'focInd', 'focOp', 'hover', 'htmlcs', 'ibm', 'menuNav', 'wave'
|
|
57
57
|
]);
|
|
58
58
|
// Browser types available in PlayWright.
|
|
59
59
|
const browserTypeNames = {
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "tp11",
|
|
3
|
+
"what": "AATT, Alfa, Axe, IBM, Tenon, WAVE, and 16 custom tests",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"commands": [
|
|
6
|
+
{
|
|
7
|
+
"type": "launch",
|
|
8
|
+
"which": "webkit",
|
|
9
|
+
"what": "Webkit browser"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "url",
|
|
13
|
+
"which": "https://*",
|
|
14
|
+
"what": "any page"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "tenonRequest",
|
|
18
|
+
"id": "a",
|
|
19
|
+
"withNewContent": true,
|
|
20
|
+
"what": "Tenon API version 2 test request"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "test",
|
|
24
|
+
"which": "motion",
|
|
25
|
+
"what": "spontaneous change of content; requires webkit",
|
|
26
|
+
"delay": 2500,
|
|
27
|
+
"interval": 2500,
|
|
28
|
+
"count": 5
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "launch",
|
|
32
|
+
"which": "chromium",
|
|
33
|
+
"what": "Chromium browser"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "url",
|
|
37
|
+
"which": "https://*",
|
|
38
|
+
"what": "any page"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "test",
|
|
42
|
+
"which": "bulk",
|
|
43
|
+
"what": "count of visible elements"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "test",
|
|
47
|
+
"which": "embAc",
|
|
48
|
+
"withItems": true,
|
|
49
|
+
"what": "active elements incorrectly embedded in each other"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "test",
|
|
53
|
+
"which": "focAll",
|
|
54
|
+
"what": "Tab-focusability"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "test",
|
|
58
|
+
"which": "focInd",
|
|
59
|
+
"revealAll": false,
|
|
60
|
+
"allowedDelay": 250,
|
|
61
|
+
"withItems": true,
|
|
62
|
+
"what": "focus indicators"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "test",
|
|
66
|
+
"which": "focOp",
|
|
67
|
+
"withItems": true,
|
|
68
|
+
"what": "focusability and operability of elements"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "test",
|
|
72
|
+
"which": "hover",
|
|
73
|
+
"headSize": 20,
|
|
74
|
+
"headSampleSize": 20,
|
|
75
|
+
"tailSampleSize": 15,
|
|
76
|
+
"withItems": true,
|
|
77
|
+
"what": "hover impacts"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "test",
|
|
81
|
+
"which": "labClash",
|
|
82
|
+
"withItems": true,
|
|
83
|
+
"what": "unlabeled and mislabeled form controls"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "test",
|
|
87
|
+
"which": "linkUl",
|
|
88
|
+
"withItems": true,
|
|
89
|
+
"what": "underlining of inline links"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "test",
|
|
93
|
+
"which": "menuNav",
|
|
94
|
+
"withItems": true,
|
|
95
|
+
"what": "keyboard navigation within true-focus menus"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "test",
|
|
99
|
+
"which": "radioSet",
|
|
100
|
+
"withItems": true,
|
|
101
|
+
"what": "grouping of radio buttons in fieldsets"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "test",
|
|
105
|
+
"which": "role",
|
|
106
|
+
"what": "validity and necessity of role assignments"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "test",
|
|
110
|
+
"which": "styleDiff",
|
|
111
|
+
"withItems": true,
|
|
112
|
+
"what": "style consistency of headings, buttons, and links"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "test",
|
|
116
|
+
"which": "tabNav",
|
|
117
|
+
"withItems": true,
|
|
118
|
+
"what": "keyboard navigation within tab lists"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "test",
|
|
122
|
+
"which": "zIndex",
|
|
123
|
+
"withItems": true,
|
|
124
|
+
"what": "elements with non-auto z indexes"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "test",
|
|
128
|
+
"which": "aatt",
|
|
129
|
+
"waitLong": true,
|
|
130
|
+
"tryLimit": 2,
|
|
131
|
+
"what": "AATT with HTML CodeSniffer"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"type": "test",
|
|
135
|
+
"which": "alfa",
|
|
136
|
+
"what": "Siteimprove alfa"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "test",
|
|
140
|
+
"which": "axe",
|
|
141
|
+
"detailLevel": 2,
|
|
142
|
+
"rules": [],
|
|
143
|
+
"what": "Axe core, all rules"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "test",
|
|
147
|
+
"which": "ibm",
|
|
148
|
+
"withItems": true,
|
|
149
|
+
"what": "IBM Accessibility Checker, with page content and again with URL"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "test",
|
|
153
|
+
"which": "tenon",
|
|
154
|
+
"id": "a",
|
|
155
|
+
"what": "Tenon API version 2 result retrieval"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "test",
|
|
159
|
+
"which": "wave",
|
|
160
|
+
"reportType": 4,
|
|
161
|
+
"what": "WAVE, report-type 4"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "tp12",
|
|
3
|
+
"what": "Alfa, Axe, HTML CodeSniffer, IBM, Tenon, WAVE, and 16 custom tests",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"commands": [
|
|
6
|
+
{
|
|
7
|
+
"type": "launch",
|
|
8
|
+
"which": "webkit",
|
|
9
|
+
"what": "Webkit browser"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "url",
|
|
13
|
+
"which": "https://*",
|
|
14
|
+
"what": "any page"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "tenonRequest",
|
|
18
|
+
"id": "a",
|
|
19
|
+
"withNewContent": true,
|
|
20
|
+
"what": "Tenon API version 2 test request"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "test",
|
|
24
|
+
"which": "motion",
|
|
25
|
+
"what": "spontaneous change of content; requires webkit",
|
|
26
|
+
"delay": 2500,
|
|
27
|
+
"interval": 2500,
|
|
28
|
+
"count": 5
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "launch",
|
|
32
|
+
"which": "chromium",
|
|
33
|
+
"what": "Chromium browser"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "url",
|
|
37
|
+
"which": "https://*",
|
|
38
|
+
"what": "any page"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "test",
|
|
42
|
+
"which": "bulk",
|
|
43
|
+
"what": "count of visible elements"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "test",
|
|
47
|
+
"which": "embAc",
|
|
48
|
+
"withItems": true,
|
|
49
|
+
"what": "active elements incorrectly embedded in each other"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "test",
|
|
53
|
+
"which": "focAll",
|
|
54
|
+
"what": "Tab-focusability"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "test",
|
|
58
|
+
"which": "focInd",
|
|
59
|
+
"revealAll": false,
|
|
60
|
+
"allowedDelay": 250,
|
|
61
|
+
"withItems": true,
|
|
62
|
+
"what": "focus indicators"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "test",
|
|
66
|
+
"which": "focOp",
|
|
67
|
+
"withItems": true,
|
|
68
|
+
"what": "focusability and operability of elements"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "test",
|
|
72
|
+
"which": "hover",
|
|
73
|
+
"headSize": 20,
|
|
74
|
+
"headSampleSize": 20,
|
|
75
|
+
"tailSampleSize": 15,
|
|
76
|
+
"withItems": true,
|
|
77
|
+
"what": "hover impacts"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "test",
|
|
81
|
+
"which": "labClash",
|
|
82
|
+
"withItems": true,
|
|
83
|
+
"what": "unlabeled and mislabeled form controls"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"type": "test",
|
|
87
|
+
"which": "linkUl",
|
|
88
|
+
"withItems": true,
|
|
89
|
+
"what": "underlining of inline links"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "test",
|
|
93
|
+
"which": "menuNav",
|
|
94
|
+
"withItems": true,
|
|
95
|
+
"what": "keyboard navigation within true-focus menus"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "test",
|
|
99
|
+
"which": "radioSet",
|
|
100
|
+
"withItems": true,
|
|
101
|
+
"what": "grouping of radio buttons in fieldsets"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "test",
|
|
105
|
+
"which": "role",
|
|
106
|
+
"what": "validity and necessity of role assignments"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "test",
|
|
110
|
+
"which": "styleDiff",
|
|
111
|
+
"withItems": true,
|
|
112
|
+
"what": "style consistency of headings, buttons, and links"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "test",
|
|
116
|
+
"which": "tabNav",
|
|
117
|
+
"withItems": true,
|
|
118
|
+
"what": "keyboard navigation within tab lists"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "test",
|
|
122
|
+
"which": "zIndex",
|
|
123
|
+
"withItems": true,
|
|
124
|
+
"what": "elements with non-auto z indexes"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "test",
|
|
128
|
+
"which": "alfa",
|
|
129
|
+
"what": "Siteimprove alfa"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "test",
|
|
133
|
+
"which": "axe",
|
|
134
|
+
"detailLevel": 2,
|
|
135
|
+
"rules": [],
|
|
136
|
+
"what": "Axe core, all rules"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "test",
|
|
140
|
+
"which": "htmlcs",
|
|
141
|
+
"what": "HTML CodeSniffer"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"type": "test",
|
|
145
|
+
"which": "ibm",
|
|
146
|
+
"withItems": true,
|
|
147
|
+
"what": "IBM Accessibility Checker, with page content and again with URL"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"type": "test",
|
|
151
|
+
"which": "tenon",
|
|
152
|
+
"id": "a",
|
|
153
|
+
"what": "Tenon API version 2 result retrieval"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "test",
|
|
157
|
+
"which": "wave",
|
|
158
|
+
"reportType": 4,
|
|
159
|
+
"what": "WAVE, report-type 4"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
package/tests/hover.js
CHANGED
|
@@ -11,9 +11,14 @@
|
|
|
11
11
|
opacity of an element changes, and (4) the element is a descendant of an element whose opacity
|
|
12
12
|
changes. The test checks up to 4 times for hovering impacts at intervals of 0.3 second.
|
|
13
13
|
|
|
14
|
-
Despite this delay, the test can make the execution time practical by randomly sampling
|
|
14
|
+
Despite this delay, the test can make the execution time practical by randomly sampling triggers
|
|
15
15
|
instead of hovering over all of them. When sampling is performed, the results may vary from one
|
|
16
|
-
execution to another.
|
|
16
|
+
execution to another. Because hover impacts typically occur near the beginning of a page,
|
|
17
|
+
sampling is governed by three optional parameters (defaults in parentheses):
|
|
18
|
+
headSize (0): the size of an initial subset of triggers (“head”)
|
|
19
|
+
headSampleSize (-1): the size of the sample to be drawn from the head
|
|
20
|
+
tailSampleSize (-1): the size of the sample to be drawn from the remainder of the page
|
|
21
|
+
A sample size of -1 means that there is no sampling, and the entire population is tested.
|
|
17
22
|
|
|
18
23
|
An element is reported as unhoverable when it fails the Playwright actionability checks for
|
|
19
24
|
hovering, i.e. fails to be attached to the DOM, visible, stable (not or no longer animating), and
|
|
@@ -27,13 +32,15 @@
|
|
|
27
32
|
|
|
28
33
|
// Initialize the result.
|
|
29
34
|
const data = {
|
|
30
|
-
populationSize: 0,
|
|
31
35
|
totals: {
|
|
36
|
+
triggers: 0,
|
|
37
|
+
headTriggers: 0,
|
|
38
|
+
tailTriggers: 0,
|
|
32
39
|
impactTriggers: 0,
|
|
33
40
|
additions: 0,
|
|
34
41
|
removals: 0,
|
|
35
42
|
opacityChanges: 0,
|
|
36
|
-
|
|
43
|
+
opacityImpact: 0,
|
|
37
44
|
unhoverables: 0
|
|
38
45
|
}
|
|
39
46
|
};
|
|
@@ -43,16 +50,22 @@ const data = {
|
|
|
43
50
|
// Samples a population and returns the sample.
|
|
44
51
|
const getSample = (population, sampleSize) => {
|
|
45
52
|
const popSize = population.length;
|
|
46
|
-
if (sampleSize
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
if (sampleSize === 0) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
else if (sampleSize > 0 && sampleSize < popSize) {
|
|
57
|
+
const popData = [];
|
|
58
|
+
for (const trigger of population) {
|
|
59
|
+
popData.push({
|
|
60
|
+
trigger,
|
|
61
|
+
sorter: Math.random()
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
popData.sort((a, b) => a.sorter - b.sorter);
|
|
65
|
+
return popData.slice(0, sampleSize).map(obj => obj.trigger);
|
|
53
66
|
}
|
|
54
67
|
else {
|
|
55
|
-
return
|
|
68
|
+
return population;
|
|
56
69
|
}
|
|
57
70
|
};
|
|
58
71
|
// Returns the text of an element.
|
|
@@ -62,11 +75,11 @@ const textOf = async (element, limit) => {
|
|
|
62
75
|
return text.trim().replace(/\s*/sg, '').slice(0, limit);
|
|
63
76
|
};
|
|
64
77
|
// Recursively reports impacts of hovering over triggers.
|
|
65
|
-
const find = async (withItems, page,
|
|
78
|
+
const find = async (withItems, page, region, sample, popRatio) => {
|
|
66
79
|
// If any potential triggers remain:
|
|
67
|
-
if (
|
|
80
|
+
if (sample.length) {
|
|
68
81
|
// Identify the first of them.
|
|
69
|
-
const firstTrigger =
|
|
82
|
+
const firstTrigger = sample[0];
|
|
70
83
|
const tagNameJSHandle = await firstTrigger.getProperty('tagName')
|
|
71
84
|
.catch(error => {
|
|
72
85
|
console.log(`ERROR getting trigger tag name (${error.message})`);
|
|
@@ -126,9 +139,9 @@ const find = async (withItems, page, triggers) => {
|
|
|
126
139
|
}
|
|
127
140
|
const opacityChangers = remainers
|
|
128
141
|
.filter(remainer => remainer.postOpacity !== remainer.preOpacity);
|
|
129
|
-
const opacityImpact = await page.evaluate(changers => changers.reduce(
|
|
142
|
+
const opacityImpact = opacityChangers ? await page.evaluate(changers => changers.reduce(
|
|
130
143
|
(total, current) => total + current.element.querySelectorAll('*').length, 0
|
|
131
|
-
), opacityChangers);
|
|
144
|
+
), opacityChangers) : 0;
|
|
132
145
|
if (additionCount || removalCount || opacityChangers.length) {
|
|
133
146
|
return {
|
|
134
147
|
additionCount,
|
|
@@ -165,15 +178,15 @@ const find = async (withItems, page, triggers) => {
|
|
|
165
178
|
await root.waitForElementState('stable');
|
|
166
179
|
// Increment the counts of triggers and impacts.
|
|
167
180
|
const {additionCount, removalCount, opacityChangers, opacityImpact} = impacts;
|
|
168
|
-
data.totals.impactTriggers
|
|
169
|
-
data.totals.additions += additionCount;
|
|
170
|
-
data.totals.removals += removalCount;
|
|
171
|
-
data.totals.opacityChanges += opacityChangers.length;
|
|
172
|
-
data.totals.opacityImpact += opacityImpact;
|
|
181
|
+
data.totals.impactTriggers += popRatio;
|
|
182
|
+
data.totals.additions += popRatio * additionCount;
|
|
183
|
+
data.totals.removals += popRatio * removalCount;
|
|
184
|
+
data.totals.opacityChanges += popRatio * opacityChangers.length;
|
|
185
|
+
data.totals.opacityImpact += popRatio * opacityImpact;
|
|
173
186
|
// If details are to be reported:
|
|
174
187
|
if (withItems) {
|
|
175
188
|
// Report them.
|
|
176
|
-
data.items.impactTriggers.push({
|
|
189
|
+
data.items[region].impactTriggers.push({
|
|
177
190
|
tagName,
|
|
178
191
|
text: await textOf(firstTrigger, 50),
|
|
179
192
|
additions: additionCount,
|
|
@@ -189,7 +202,7 @@ const find = async (withItems, page, triggers) => {
|
|
|
189
202
|
data.totals.unhoverables++;
|
|
190
203
|
if (withItems) {
|
|
191
204
|
const id = await firstTrigger.getAttribute('id');
|
|
192
|
-
data.items.unhoverables.push({
|
|
205
|
+
data.items[region].unhoverables.push({
|
|
193
206
|
tagName,
|
|
194
207
|
id: id || '',
|
|
195
208
|
text: await textOf(firstTrigger, 50)
|
|
@@ -198,17 +211,25 @@ const find = async (withItems, page, triggers) => {
|
|
|
198
211
|
}
|
|
199
212
|
}
|
|
200
213
|
// Process the remaining potential triggers.
|
|
201
|
-
await find(withItems, page,
|
|
214
|
+
await find(withItems, page, region, sample.slice(1), popRatio);
|
|
202
215
|
}
|
|
203
216
|
};
|
|
204
|
-
// Performs hover test and reports results.
|
|
205
|
-
exports.reporter = async (
|
|
217
|
+
// Performs the hover test and reports results.
|
|
218
|
+
exports.reporter = async (
|
|
219
|
+
page, headSize = 0, headSampleSize = -1, tailSampleSize = -1, withItems
|
|
220
|
+
) => {
|
|
206
221
|
// If details are to be reported:
|
|
207
222
|
if (withItems) {
|
|
208
223
|
// Add properties for details to the initialized result.
|
|
209
224
|
data.items = {
|
|
210
|
-
|
|
211
|
-
|
|
225
|
+
head: {
|
|
226
|
+
impactTriggers: [],
|
|
227
|
+
unhoverables: []
|
|
228
|
+
},
|
|
229
|
+
tail: {
|
|
230
|
+
impactTriggers: [],
|
|
231
|
+
unhoverables: []
|
|
232
|
+
}
|
|
212
233
|
};
|
|
213
234
|
}
|
|
214
235
|
// Identify the triggers.
|
|
@@ -219,20 +240,28 @@ exports.reporter = async (page, sampleSize = Infinity, withItems) => {
|
|
|
219
240
|
data.prevented = true;
|
|
220
241
|
return [];
|
|
221
242
|
});
|
|
222
|
-
//
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
// Classify them into head and tail triggers.
|
|
244
|
+
const headTriggers = triggers.slice(0, headSize);
|
|
245
|
+
const tailTriggers = triggers.slice(headSize);
|
|
246
|
+
const headTriggerCount = headTriggers.length;
|
|
247
|
+
const tailTriggerCount = tailTriggers.length;
|
|
248
|
+
data.totals.triggers = headTriggerCount + tailTriggerCount;
|
|
249
|
+
data.totals.headTriggers = headTriggerCount;
|
|
250
|
+
data.totals.tailTriggers = tailTriggerCount;
|
|
251
|
+
// Get the head and tail samples.
|
|
252
|
+
const headSample = getSample(headTriggers, headSampleSize);
|
|
253
|
+
const tailSample = tailSampleSize === -1 ? tailTriggers : getSample(tailTriggers, tailSampleSize);
|
|
254
|
+
// Find and document the impacts.
|
|
255
|
+
if (headSample.length) {
|
|
256
|
+
await find(withItems, page, 'head', headSample, headTriggerCount / headSample.length);
|
|
235
257
|
}
|
|
258
|
+
if (tailSample.length) {
|
|
259
|
+
await find(withItems, page, 'tail', tailSample, tailTriggerCount / tailSample.length);
|
|
260
|
+
}
|
|
261
|
+
// Round the reported totals.
|
|
262
|
+
Object.keys(data.totals).forEach(key => {
|
|
263
|
+
data.totals[key] = Math.round(data.totals[key]);
|
|
264
|
+
});
|
|
236
265
|
// Return the result.
|
|
237
266
|
return {result: data};
|
|
238
267
|
};
|
package/tests/htmlcs.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
htmlcs
|
|
3
|
+
This test implements the HTML CodeSniffer ruleset.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// FUNCTIONS
|
|
7
|
+
// Runs HTML CodeSniffer on the page.
|
|
8
|
+
exports.reporter = async page => {
|
|
9
|
+
await page.addScriptTag({
|
|
10
|
+
path: `${__dirname}/../htmlcs/HTMLCS.js`
|
|
11
|
+
});
|
|
12
|
+
let messageStrings = [];
|
|
13
|
+
for (const standard of ['WCAG2A', 'WCAG2AA', 'WCAG2AAA']) {
|
|
14
|
+
const nextIssues = await page.evaluate(standard => HTMLCS_RUNNER.run(standard), standard);
|
|
15
|
+
messageStrings.push(... nextIssues);
|
|
16
|
+
}
|
|
17
|
+
// Sort the issues by class and standard.
|
|
18
|
+
messageStrings.sort();
|
|
19
|
+
// Remove any duplicate issues.
|
|
20
|
+
messageStrings = [... new Set(messageStrings)];
|
|
21
|
+
// Initialize the result.
|
|
22
|
+
const result = {
|
|
23
|
+
Error: {},
|
|
24
|
+
Warning: {}
|
|
25
|
+
};
|
|
26
|
+
// For each issue:
|
|
27
|
+
messageStrings.forEach(string => {
|
|
28
|
+
const parts = string.split(/\|/g);
|
|
29
|
+
const partCount = parts.length;
|
|
30
|
+
if (partCount !== 6) {
|
|
31
|
+
console.log(`ERROR: Issue string ${string} has too few or too many parts`);
|
|
32
|
+
}
|
|
33
|
+
// If it is an error or a warning (not a notice):
|
|
34
|
+
else if (['Error', 'Warning'].includes(parts[0])) {
|
|
35
|
+
/*
|
|
36
|
+
Add the issue to an issueClass.issueCode.description array in the result.
|
|
37
|
+
This saves space, because, although some descriptions are issue-specific, such as
|
|
38
|
+
descriptions that state the contrast ratio of an element, most descriptions are
|
|
39
|
+
generic, so typically many issues share a description.
|
|
40
|
+
*/
|
|
41
|
+
if (! result[parts[0]][parts[1]]) {
|
|
42
|
+
result[parts[0]][parts[1]] = {};
|
|
43
|
+
}
|
|
44
|
+
if (! result[parts[0]][parts[1]][parts[4]]) {
|
|
45
|
+
result[parts[0]][parts[1]][parts[4]] = [];
|
|
46
|
+
}
|
|
47
|
+
result[parts[0]][parts[1]][parts[4]].push({
|
|
48
|
+
tagName: parts[2],
|
|
49
|
+
id: parts[3],
|
|
50
|
+
code: parts[5]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {result};
|
|
55
|
+
};
|
package/tests/ibm.js
CHANGED
|
@@ -99,7 +99,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
|
|
|
99
99
|
// If a test with existing content is to be performed:
|
|
100
100
|
const result = {};
|
|
101
101
|
if (! withNewContent) {
|
|
102
|
-
const timeLimit =
|
|
102
|
+
const timeLimit = 20;
|
|
103
103
|
const typeContent = await page.content();
|
|
104
104
|
result.content = await doTest(typeContent, withItems, timeLimit);
|
|
105
105
|
if (result.content.prevented) {
|