testaro 78.0.4 → 78.0.6
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 +1 -1
- package/procs/nu.js +12 -0
- package/tests/htmlcs.js +11 -0
- package/tests/nuVal.js +8 -1
- package/tests/nuVnu.js +8 -1
package/package.json
CHANGED
package/procs/nu.js
CHANGED
|
@@ -93,3 +93,15 @@ exports.curate = async (data, nuData, rules) => {
|
|
|
93
93
|
// Return the result.
|
|
94
94
|
return result;
|
|
95
95
|
};
|
|
96
|
+
// Maximum length of an extract excerpt included in the what property of a standard instance.
|
|
97
|
+
const excerptMax = 400;
|
|
98
|
+
// Gets an excerpt of the extract of a message for inclusion in the what property of a standard instance, if the element catalog cannot report the extract.
|
|
99
|
+
exports.getExtractExcerpt = extract => {
|
|
100
|
+
// If there is no extract, or the extract contains a data-xpath attribute identifying an element:
|
|
101
|
+
if (! extract || / data-xpath="/.test(extract)) {
|
|
102
|
+
// Report that no excerpt is needed, because the catalog reports the element.
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
// Return the extract (e.g. the erroneous text of a CSS: Parse Error message), truncated if necessary.
|
|
106
|
+
return extract.length > excerptMax ? `${extract.slice(0, excerptMax)} …` : extract;
|
|
107
|
+
};
|
package/tests/htmlcs.js
CHANGED
|
@@ -62,8 +62,19 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
62
62
|
const script = document.createElement('script');
|
|
63
63
|
script.nonce = scriptNonce;
|
|
64
64
|
script.textContent = scriptText;
|
|
65
|
+
// HTMLCS.js is a UMD bundle. If the page exposes an AMD loader (define.amd, e.g. Wix or RequireJS) or leaked CommonJS globals (exports, module), the UMD wrapper registers HTMLCS as a module and never attaches HTMLCS_RUNNER to window, so the run() call below throws and the tool is reported prevented. Hide those loader globals for the duration of the synchronous script execution, so the wrapper falls through to its browser-global branch.
|
|
66
|
+
const umdDefine = window.define;
|
|
67
|
+
const umdExports = window.exports;
|
|
68
|
+
const umdModule = window.module;
|
|
69
|
+
window.define = undefined;
|
|
70
|
+
window.exports = undefined;
|
|
71
|
+
window.module = undefined;
|
|
65
72
|
// Add the HTMLCS script to the page.
|
|
66
73
|
document.head.insertAdjacentElement('beforeend', script);
|
|
74
|
+
// Restore the loader globals.
|
|
75
|
+
window.define = umdDefine;
|
|
76
|
+
window.exports = umdExports;
|
|
77
|
+
window.module = umdModule;
|
|
67
78
|
// If only some rules are to be employed:
|
|
68
79
|
if (rules && Array.isArray(rules) && rules.length) {
|
|
69
80
|
// Redefine WCAG 2 AAA as including only them.
|
package/tests/nuVal.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
// IMPORTS
|
|
20
20
|
|
|
21
|
-
const {curate, getContent} = require('../procs/nu');
|
|
21
|
+
const {curate, getContent, getExtractExcerpt} = require('../procs/nu');
|
|
22
22
|
const {getAttributeXPath, getXPathCatalogIndex} = require('../procs/xPath');
|
|
23
23
|
|
|
24
24
|
// FUNCTIONS
|
|
@@ -113,6 +113,13 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
113
113
|
// Add the catalog index to the standard instance.
|
|
114
114
|
standardInstance.catalogIndex = getXPathCatalogIndex(report, xPath);
|
|
115
115
|
}
|
|
116
|
+
// Get an excerpt of the extract, if the extract identifies no element.
|
|
117
|
+
const extractExcerpt = getExtractExcerpt(message.extract);
|
|
118
|
+
// If one was obtained (e.g. the erroneous CSS of a CSS: Parse Error message):
|
|
119
|
+
if (extractExcerpt) {
|
|
120
|
+
// Add it to the description of the violation, so the extract is not lost.
|
|
121
|
+
standardInstance.what = `${message.message} Extract: ${extractExcerpt}`;
|
|
122
|
+
}
|
|
116
123
|
// Add the standard instance to the standard result.
|
|
117
124
|
standardResult.instances.push(standardInstance);
|
|
118
125
|
})
|
package/tests/nuVnu.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// IMPORTS
|
|
18
18
|
|
|
19
|
-
const {curate, getContent} = require('../procs/nu');
|
|
19
|
+
const {curate, getContent, getExtractExcerpt} = require('../procs/nu');
|
|
20
20
|
const {getAttributeXPath, getXPathCatalogIndex} = require('../procs/xPath');
|
|
21
21
|
const fs = require('fs/promises');
|
|
22
22
|
const path = require('path');
|
|
@@ -101,6 +101,13 @@ exports.reporter = async (page, report, actIndex) => {
|
|
|
101
101
|
// Add the catalog index to the standard instance.
|
|
102
102
|
standardInstance.catalogIndex = getXPathCatalogIndex(report, xPath);
|
|
103
103
|
}
|
|
104
|
+
// Get an excerpt of the extract, if the extract identifies no element.
|
|
105
|
+
const extractExcerpt = getExtractExcerpt(message.extract);
|
|
106
|
+
// If one was obtained (e.g. the erroneous CSS of a CSS: Parse Error message):
|
|
107
|
+
if (extractExcerpt) {
|
|
108
|
+
// Add it to the description of the violation, so the extract is not lost.
|
|
109
|
+
standardInstance.what = `${message.message} Extract: ${extractExcerpt}`;
|
|
110
|
+
}
|
|
104
111
|
// Add the standard instance to the standard result.
|
|
105
112
|
standardResult.instances.push(standardInstance);
|
|
106
113
|
});
|