testaro 5.1.1 → 5.2.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/htmlcs/HTMLCS.js +1 -3
- package/package.json +1 -1
- package/run.js +33 -11
- package/tests/hover.js +1 -1
- package/tests/htmlcs.js +54 -36
package/htmlcs/HTMLCS.js
CHANGED
|
@@ -6321,10 +6321,8 @@
|
|
|
6321
6321
|
self.output(messages[i]);
|
|
6322
6322
|
msgCount[messages[i].type]++;
|
|
6323
6323
|
}
|
|
6324
|
-
console.log("done");
|
|
6325
6324
|
}, function () {
|
|
6326
6325
|
console.log("Something in HTML_CodeSniffer failed to parse. Cannot run.");
|
|
6327
|
-
console.log("done");
|
|
6328
6326
|
}, "en");
|
|
6329
6327
|
return Array.from(messageStrings);
|
|
6330
6328
|
};
|
|
@@ -7968,4 +7966,4 @@
|
|
|
7968
7966
|
};
|
|
7969
7967
|
}(); // Expose globals.
|
|
7970
7968
|
return _global;
|
|
7971
|
-
}));
|
|
7969
|
+
}));
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -36,7 +36,7 @@ const tests = {
|
|
|
36
36
|
focAll: 'focusable and Tab-focused elements',
|
|
37
37
|
focInd: 'focus indicators',
|
|
38
38
|
focOp: 'focusability and operability',
|
|
39
|
-
hover: 'hover-caused content
|
|
39
|
+
hover: 'hover-caused content changes',
|
|
40
40
|
htmlcs: 'HTML CodeSniffer WCAG 2.1 AA ruleset',
|
|
41
41
|
ibm: 'IBM Accessibility Checker',
|
|
42
42
|
labClash: 'labeling inconsistencies',
|
|
@@ -257,6 +257,7 @@ const closeBrowsers = async () => {
|
|
|
257
257
|
await browser.close();
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
+
browsers = [];
|
|
260
261
|
};
|
|
261
262
|
// Launches a browser.
|
|
262
263
|
const launch = async typeName => {
|
|
@@ -1305,11 +1306,12 @@ const doScript = async (report) => {
|
|
|
1305
1306
|
value: ((new Date()).toISOString().slice(0, 19))
|
|
1306
1307
|
});
|
|
1307
1308
|
};
|
|
1308
|
-
// Injects url acts into a report where necessary to undo DOM changes.
|
|
1309
|
-
const
|
|
1309
|
+
// Injects launch and url acts into a report where necessary to undo DOM changes.
|
|
1310
|
+
const injectLaunches = acts => {
|
|
1310
1311
|
let injectMore = true;
|
|
1311
1312
|
while (injectMore) {
|
|
1312
|
-
const injectIndex = acts.findIndex(
|
|
1313
|
+
const injectIndex = acts.findIndex(
|
|
1314
|
+
(act, index) =>
|
|
1313
1315
|
index < acts.length - 1
|
|
1314
1316
|
&& act.type === 'test'
|
|
1315
1317
|
&& acts[index + 1].type === 'test'
|
|
@@ -1319,6 +1321,14 @@ const injectURLActs = acts => {
|
|
|
1319
1321
|
injectMore = false;
|
|
1320
1322
|
}
|
|
1321
1323
|
else {
|
|
1324
|
+
const lastBrowserType = acts.reduce((browserType, act, index) => {
|
|
1325
|
+
if (act.type === 'launch' && index < injectIndex) {
|
|
1326
|
+
return act.which;
|
|
1327
|
+
}
|
|
1328
|
+
else {
|
|
1329
|
+
return browserType;
|
|
1330
|
+
}
|
|
1331
|
+
}, '');
|
|
1322
1332
|
const lastURL = acts.reduce((url, act, index) => {
|
|
1323
1333
|
if (act.type === 'url' && index < injectIndex) {
|
|
1324
1334
|
return act.which;
|
|
@@ -1327,11 +1337,20 @@ const injectURLActs = acts => {
|
|
|
1327
1337
|
return url;
|
|
1328
1338
|
}
|
|
1329
1339
|
}, '');
|
|
1330
|
-
acts.splice(
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1340
|
+
acts.splice(
|
|
1341
|
+
injectIndex + 1,
|
|
1342
|
+
0,
|
|
1343
|
+
{
|
|
1344
|
+
type: 'launch',
|
|
1345
|
+
which: lastBrowserType,
|
|
1346
|
+
what: `${lastBrowserType} browser`
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
type: 'url',
|
|
1350
|
+
which: lastURL,
|
|
1351
|
+
what: 'URL'
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1335
1354
|
}
|
|
1336
1355
|
}
|
|
1337
1356
|
};
|
|
@@ -1354,9 +1373,12 @@ exports.handleRequest = async report => {
|
|
|
1354
1373
|
report.timeStamp = report.id.replace(/-.+/, '');
|
|
1355
1374
|
// Add the script commands to the report as its initial acts.
|
|
1356
1375
|
report.acts = JSON.parse(JSON.stringify(report.script.commands));
|
|
1357
|
-
|
|
1376
|
+
/*
|
|
1377
|
+
Inject launch and url acts where necessary to undo DOM changes, if specified.
|
|
1378
|
+
Injection of url acts alone does not guarantee test independence.
|
|
1379
|
+
*/
|
|
1358
1380
|
if (urlInject === 'yes') {
|
|
1359
|
-
|
|
1381
|
+
injectLaunches(report.acts);
|
|
1360
1382
|
}
|
|
1361
1383
|
// Perform the acts, asynchronously adding to the log and report.
|
|
1362
1384
|
await doScript(report);
|
package/tests/hover.js
CHANGED
|
@@ -198,7 +198,7 @@ const find = async (withItems, page, region, sample, popRatio) => {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
catch (error) {
|
|
201
|
-
console.log(`ERROR hovering (${error.message})`);
|
|
201
|
+
console.log(`ERROR hovering (${error.message.replace(/\n.+/s, '')})`);
|
|
202
202
|
data.totals.unhoverables++;
|
|
203
203
|
if (withItems) {
|
|
204
204
|
const id = await firstTrigger.getAttribute('id');
|
package/tests/htmlcs.js
CHANGED
|
@@ -18,45 +18,63 @@ exports.reporter = async page => {
|
|
|
18
18
|
if (! result.prevented) {
|
|
19
19
|
let messageStrings = [];
|
|
20
20
|
for (const standard of ['WCAG2AA']) {
|
|
21
|
-
const nextIssues = await page.evaluate(standard =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
const nextIssues = await page.evaluate(standard => {
|
|
22
|
+
let issues = null;
|
|
23
|
+
try {
|
|
24
|
+
issues = HTMLCS_RUNNER.run(standard);
|
|
25
|
+
}
|
|
26
|
+
catch(error) {
|
|
27
|
+
console.log(`ERROR executing HTMLCS_RUNNER on ${document.URL} (${error.message})`);
|
|
28
|
+
};
|
|
29
|
+
return issues;
|
|
30
|
+
}, standard);
|
|
31
|
+
if (nextIssues) {
|
|
32
|
+
messageStrings.push(... nextIssues);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
result.prevented = true;
|
|
36
|
+
result.error = 'ERROR executing HTMLCS_RUNNER in the page';
|
|
37
|
+
break;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
};
|
|
40
|
+
if (! result.prevented) {
|
|
41
|
+
// Sort the issues by class and standard.
|
|
42
|
+
messageStrings.sort();
|
|
43
|
+
// Remove any duplicate issues.
|
|
44
|
+
messageStrings = [... new Set(messageStrings)];
|
|
45
|
+
// Initialize the result.
|
|
46
|
+
result.Error = {};
|
|
47
|
+
result.Warning = {};
|
|
48
|
+
// For each issue:
|
|
49
|
+
messageStrings.forEach(string => {
|
|
50
|
+
const parts = string.split(/\|/, 6);
|
|
51
|
+
const partCount = parts.length;
|
|
52
|
+
if (partCount < 6) {
|
|
53
|
+
console.log(`ERROR: Issue string ${string} has too few parts`);
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
// If it is an error or a warning (not a notice):
|
|
56
|
+
else if (['Error', 'Warning'].includes(parts[0])) {
|
|
57
|
+
/*
|
|
58
|
+
Add the issue to an issueClass.issueCode.description array in the result.
|
|
59
|
+
This saves space, because, although some descriptions are issue-specific, such as
|
|
60
|
+
descriptions that state the contrast ratio of an element, most descriptions are
|
|
61
|
+
generic, so typically many issues share a description.
|
|
62
|
+
*/
|
|
63
|
+
const issueCode = parts[1].replace(/^WCAG2|\.Principle\d\.Guideline[\d_]+/g, '');
|
|
64
|
+
if (! result[parts[0]][issueCode]) {
|
|
65
|
+
result[parts[0]][issueCode] = {};
|
|
66
|
+
}
|
|
67
|
+
if (! result[parts[0]][issueCode][parts[4]]) {
|
|
68
|
+
result[parts[0]][issueCode][parts[4]] = [];
|
|
69
|
+
}
|
|
70
|
+
result[parts[0]][issueCode][parts[4]].push({
|
|
71
|
+
tagName: parts[2],
|
|
72
|
+
id: parts[3],
|
|
73
|
+
code: parts[5]
|
|
74
|
+
});
|
|
52
75
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
id: parts[3],
|
|
56
|
-
code: parts[5]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
60
78
|
}
|
|
61
79
|
return {result};
|
|
62
80
|
};
|