testaro 36.0.2 → 36.1.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/package.json +1 -1
- package/tests/ed11y.js +24 -4
package/package.json
CHANGED
package/tests/ed11y.js
CHANGED
|
@@ -41,6 +41,13 @@ exports.reporter = async (page, options) => {
|
|
|
41
41
|
// Get the test script.
|
|
42
42
|
const script = await fs.readFile(`${__dirname}/../ed11y/editoria11y.min.js`, 'utf8');
|
|
43
43
|
const rawResultJSON = await page.evaluate(args => new Promise(async resolve => {
|
|
44
|
+
// Impose a timeout on obtaining a result.
|
|
45
|
+
const timer = setTimeout(() => {
|
|
46
|
+
resolve(JSON.stringify({
|
|
47
|
+
prevented: true,
|
|
48
|
+
error: 'ed11y timed out'
|
|
49
|
+
}));
|
|
50
|
+
}, 20000);
|
|
44
51
|
const {scriptNonce, script, rulesToTest} = args;
|
|
45
52
|
// When the script is executed:
|
|
46
53
|
document.addEventListener('ed11yResults', () => {
|
|
@@ -111,11 +118,15 @@ exports.reporter = async (page, options) => {
|
|
|
111
118
|
// Return the result.
|
|
112
119
|
try {
|
|
113
120
|
const resultJSON = JSON.stringify(resultObj);
|
|
121
|
+
clearTimeout(timer);
|
|
114
122
|
resolve(resultJSON);
|
|
115
123
|
}
|
|
116
124
|
catch(error) {
|
|
117
|
-
|
|
118
|
-
resolve(
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
resolve(JSON.stringify({
|
|
127
|
+
prevented: true,
|
|
128
|
+
error: `Result object not stringified (${error.message})`
|
|
129
|
+
}));
|
|
119
130
|
}
|
|
120
131
|
});
|
|
121
132
|
// Add the test script to the page.
|
|
@@ -133,12 +144,21 @@ exports.reporter = async (page, options) => {
|
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
146
|
catch(error) {
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
resolve(JSON.stringify({
|
|
148
|
+
prevented: true,
|
|
149
|
+
error: error.message
|
|
150
|
+
}));
|
|
138
151
|
};
|
|
139
152
|
}), {scriptNonce, script, rulesToTest: act.rules});
|
|
140
153
|
const result = JSON.parse(rawResultJSON);
|
|
141
154
|
let data = {};
|
|
155
|
+
if (result.prevented) {
|
|
156
|
+
data.success = false;
|
|
157
|
+
data.prevented = true;
|
|
158
|
+
data.error = result.error;
|
|
159
|
+
delete result.prevented;
|
|
160
|
+
delete result.error;
|
|
161
|
+
}
|
|
142
162
|
// Return the act report.
|
|
143
163
|
return {
|
|
144
164
|
data,
|