testaro 4.12.0 → 4.13.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/aceconfig.js +1 -1
- package/high.js +1 -1
- package/package.json +1 -1
- package/run.js +36 -15
- package/tests/focInd.js +2 -1
- package/tests/hover.js +5 -7
- package/tests/ibm.js +8 -6
package/aceconfig.js
CHANGED
package/high.js
CHANGED
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
index.js
|
|
3
3
|
testaro main script.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
// ########## IMPORTS
|
|
7
|
+
|
|
6
8
|
// Module to keep secrets.
|
|
7
9
|
require('dotenv').config();
|
|
8
10
|
// Requirements for commands.
|
|
9
11
|
const {commands} = require('./commands');
|
|
12
|
+
|
|
10
13
|
// ########## CONSTANTS
|
|
14
|
+
|
|
11
15
|
// Set DEBUG environment variable to 'true' to add debugging features.
|
|
12
16
|
const debug = process.env.DEBUG === 'true';
|
|
13
17
|
// Set WAITS environment variable to a positive number to insert delays (in ms).
|
|
@@ -66,18 +70,21 @@ const tenonData = {
|
|
|
66
70
|
};
|
|
67
71
|
// Keywords in log messages indicating errors.
|
|
68
72
|
const errorWords = [
|
|
69
|
-
'
|
|
73
|
+
'content security policy',
|
|
74
|
+
'deprecated',
|
|
70
75
|
'error',
|
|
71
|
-
'
|
|
76
|
+
'failed',
|
|
77
|
+
'missing',
|
|
78
|
+
'but not used',
|
|
72
79
|
'refused',
|
|
73
|
-
'content security policy',
|
|
74
|
-
'unrecognized',
|
|
75
80
|
'requires',
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
81
|
+
'suspicious',
|
|
82
|
+
'unrecognized',
|
|
83
|
+
'warning'
|
|
79
84
|
];
|
|
85
|
+
|
|
80
86
|
// ########## VARIABLES
|
|
87
|
+
|
|
81
88
|
// Facts about the current session.
|
|
82
89
|
let logCount = 0;
|
|
83
90
|
let logSize = 0;
|
|
@@ -91,7 +98,11 @@ let actCount = 0;
|
|
|
91
98
|
let browserContext;
|
|
92
99
|
let browserTypeName;
|
|
93
100
|
let requestedURL = '';
|
|
101
|
+
// All browsers launched.
|
|
102
|
+
let browsers = [];
|
|
103
|
+
|
|
94
104
|
// ########## VALIDATORS
|
|
105
|
+
|
|
95
106
|
// Validates a browser type.
|
|
96
107
|
const isBrowserType = type => ['chromium', 'firefox', 'webkit'].includes(type);
|
|
97
108
|
// Validates a load state.
|
|
@@ -234,12 +245,17 @@ const isValidReport = async report => {
|
|
|
234
245
|
return false;
|
|
235
246
|
}
|
|
236
247
|
};
|
|
248
|
+
|
|
237
249
|
// ########## OTHER FUNCTIONS
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
250
|
+
|
|
251
|
+
// Closes all existing browsers.
|
|
252
|
+
const closeBrowsers = async () => {
|
|
253
|
+
for (const browserObj of browsers) {
|
|
254
|
+
const {browser, typeName} = browserObj;
|
|
255
|
+
if (browser) {
|
|
256
|
+
console.log(`Closing ${typeName} browser, version ${browser.version()}`);
|
|
257
|
+
await browser.close();
|
|
258
|
+
}
|
|
243
259
|
}
|
|
244
260
|
};
|
|
245
261
|
// Launches a browser.
|
|
@@ -248,7 +264,7 @@ const launch = async typeName => {
|
|
|
248
264
|
// If the specified browser type exists:
|
|
249
265
|
if (browserType) {
|
|
250
266
|
// Close any existing browser.
|
|
251
|
-
await
|
|
267
|
+
await closeBrowsers();
|
|
252
268
|
// Launch a browser of the specified type.
|
|
253
269
|
const browserOptions = {};
|
|
254
270
|
if (debug) {
|
|
@@ -258,6 +274,11 @@ const launch = async typeName => {
|
|
|
258
274
|
browserOptions.slowMo = waits;
|
|
259
275
|
}
|
|
260
276
|
const browser = await browserType.launch(browserOptions);
|
|
277
|
+
// Register it.
|
|
278
|
+
browsers.push({
|
|
279
|
+
browser,
|
|
280
|
+
typeName
|
|
281
|
+
});
|
|
261
282
|
// Create a new context (window) in it, taller if debugging is on.
|
|
262
283
|
const viewport = debug ? {
|
|
263
284
|
viewPort: {
|
|
@@ -1261,8 +1282,8 @@ const doScript = async (report) => {
|
|
|
1261
1282
|
report.testTimes = [];
|
|
1262
1283
|
// Perform the specified acts.
|
|
1263
1284
|
await doActs(report, 0, null);
|
|
1264
|
-
// Close
|
|
1265
|
-
await
|
|
1285
|
+
// Close all browsers.
|
|
1286
|
+
await closeBrowsers();
|
|
1266
1287
|
// Add the log statistics to the report.
|
|
1267
1288
|
report.logCount = logCount;
|
|
1268
1289
|
report.logSize = logSize;
|
package/tests/focInd.js
CHANGED
|
@@ -128,7 +128,7 @@ exports.reporter = async (page, revealAll, allowedDelay, withItems) => {
|
|
|
128
128
|
if (! hasOutline) {
|
|
129
129
|
// Returns whether a style property differs between focused and not focused.
|
|
130
130
|
const diff = prop => styleDec[prop] !== styleBlurred[prop];
|
|
131
|
-
// Determine whether the element has another
|
|
131
|
+
// Determine whether the element has another recognized focus indicator.
|
|
132
132
|
const hasDiffOutline = styleDec.outlineWidth !== '0px'
|
|
133
133
|
&& styleDec.outlineColor !== 'rgba(0, 0, 0, 0)'
|
|
134
134
|
&& (diff('outlineStyle') || diff('outlineWidth'));
|
|
@@ -138,6 +138,7 @@ exports.reporter = async (page, revealAll, allowedDelay, withItems) => {
|
|
|
138
138
|
const hasIndicator
|
|
139
139
|
= hasDiffOutline
|
|
140
140
|
|| hasDiffBorder
|
|
141
|
+
|| diff('box-shadow')
|
|
141
142
|
|| diff('fontSize')
|
|
142
143
|
|| diff('fontStyle')
|
|
143
144
|
|| diff('textDecorationLine')
|
package/tests/hover.js
CHANGED
|
@@ -28,6 +28,7 @@ const targetSelectors = ['a', 'button', 'input', '[role=menuitem]', 'span']
|
|
|
28
28
|
.join(', ');
|
|
29
29
|
// Initialize the result.
|
|
30
30
|
const data = {
|
|
31
|
+
populationSize: 0,
|
|
31
32
|
totals: {
|
|
32
33
|
triggers: 0,
|
|
33
34
|
madeVisible: 0,
|
|
@@ -83,13 +84,9 @@ const find = async (withItems, page, triggers) => {
|
|
|
83
84
|
if (['A', 'BUTTON'].includes(tagName)) {
|
|
84
85
|
const rootJSHandle = await page.evaluateHandle(
|
|
85
86
|
firstTrigger => {
|
|
86
|
-
const parent = firstTrigger.parentElement;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return firstTrigger;
|
|
92
|
-
}
|
|
87
|
+
const parent = firstTrigger.parentElement || firstTrigger;
|
|
88
|
+
const grandparent = parent.parentElement || parent;
|
|
89
|
+
return grandparent;
|
|
93
90
|
},
|
|
94
91
|
firstTrigger
|
|
95
92
|
);
|
|
@@ -226,6 +223,7 @@ exports.reporter = async (page, sampleSize = Infinity, withItems) => {
|
|
|
226
223
|
});
|
|
227
224
|
// If they number more than the sample size limit, sample them.
|
|
228
225
|
const triggerCount = triggers.length;
|
|
226
|
+
data.populationSize = triggerCount;
|
|
229
227
|
const triggerSample = triggerCount > sampleSize ? getSample(triggers, sampleSize) : triggers;
|
|
230
228
|
// Find and document the hover-triggered disclosures.
|
|
231
229
|
await find(withItems, page, triggerSample);
|
package/tests/ibm.js
CHANGED
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
*/
|
|
20
20
|
// Import required modules.
|
|
21
21
|
const fs = require('fs').promises;
|
|
22
|
-
const {getCompliance} = require('accessibility-checker');
|
|
22
|
+
const {getCompliance, close} = require('accessibility-checker');
|
|
23
23
|
// Runs the IBM test.
|
|
24
24
|
const run = async content => {
|
|
25
25
|
const nowLabel = (new Date()).toISOString().slice(0, 19);
|
|
26
26
|
// Return the result of a test.
|
|
27
27
|
const ibmReport = await getCompliance(content, nowLabel);
|
|
28
|
+
await close();
|
|
28
29
|
return ibmReport;
|
|
29
30
|
};
|
|
30
31
|
// Trims an IBM report.
|
|
@@ -67,11 +68,11 @@ const doTest = async (content, withItems, timeLimit) => {
|
|
|
67
68
|
resolve({});
|
|
68
69
|
}, 1000 * timeLimit);
|
|
69
70
|
});
|
|
70
|
-
// Conduct and
|
|
71
|
+
// Conduct the test and get a Promise of the report.
|
|
71
72
|
const ibmReport = run(content);
|
|
72
|
-
// Wait for
|
|
73
|
+
// Wait for completion or until the time limit expires.
|
|
73
74
|
const ibmReportIfFast = await Promise.race([ibmReport, wait]);
|
|
74
|
-
// Delete
|
|
75
|
+
// Delete existing report files.
|
|
75
76
|
try {
|
|
76
77
|
const reportNames = await fs.readdir('results');
|
|
77
78
|
for (const reportName of reportNames) {
|
|
@@ -88,7 +89,6 @@ const doTest = async (content, withItems, timeLimit) => {
|
|
|
88
89
|
return ibmTypeReport;
|
|
89
90
|
}
|
|
90
91
|
else {
|
|
91
|
-
console.log('ERROR: getting ibm test report took too long');
|
|
92
92
|
return {
|
|
93
93
|
prevented: true,
|
|
94
94
|
error: 'ERROR: getting ibm test report took too long'
|
|
@@ -105,6 +105,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
|
|
|
105
105
|
result.content = await doTest(typeContent, withItems, timeLimit);
|
|
106
106
|
if (result.content.prevented) {
|
|
107
107
|
result.prevented = true;
|
|
108
|
+
console.log('ERROR: Getting ibm test report from page took too long');
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
// If a test with new content is to be performed:
|
|
@@ -112,8 +113,9 @@ exports.reporter = async (page, withItems, withNewContent) => {
|
|
|
112
113
|
const timeLimit = 20;
|
|
113
114
|
const typeContent = page.url();
|
|
114
115
|
result.url = await doTest(typeContent, withItems, timeLimit);
|
|
115
|
-
if (result.
|
|
116
|
+
if (result.url.prevented) {
|
|
116
117
|
result.prevented = true;
|
|
118
|
+
console.log('ERROR: Getting ibm test report from URL took too long');
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
return {result};
|