testaro 10.2.0 → 10.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/actSpecs.js +11 -0
- package/package.json +1 -1
- package/tests/htmlcs.js +15 -5
package/actSpecs.js
CHANGED
|
@@ -229,6 +229,17 @@ exports.actSpecs = {
|
|
|
229
229
|
withItems: [true, 'boolean', '', 'itemize']
|
|
230
230
|
}
|
|
231
231
|
],
|
|
232
|
+
htmlcs: [
|
|
233
|
+
'Perform an htmlcs test',
|
|
234
|
+
{
|
|
235
|
+
rules: [
|
|
236
|
+
false,
|
|
237
|
+
'array',
|
|
238
|
+
'areStrings',
|
|
239
|
+
'rule names (e.g., Principle1.Guideline1_4.1_4_9), if not all'
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
232
243
|
ibm: [
|
|
233
244
|
'Perform an IBM Equal Access test',
|
|
234
245
|
{
|
package/package.json
CHANGED
package/tests/htmlcs.js
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
// FUNCTIONS
|
|
7
7
|
// Runs HTML CodeSniffer on the page.
|
|
8
|
-
exports.reporter = async page => {
|
|
8
|
+
exports.reporter = async (page, rules) => {
|
|
9
9
|
const result = {};
|
|
10
|
+
// Add the HTMLCS script to the page.
|
|
10
11
|
await page.addScriptTag({
|
|
11
12
|
path: `${__dirname}/../htmlcs/HTMLCS.js`
|
|
12
13
|
})
|
|
@@ -17,17 +18,26 @@ exports.reporter = async page => {
|
|
|
17
18
|
});
|
|
18
19
|
if (! result.prevented) {
|
|
19
20
|
let messageStrings = [];
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Define the rules to be employed as those of WCAG 2 level AAA.
|
|
22
|
+
for (const standard of ['WCAG2AAA']) {
|
|
23
|
+
const nextIssues = await page.evaluate(args => {
|
|
24
|
+
const standard = args[0];
|
|
25
|
+
const rules = args[1];
|
|
26
|
+
// If only some rules are to be employed:
|
|
27
|
+
if (rules && Array.isArray(rules) && rules.length) {
|
|
28
|
+
// Redefine WCAG 2 AAA as including only them.
|
|
29
|
+
window.HTMLCS_WCAG2AAA.sniffs = rules;
|
|
30
|
+
}
|
|
31
|
+
// Run the tests.
|
|
22
32
|
let issues = null;
|
|
23
33
|
try {
|
|
24
|
-
issues = window
|
|
34
|
+
issues = window.HTMLCS_RUNNER.run(standard);
|
|
25
35
|
}
|
|
26
36
|
catch(error) {
|
|
27
37
|
console.log(`ERROR executing HTMLCS_RUNNER on ${document.URL} (${error.message})`);
|
|
28
38
|
}
|
|
29
39
|
return issues;
|
|
30
|
-
}, standard);
|
|
40
|
+
}, [standard, rules]);
|
|
31
41
|
if (nextIssues && nextIssues.every(issue => typeof issue === 'string')) {
|
|
32
42
|
messageStrings.push(... nextIssues);
|
|
33
43
|
}
|