testaro 5.2.1 → 5.4.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/.eslintrc.json +41 -0
- package/README.md +52 -2
- package/create.js +83 -12
- package/high.js +2 -6
- package/htmlcs/.eslintrc.json +67 -0
- package/htmlcs/HTMLCS.js +3792 -3557
- package/package.json +1 -1
- package/run.js +7 -2
- package/runHost.js +36 -0
- package/tests/hover.js +4 -1
- package/tests/htmlcs.js +4 -4
- package/tests/ibm.js +2 -2
- package/tests/role.js +77 -18
- package/tests/tabNav.js +3 -1
- package/htmlcs/HTMLCS.css +0 -1069
- package/htmlcs/Images/HTMLCS-tools.png +0 -0
- package/htmlcs/Images/bgTexture1.gif +0 -0
- package/htmlcs/Images/summaryLoader-error.gif +0 -0
- package/htmlcs/Images/summaryLoader-notice.gif +0 -0
- package/htmlcs/Images/summaryLoader-warning.gif +0 -0
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -633,6 +633,12 @@ const wait = ms => {
|
|
|
633
633
|
};
|
|
634
634
|
// Recursively performs the acts in a report.
|
|
635
635
|
const doActs = async (report, actIndex, page) => {
|
|
636
|
+
process.on('message', message => {
|
|
637
|
+
if (message === 'interrupt') {
|
|
638
|
+
console.log('ERROR: Terminal interrupted doActs');
|
|
639
|
+
process.exit();
|
|
640
|
+
}
|
|
641
|
+
});
|
|
636
642
|
const {acts} = report;
|
|
637
643
|
// If any more commands are to be performed:
|
|
638
644
|
if (actIndex > -1 && actIndex < acts.length) {
|
|
@@ -1310,8 +1316,7 @@ const doScript = async (report) => {
|
|
|
1310
1316
|
const injectLaunches = acts => {
|
|
1311
1317
|
let injectMore = true;
|
|
1312
1318
|
while (injectMore) {
|
|
1313
|
-
const injectIndex = acts.findIndex(
|
|
1314
|
-
(act, index) =>
|
|
1319
|
+
const injectIndex = acts.findIndex((act, index) =>
|
|
1315
1320
|
index < acts.length - 1
|
|
1316
1321
|
&& act.type === 'test'
|
|
1317
1322
|
&& acts[index + 1].type === 'test'
|
package/runHost.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
runHost.js
|
|
3
|
+
Runs a host job and writes a report file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ########## IMPORTS
|
|
7
|
+
|
|
8
|
+
// Module to keep secrets.
|
|
9
|
+
require('dotenv').config();
|
|
10
|
+
// Module to read and write files.
|
|
11
|
+
const fs = require('fs/promises');
|
|
12
|
+
const {handleRequest} = require('./run');
|
|
13
|
+
|
|
14
|
+
// ########## CONSTANTS
|
|
15
|
+
const reportDir = process.env.REPORTDIR;
|
|
16
|
+
|
|
17
|
+
// ########## FUNCTIONS
|
|
18
|
+
|
|
19
|
+
// Runs one script and writes a report file.
|
|
20
|
+
const runHost = async (id, scriptJSON, hostJSON) => {
|
|
21
|
+
const report = {
|
|
22
|
+
id,
|
|
23
|
+
host: JSON.parse(hostJSON),
|
|
24
|
+
log: [],
|
|
25
|
+
script: JSON.parse(scriptJSON),
|
|
26
|
+
acts: []
|
|
27
|
+
};
|
|
28
|
+
await handleRequest(report);
|
|
29
|
+
const reportJSON = JSON.stringify(report, null, 2);
|
|
30
|
+
await fs.writeFile(`${reportDir}/${id}.json`, reportJSON);
|
|
31
|
+
process.disconnect();
|
|
32
|
+
process.exit();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// ########## OPERATION
|
|
36
|
+
runHost(... process.argv.slice(2));
|
package/tests/hover.js
CHANGED
|
@@ -158,7 +158,10 @@ const find = async (withItems, page, region, sample, popRatio) => {
|
|
|
158
158
|
position: {
|
|
159
159
|
x: 0,
|
|
160
160
|
y: 0
|
|
161
|
-
}
|
|
161
|
+
},
|
|
162
|
+
timeout: 500,
|
|
163
|
+
force: true,
|
|
164
|
+
noWaitAfter: true
|
|
162
165
|
});
|
|
163
166
|
// Wait for any delayed and/or slowed hover reaction.
|
|
164
167
|
await page.waitForTimeout(200);
|
package/tests/htmlcs.js
CHANGED
|
@@ -21,14 +21,14 @@ exports.reporter = async page => {
|
|
|
21
21
|
const nextIssues = await page.evaluate(standard => {
|
|
22
22
|
let issues = null;
|
|
23
23
|
try {
|
|
24
|
-
issues = HTMLCS_RUNNER.run(standard);
|
|
24
|
+
issues = window['HTMLCS_RUNNER'].run(standard);
|
|
25
25
|
}
|
|
26
26
|
catch(error) {
|
|
27
27
|
console.log(`ERROR executing HTMLCS_RUNNER on ${document.URL} (${error.message})`);
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
return issues;
|
|
30
30
|
}, standard);
|
|
31
|
-
if (nextIssues) {
|
|
31
|
+
if (nextIssues && nextIssues.every(issue => typeof issue === 'string')) {
|
|
32
32
|
messageStrings.push(... nextIssues);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
@@ -36,7 +36,7 @@ exports.reporter = async page => {
|
|
|
36
36
|
result.error = 'ERROR executing HTMLCS_RUNNER in the page';
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
if (! result.prevented) {
|
|
41
41
|
// Sort the issues by class and standard.
|
|
42
42
|
messageStrings.sort();
|
package/tests/ibm.js
CHANGED
|
@@ -104,7 +104,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
|
|
|
104
104
|
result.content = await doTest(typeContent, withItems, timeLimit);
|
|
105
105
|
if (result.content.prevented) {
|
|
106
106
|
result.prevented = true;
|
|
107
|
-
console.log(
|
|
107
|
+
console.log(`ERROR: Getting ibm test report from page timed out at ${timeLimit} seconds`);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
// If a test with new content is to be performed:
|
|
@@ -114,7 +114,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
|
|
|
114
114
|
result.url = await doTest(typeContent, withItems, timeLimit);
|
|
115
115
|
if (result.url.prevented) {
|
|
116
116
|
result.prevented = true;
|
|
117
|
-
console.log(
|
|
117
|
+
console.log(`ERROR: Getting ibm test report from URL timed out at ${timeLimit} seconds`);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
await close();
|
package/tests/role.js
CHANGED
|
@@ -120,6 +120,58 @@ exports.reporter = async page => await page.$eval('body', body => {
|
|
|
120
120
|
'treegrid',
|
|
121
121
|
'treeitem',
|
|
122
122
|
]);
|
|
123
|
+
// Implicit roles
|
|
124
|
+
const implicitRoles = {
|
|
125
|
+
article: 'article',
|
|
126
|
+
aside: 'complementary',
|
|
127
|
+
button: 'button',
|
|
128
|
+
datalist: 'listbox',
|
|
129
|
+
dd: 'definition',
|
|
130
|
+
details: 'group',
|
|
131
|
+
dfn: 'term',
|
|
132
|
+
dialog: 'dialog',
|
|
133
|
+
dt: 'term',
|
|
134
|
+
fieldset: 'group',
|
|
135
|
+
figure: 'figure',
|
|
136
|
+
h1: 'heading',
|
|
137
|
+
h2: 'heading',
|
|
138
|
+
h3: 'heading',
|
|
139
|
+
h4: 'heading',
|
|
140
|
+
h5: 'heading',
|
|
141
|
+
h6: 'heading',
|
|
142
|
+
hr: 'separator',
|
|
143
|
+
html: 'document',
|
|
144
|
+
li: 'listitem',
|
|
145
|
+
main: 'main',
|
|
146
|
+
math: 'math',
|
|
147
|
+
menu: 'list',
|
|
148
|
+
nav: 'navigation',
|
|
149
|
+
ol: 'list',
|
|
150
|
+
output: 'status',
|
|
151
|
+
progress: 'progressbar',
|
|
152
|
+
summary: 'button',
|
|
153
|
+
SVG: 'graphics-document',
|
|
154
|
+
table: 'table',
|
|
155
|
+
tbody: 'rowgroup',
|
|
156
|
+
textarea: 'textbox',
|
|
157
|
+
tfoot: 'rowgroup',
|
|
158
|
+
thead: 'rowgroup',
|
|
159
|
+
tr: 'row',
|
|
160
|
+
ul: 'list'
|
|
161
|
+
};
|
|
162
|
+
// FUNCTIONS
|
|
163
|
+
const dataInit = (data, tagName, role) => {
|
|
164
|
+
if (! data.tagNames[tagName]) {
|
|
165
|
+
data.tagNames[tagName] = {};
|
|
166
|
+
}
|
|
167
|
+
if (! data.tagNames[tagName][role]) {
|
|
168
|
+
data.tagNames[tagName][role] = {
|
|
169
|
+
bad: 0,
|
|
170
|
+
redundant: 0
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
// OPERATION
|
|
123
175
|
// Remove the deprecated roles from the non-abstract roles.
|
|
124
176
|
goodRoles.forEach(role => {
|
|
125
177
|
if (badRoles.has(role)) {
|
|
@@ -128,34 +180,41 @@ exports.reporter = async page => await page.$eval('body', body => {
|
|
|
128
180
|
});
|
|
129
181
|
// Identify all elements with role attributes.
|
|
130
182
|
const roleElements = Array.from(body.querySelectorAll('[role]'));
|
|
131
|
-
// Identify those with roles that are either deprecated or invalid.
|
|
132
|
-
const bads = roleElements.filter(element => {
|
|
133
|
-
const role = element.getAttribute('role');
|
|
134
|
-
return badRoles.has(role) || ! goodRoles.has(role);
|
|
135
|
-
});
|
|
136
183
|
// Initialize the result.
|
|
137
184
|
const data = {
|
|
138
185
|
roleElements: roleElements.length,
|
|
139
|
-
badRoleElements:
|
|
186
|
+
badRoleElements: 0,
|
|
187
|
+
redundantRoleElements: 0,
|
|
140
188
|
tagNames: {}
|
|
141
189
|
};
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
// Identify its facts.
|
|
145
|
-
const tagName = element.tagName;
|
|
190
|
+
// Identify the elements with redundant roles and bad roles.
|
|
191
|
+
roleElements.forEach(element => {
|
|
146
192
|
const role = element.getAttribute('role');
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
193
|
+
const tagName = element.tagName;
|
|
194
|
+
// If the role is not absolutely valid:
|
|
195
|
+
if (! goodRoles.has(role)) {
|
|
196
|
+
// If it is bad or redundant:
|
|
197
|
+
if (badRoles.has(role)) {
|
|
198
|
+
dataInit(data, tagName, role);
|
|
199
|
+
// Add the facts to the result.
|
|
200
|
+
if (role === implicitRoles[tagName.toLowerCase()]) {
|
|
201
|
+
data.redundantRoleElements++;
|
|
202
|
+
data.tagNames[tagName][role].redundant++;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
data.badRoleElements++;
|
|
206
|
+
data.tagNames[tagName][role].bad++;
|
|
207
|
+
}
|
|
151
208
|
}
|
|
209
|
+
// Otherwise, i.e. if it is absolutely invalid:
|
|
152
210
|
else {
|
|
153
|
-
|
|
211
|
+
// Add the facts to the result.
|
|
212
|
+
data.badRoleElements++;
|
|
213
|
+
dataInit(data, tagName, role);
|
|
214
|
+
data.tagNames[tagName][role].bad++;
|
|
154
215
|
}
|
|
155
216
|
}
|
|
156
|
-
else {
|
|
157
|
-
data.tagNames[tagName] = {[role]: 1};
|
|
158
|
-
}
|
|
159
217
|
});
|
|
218
|
+
// Return the result.
|
|
160
219
|
return {result: data};
|
|
161
220
|
});
|
package/tests/tabNav.js
CHANGED
|
@@ -103,7 +103,9 @@ exports.reporter = async (page, withItems) => {
|
|
|
103
103
|
});
|
|
104
104
|
})
|
|
105
105
|
.catch(error => {
|
|
106
|
-
console.log(
|
|
106
|
+
console.log(
|
|
107
|
+
`ERROR clicking tab element ${itemData.text} (${error.message.replace(/\n.+/s, '')})`
|
|
108
|
+
);
|
|
107
109
|
pressed = false;
|
|
108
110
|
});
|
|
109
111
|
// Increment the counts of navigations and key navigations.
|