testaro 4.11.1 → 4.12.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/commands.js +1 -1
- package/package.json +1 -1
- package/tests/aatt.js +17 -2
- package/tests/alfa.js +14 -2
- package/tests/focAll.js +7 -12
- package/tests/focInd.js +6 -3
- package/tests/tabNav.js +43 -10
package/commands.js
CHANGED
package/package.json
CHANGED
package/tests/aatt.js
CHANGED
|
@@ -65,9 +65,12 @@ exports.reporter = async (page, waitLong, tryLimit = 4) => {
|
|
|
65
65
|
const issueArray = JSON.parse(reportJSON);
|
|
66
66
|
// Remove the notices from the array.
|
|
67
67
|
const nonNotices = issueArray.filter(issue => issue.type !== 'notice');
|
|
68
|
-
//
|
|
68
|
+
// For each non-notice issue:
|
|
69
|
+
let errors = 0;
|
|
70
|
+
let warnings = 0;
|
|
69
71
|
nonNotices.forEach(issue => {
|
|
70
72
|
if (issue.type) {
|
|
73
|
+
// Convert the technique property from a string to an array of strings.
|
|
71
74
|
const longTech = issue.techniques;
|
|
72
75
|
issue.techniques = longTech.replace(/a><a/g, 'a>%<a').split('%');
|
|
73
76
|
issue.id = issue
|
|
@@ -75,12 +78,24 @@ exports.reporter = async (page, waitLong, tryLimit = 4) => {
|
|
|
75
78
|
.map(technique => technique.replace(/^.+?>|<\/a>$/g, ''))
|
|
76
79
|
.sort()
|
|
77
80
|
.join('+');
|
|
81
|
+
// Add the issue to the totals.
|
|
82
|
+
if (issue.type === 'error') {
|
|
83
|
+
errors++;
|
|
84
|
+
}
|
|
85
|
+
else if (issue.type === 'warning') {
|
|
86
|
+
warnings++;
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
89
|
});
|
|
90
|
+
// Return the result.
|
|
80
91
|
return {
|
|
81
92
|
result: {
|
|
93
|
+
totals: {
|
|
94
|
+
errors,
|
|
95
|
+
warnings
|
|
96
|
+
},
|
|
82
97
|
report: nonNotices,
|
|
83
|
-
triesLeft
|
|
98
|
+
preventionCount: tryLimit - triesLeft - 1
|
|
84
99
|
}
|
|
85
100
|
};
|
|
86
101
|
}
|
package/tests/alfa.js
CHANGED
|
@@ -44,7 +44,13 @@ exports.reporter = async page => {
|
|
|
44
44
|
});
|
|
45
45
|
await rulePage.close();
|
|
46
46
|
}
|
|
47
|
-
const data =
|
|
47
|
+
const data = {
|
|
48
|
+
totals: {
|
|
49
|
+
failures: 0,
|
|
50
|
+
warnings: 0
|
|
51
|
+
},
|
|
52
|
+
items: []
|
|
53
|
+
};
|
|
48
54
|
await Scraper.with(async scraper => {
|
|
49
55
|
for (const input of await scraper.scrape(page.url())) {
|
|
50
56
|
const audit = Audit.of(input, alfaRules.default);
|
|
@@ -96,7 +102,13 @@ exports.reporter = async page => {
|
|
|
96
102
|
if (etcTags.length) {
|
|
97
103
|
outcomeData.etcTags = etcTags;
|
|
98
104
|
}
|
|
99
|
-
|
|
105
|
+
if (outcomeData.verdict === 'failed') {
|
|
106
|
+
data.totals.failures++;
|
|
107
|
+
}
|
|
108
|
+
else if (outcomeData.verdict === 'cantTell') {
|
|
109
|
+
data.totals.warnings++;
|
|
110
|
+
}
|
|
111
|
+
data.items.push(outcomeData);
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
114
|
});
|
package/tests/focAll.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
focAll
|
|
3
|
-
This test reports discrepancies between focusable and Tab-focused element counts.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
it
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from reaching all focusable elements. Either of these can complicate navigation for
|
|
11
|
-
users. It may disappoint the expectation that the content will remain stable as they
|
|
12
|
-
move with the Tab key, or the expectation that they can reach every focusable element
|
|
13
|
-
(or widget, such as one radio button or tab in each group) merely by pressing the Tab
|
|
14
|
-
key.
|
|
3
|
+
This test reports discrepancies between focusable and Tab-focused element counts. The test first
|
|
4
|
+
counts all the visible focusable (i.e. with tabIndex 0) elements (except counting each group of
|
|
5
|
+
radio buttons as only one focusable element). Then it repeatedly presses the Tab (or Option-Tab
|
|
6
|
+
in webkit) key until it has reached all the elements it can and counts those elements. If the
|
|
7
|
+
two counts differ, navigation can be made more difficult. The cause may be surprising changes in
|
|
8
|
+
content during navigation with the Tab key, or inability to reach every focusable element (or
|
|
9
|
+
widget, such as one radio button or tab in each group) merely by pressing the Tab key.
|
|
15
10
|
*/
|
|
16
11
|
exports.reporter = async page => {
|
|
17
12
|
// Identify the count of visible focusable elements.
|
package/tests/focInd.js
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
line thickness and non-transparent color. The test is based on the assumption that outlines are
|
|
6
6
|
the standard and thus most familiar focus indicator. Other focus indicators are assumed better
|
|
7
7
|
than none, but more likely to be misunderstood. For example, underlines may be mistaken for
|
|
8
|
-
selection indicators. Some pages delay the appearance of focus indicators.
|
|
9
|
-
|
|
8
|
+
selection indicators. Some pages delay the appearance of focus indicators. If a wait is
|
|
9
|
+
specified, the test checks every 100 ms for an outline until the allow wait time expires,
|
|
10
|
+
and once more after it expires. If no outline appears by then, the test checks for other focus
|
|
11
|
+
indicators. If an outline does not appear immediately but appears on a subsequent check, the test
|
|
12
|
+
reports the amount of the delay.
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
WARNING: This test fails to recognize outlines when run with firefox.
|
|
12
15
|
*/
|
|
13
16
|
exports.reporter = async (page, revealAll, allowedDelay, withItems) => {
|
|
14
17
|
// If required, make all elements visible.
|
package/tests/tabNav.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
tabNav
|
|
3
|
-
This test reports nonstandard keyboard navigation among tab elements in tab lists.
|
|
3
|
+
This test reports nonstandard keyboard navigation among tab elements in visible tab lists.
|
|
4
4
|
Standards are based on https://www.w3.org/TR/wai-aria-practices-1.1/#tabpanel.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -73,8 +73,8 @@ exports.reporter = async (page, withItems) => {
|
|
|
73
73
|
correct: []
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
// Identify an array of the tablists.
|
|
77
|
-
const tabLists = await page.$$('[role=tablist]');
|
|
76
|
+
// Identify an array of the visible tablists.
|
|
77
|
+
const tabLists = await page.$$('[role=tablist]:visible');
|
|
78
78
|
if (tabLists.length) {
|
|
79
79
|
// FUNCTION DEFINITIONS START
|
|
80
80
|
// Returns text associated with an element.
|
|
@@ -94,22 +94,34 @@ exports.reporter = async (page, withItems) => {
|
|
|
94
94
|
) => {
|
|
95
95
|
let pressed = true;
|
|
96
96
|
// Click the tab element, to make the focus on it effective.
|
|
97
|
-
await tabElement.click({
|
|
97
|
+
await tabElement.click({
|
|
98
|
+
timeout: 500
|
|
99
|
+
})
|
|
100
|
+
.catch(async error => {
|
|
101
|
+
await tabElement.click({
|
|
102
|
+
force: true
|
|
103
|
+
});
|
|
104
|
+
})
|
|
98
105
|
.catch(error => {
|
|
99
106
|
console.log(`ERROR: could not click tab element ${itemData.text} (${error.message})`);
|
|
100
|
-
|
|
107
|
+
pressed = false;
|
|
101
108
|
});
|
|
109
|
+
// Increment the counts of navigations and key navigations.
|
|
110
|
+
data.totals.navigations.all.total++;
|
|
111
|
+
data.totals.navigations.specific[keyProp].total++;
|
|
112
|
+
const {navigationErrors} = itemData;
|
|
113
|
+
// If the click succeeded:
|
|
102
114
|
if (pressed) {
|
|
103
115
|
// Refocus the tab element and press the specified key (page.keyboard.press may fail).
|
|
104
|
-
await tabElement.press(keyName
|
|
116
|
+
await tabElement.press(keyName, {
|
|
117
|
+
timeout: 1000
|
|
118
|
+
})
|
|
105
119
|
.catch(error => {
|
|
106
120
|
console.log(`ERROR: could not press ${keyName} (${error.message})`);
|
|
107
121
|
pressed = false;
|
|
108
122
|
});
|
|
123
|
+
// If the refocus and keypress succeeded:
|
|
109
124
|
if (pressed) {
|
|
110
|
-
// Increment the counts of navigations and key navigations.
|
|
111
|
-
data.totals.navigations.all.total++;
|
|
112
|
-
data.totals.navigations.specific[keyProp].total++;
|
|
113
125
|
// Identify which tab element is now focused, if any.
|
|
114
126
|
const focusIndex = await focusedTab(tabs);
|
|
115
127
|
// If the focus is correct:
|
|
@@ -128,15 +140,36 @@ exports.reporter = async (page, withItems) => {
|
|
|
128
140
|
// If itemization is required:
|
|
129
141
|
if (withItems) {
|
|
130
142
|
// Update the element report.
|
|
131
|
-
|
|
143
|
+
navigationErrors.push(keyName);
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
146
|
return elementIsCorrect;
|
|
135
147
|
}
|
|
148
|
+
// Otherwise, i.e. if the refocus or keypress failed:
|
|
136
149
|
else {
|
|
150
|
+
// Increment the counts of incorrect navigations and incorrect key navigations.
|
|
151
|
+
data.totals.navigations.all.incorrect++;
|
|
152
|
+
data.totals.navigations.specific[keyProp].incorrect++;
|
|
153
|
+
// If itemization is required and a focus failure has not yet been reported:
|
|
154
|
+
if (withItems && ! navigationErrors.includes('focus')) {
|
|
155
|
+
// Update the element report.
|
|
156
|
+
navigationErrors.push('focus');
|
|
157
|
+
}
|
|
137
158
|
return false;
|
|
138
159
|
}
|
|
139
160
|
}
|
|
161
|
+
// Otherwise, i.e. if the click failed:
|
|
162
|
+
else {
|
|
163
|
+
// Increment the counts of incorrect navigations and incorrect key navigations.
|
|
164
|
+
data.totals.navigations.all.incorrect++;
|
|
165
|
+
data.totals.navigations.specific[keyProp].incorrect++;
|
|
166
|
+
// If itemization is required and a click failure has not yet been reported:
|
|
167
|
+
if (withItems && ! navigationErrors.includes('click')) {
|
|
168
|
+
// Update the element report.
|
|
169
|
+
navigationErrors.push('click');
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
140
173
|
};
|
|
141
174
|
// Returns the index to which an arrow key should move the focus.
|
|
142
175
|
const arrowTarget = (startIndex, tabCount, orientation, direction) => {
|