testaro 5.8.0 → 5.9.2
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/README.md +13 -5
- package/commands.js +9 -0
- package/package.json +1 -1
- package/run.js +4 -39
- package/tests/elements.js +130 -0
- package/tests/title.js +8 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Federated accessibility test automation
|
|
|
6
6
|
|
|
7
7
|
Testaro is a collection of collections of web accessibility tests.
|
|
8
8
|
|
|
9
|
-
The purpose of Testaro is to provide programmatic access to
|
|
9
|
+
The purpose of Testaro is to provide programmatic access to 1230 accessibility tests defined in several test packages and in Testaro itself.
|
|
10
10
|
|
|
11
11
|
## System requirements
|
|
12
12
|
|
|
@@ -40,8 +40,8 @@ As of this version, the counts of tests in the packages referenced above were:
|
|
|
40
40
|
- WAVE: 110
|
|
41
41
|
- Nu Html Checker: 147
|
|
42
42
|
- subtotal: 612
|
|
43
|
-
- Testaro tests:
|
|
44
|
-
- grand total:
|
|
43
|
+
- Testaro tests: 24
|
|
44
|
+
- grand total: 1230
|
|
45
45
|
|
|
46
46
|
## Code organization
|
|
47
47
|
|
|
@@ -234,6 +234,14 @@ This command causes Testaro to alter the `display` and `visibility` style proper
|
|
|
234
234
|
|
|
235
235
|
The possible commands of type `test` are enumerated in the `tests` object defined in the `index.js` file.
|
|
236
236
|
|
|
237
|
+
A test performs operations and reports results. The results may or may not directly indicate that a page passes or fails requirements. Typically, accessibility tests report successes and failures. But a test in Testaro is defined less restrictively, so it can report any results. As one example, the Testaro `elements` test reports facts about certain elements on a page, without asserting that those facts are successes or failures.
|
|
238
|
+
|
|
239
|
+
The term “test” has two meanings for Testaro:
|
|
240
|
+
- A command is a test (test command) if its `type` property has the value `test`.
|
|
241
|
+
- A package, such as Continuum, performs multiple tests (packaged tests).
|
|
242
|
+
|
|
243
|
+
Thus, if a command of type `test` runs Continuum, Continuum performs multiple tests and reports their results.
|
|
244
|
+
|
|
237
245
|
###### Examples
|
|
238
246
|
|
|
239
247
|
An example of a **packaged test** is:
|
|
@@ -266,7 +274,7 @@ In this case, Testaro runs the `motion` test with the specified parameters.
|
|
|
266
274
|
|
|
267
275
|
###### Tenon
|
|
268
276
|
|
|
269
|
-
|
|
277
|
+
Most packaged tests require only one command, but the `tenon` test requires two commands:
|
|
270
278
|
- A command of type `tenonRequest`.
|
|
271
279
|
- A command of type `test` with `tenon` as the value of `which`.
|
|
272
280
|
|
|
@@ -342,7 +350,7 @@ The changes in `htmlcs/HTMLCS.js` are:
|
|
|
342
350
|
|
|
343
351
|
###### BBC Accessibility Standards Checker
|
|
344
352
|
|
|
345
|
-
The BBC Accessibility Standards Checker has obsolete dependencies with security vulnerabilities. Therefore, it is not used as a dependency of Testaro. Instead, 6 of its tests are reimplemented, in some
|
|
353
|
+
The BBC Accessibility Standards Checker has obsolete dependencies with security vulnerabilities. Therefore, it is not used as a dependency of Testaro. Instead, 6 of its tests are reimplemented, in some cases with revisions, as Testaro tests. They are drawn from the 18 automated tests of the Checker. The other 12 tests were found too duplicative of other tests to justify reimplementation.
|
|
346
354
|
|
|
347
355
|
##### Branching
|
|
348
356
|
|
package/commands.js
CHANGED
|
@@ -150,6 +150,15 @@ exports.commands = {
|
|
|
150
150
|
rules: [true, 'array', 'areStrings', 'rule names, or empty if all']
|
|
151
151
|
}
|
|
152
152
|
],
|
|
153
|
+
elements: [
|
|
154
|
+
'Perform an elements test',
|
|
155
|
+
{
|
|
156
|
+
detailLevel: [true, 'number', '', '0 = counts, 1 = selves, 2 = also sibling nodes'],
|
|
157
|
+
tagName: [false, 'string', '', 'tag name of elements'],
|
|
158
|
+
onlyVisible: [false, 'boolean', '', 'whether to exclude invisible elements'],
|
|
159
|
+
attribute: [false, 'string', 'hasLength', 'required attribute or attribute=value']
|
|
160
|
+
}
|
|
161
|
+
],
|
|
153
162
|
embAc: [
|
|
154
163
|
'Perform an embAc test',
|
|
155
164
|
{
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -34,6 +34,7 @@ const tests = {
|
|
|
34
34
|
bulk: 'count of visible elements',
|
|
35
35
|
continuum: 'Level Access Continuum, community edition',
|
|
36
36
|
docType: 'document without a doctype property',
|
|
37
|
+
elements: 'data on specified elements',
|
|
37
38
|
embAc: 'active elements embedded in links or buttons',
|
|
38
39
|
focAll: 'focusable and Tab-focused elements',
|
|
39
40
|
focInd: 'focus indicators',
|
|
@@ -55,6 +56,7 @@ const tests = {
|
|
|
55
56
|
styleDiff: 'style inconsistencies',
|
|
56
57
|
tabNav: 'keyboard navigation between tab elements',
|
|
57
58
|
tenon: 'Tenon',
|
|
59
|
+
title: 'page title',
|
|
58
60
|
titledEl: 'title attributes on inappropriate elements',
|
|
59
61
|
wave: 'WAVE',
|
|
60
62
|
zIndex: 'z indexes'
|
|
@@ -70,7 +72,7 @@ const browserTypeNames = {
|
|
|
70
72
|
'firefox': 'Firefox'
|
|
71
73
|
};
|
|
72
74
|
// Items that may be waited for.
|
|
73
|
-
const waitables = ['url', 'title', 'body'
|
|
75
|
+
const waitables = ['url', 'title', 'body'];
|
|
74
76
|
// Tenon data.
|
|
75
77
|
const tenonData = {
|
|
76
78
|
accessToken: '',
|
|
@@ -81,6 +83,7 @@ const errorWords = [
|
|
|
81
83
|
'content security policy',
|
|
82
84
|
'deprecated',
|
|
83
85
|
'error',
|
|
86
|
+
'expected',
|
|
84
87
|
'failed',
|
|
85
88
|
'invalid',
|
|
86
89
|
'missing',
|
|
@@ -812,44 +815,6 @@ const doActs = async (report, actIndex, page) => {
|
|
|
812
815
|
waitError(page, act, error, 'body');
|
|
813
816
|
}
|
|
814
817
|
}
|
|
815
|
-
else if (what === 'mailLink') {
|
|
816
|
-
try {
|
|
817
|
-
const addressJSHandle = await page.waitForFunction(
|
|
818
|
-
text => {
|
|
819
|
-
const mailLinks = document
|
|
820
|
-
&& document.body
|
|
821
|
-
&& document.body.querySelectorAll('a[href^="mailto:"]');
|
|
822
|
-
if (mailLinks && mailLinks.length) {
|
|
823
|
-
const textLC = text.toLowerCase();
|
|
824
|
-
const a11yLink = Array
|
|
825
|
-
.from(mailLinks)
|
|
826
|
-
.find(link => link.textContent.toLowerCase().includes(textLC));
|
|
827
|
-
if (a11yLink) {
|
|
828
|
-
return a11yLink.href.replace(/^mailto:/, '');
|
|
829
|
-
}
|
|
830
|
-
else {
|
|
831
|
-
return false;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
else {
|
|
835
|
-
return false;
|
|
836
|
-
}
|
|
837
|
-
},
|
|
838
|
-
which,
|
|
839
|
-
{
|
|
840
|
-
polling: 1000,
|
|
841
|
-
timeout: 5000
|
|
842
|
-
}
|
|
843
|
-
);
|
|
844
|
-
const address = await addressJSHandle.jsonValue();
|
|
845
|
-
result.found = true;
|
|
846
|
-
result.address = address;
|
|
847
|
-
}
|
|
848
|
-
catch(error) {
|
|
849
|
-
actIndex = -2;
|
|
850
|
-
waitError(page, act, error, 'mailLink');
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
818
|
}
|
|
854
819
|
// Otherwise, if the act is a wait for a state:
|
|
855
820
|
else if (act.type === 'state') {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
elements
|
|
3
|
+
This test reports data about specified elements.
|
|
4
|
+
*/
|
|
5
|
+
exports.reporter = async (page, detailLevel, tagName, onlyVisible, attribute) => {
|
|
6
|
+
// Determine a selector of the specified elements.
|
|
7
|
+
let selector = tagName || '*';
|
|
8
|
+
if (attribute) {
|
|
9
|
+
selector += `[${attribute}]`;
|
|
10
|
+
}
|
|
11
|
+
if (onlyVisible) {
|
|
12
|
+
selector += ':visible';
|
|
13
|
+
}
|
|
14
|
+
// Get the data on the elements.
|
|
15
|
+
const data = await page.$$eval(selector, (elements, detailLevel) => {
|
|
16
|
+
// FUNCTION DEFINITIONS START
|
|
17
|
+
// Compacts a string.
|
|
18
|
+
const compact = string => string.replace(/\s+/g, ' ').trim();
|
|
19
|
+
// Gets data on the sibling nodes of an element.
|
|
20
|
+
const getSibInfo = (node, nodeType, text) => {
|
|
21
|
+
const sibInfo = {
|
|
22
|
+
type: nodeType
|
|
23
|
+
};
|
|
24
|
+
if (nodeType === 1) {
|
|
25
|
+
sibInfo.tagName = node.tagName;
|
|
26
|
+
}
|
|
27
|
+
else if (nodeType === 3) {
|
|
28
|
+
sibInfo.text = compact(text);
|
|
29
|
+
}
|
|
30
|
+
return sibInfo;
|
|
31
|
+
};
|
|
32
|
+
// FUNCTION DEFINITIONS END
|
|
33
|
+
// Initialize the data with the count of the specified elements.
|
|
34
|
+
const data = {
|
|
35
|
+
total: elements.length
|
|
36
|
+
};
|
|
37
|
+
// If no itemization is required:
|
|
38
|
+
if (detailLevel === 0) {
|
|
39
|
+
// Return the element count.
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
// Otherwise, i.e. if itemization is required:
|
|
43
|
+
else {
|
|
44
|
+
// Initialize the item data.
|
|
45
|
+
data.items = [];
|
|
46
|
+
// For each specified element:
|
|
47
|
+
elements.forEach(element => {
|
|
48
|
+
// Initialize data on it.
|
|
49
|
+
const parent = element.parentElement;
|
|
50
|
+
const datum = {
|
|
51
|
+
tagName: element.tagName,
|
|
52
|
+
parentTagName: parent ? parent.tagName : '',
|
|
53
|
+
code: compact(element.outerHTML),
|
|
54
|
+
attributes: [],
|
|
55
|
+
textContent: compact(element.textContent)
|
|
56
|
+
};
|
|
57
|
+
// For each of its attributes:
|
|
58
|
+
for (const attribute of element.attributes) {
|
|
59
|
+
// Add data on the attribute to the element data.
|
|
60
|
+
const {name, value} = attribute;
|
|
61
|
+
datum.attributes.push({
|
|
62
|
+
name,
|
|
63
|
+
value
|
|
64
|
+
});
|
|
65
|
+
// If the element has reference labels:
|
|
66
|
+
if (name === 'aria-labelledby') {
|
|
67
|
+
// Add their texts to the element data.
|
|
68
|
+
const labelerIDs = value.split(/\s+/);
|
|
69
|
+
const labelers = [];
|
|
70
|
+
labelerIDs.forEach(id => {
|
|
71
|
+
const labeler = document.getElementById(id);
|
|
72
|
+
if (labeler) {
|
|
73
|
+
labelers.push(compact(labeler.textContent));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (labelers.length) {
|
|
77
|
+
datum.labelers = labelers;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// If the element has text content:
|
|
82
|
+
const {labels, textContent} = element;
|
|
83
|
+
const compactContent = compact(textContent);
|
|
84
|
+
if (compactContent) {
|
|
85
|
+
// Add it to the element data.
|
|
86
|
+
datum.textContent = compactContent;
|
|
87
|
+
}
|
|
88
|
+
// If the element has labels:
|
|
89
|
+
if (labels && labels.length) {
|
|
90
|
+
// Add their texts to the element data.
|
|
91
|
+
datum.labels = Array.from(labels).map(label => compact(label.textContent));
|
|
92
|
+
}
|
|
93
|
+
// If sibling itemization is required:
|
|
94
|
+
if (detailLevel === 2) {
|
|
95
|
+
// Add the sibling data to the element data.
|
|
96
|
+
datum.siblings = {
|
|
97
|
+
before: [],
|
|
98
|
+
after: []
|
|
99
|
+
};
|
|
100
|
+
let more = element;
|
|
101
|
+
while (more) {
|
|
102
|
+
more = more.previousSibling;
|
|
103
|
+
if (more) {
|
|
104
|
+
const {nodeType, nodeValue} = more;
|
|
105
|
+
if (! (nodeType === 3 && nodeValue === '')) {
|
|
106
|
+
const sibInfo = getSibInfo(more, nodeType, nodeValue);
|
|
107
|
+
datum.siblings.before.unshift(sibInfo);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
more = element;
|
|
112
|
+
while (more) {
|
|
113
|
+
more = more.nextSibling;
|
|
114
|
+
if (more) {
|
|
115
|
+
const {nodeType, textContent} = more;
|
|
116
|
+
if (! (nodeType === 3 && textContent === '')) {
|
|
117
|
+
const sibInfo = getSibInfo(more, nodeType, compact(textContent));
|
|
118
|
+
datum.siblings.after.push(sibInfo);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
data.items.push(datum);
|
|
124
|
+
});
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
}, detailLevel);
|
|
128
|
+
// Return the result.
|
|
129
|
+
return {result: data};
|
|
130
|
+
};
|