testaro 14.9.8 → 14.10.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/testaro/linkExt.js +65 -0
- package/tests/testaro.js +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
linkExt
|
|
3
|
+
Related to Tenon rule 218, but stricter.
|
|
4
|
+
This test reports links with target attributes with _blank values
|
|
5
|
+
*/
|
|
6
|
+
exports.reporter = async (page, withItems) => {
|
|
7
|
+
// Identify the links with target=_blank attributes.
|
|
8
|
+
const badLinkData = await page.$$eval(
|
|
9
|
+
'a[target=_blank]',
|
|
10
|
+
badLinks => {
|
|
11
|
+
// FUNCTION DEFINITION START
|
|
12
|
+
// Returns a space-minimized copy of a string.
|
|
13
|
+
const compact = string => string.replace(/[\t\n]/g, '').replace(/\s{2,}/g, ' ').trim();
|
|
14
|
+
// FUNCTION DEFINITION END
|
|
15
|
+
return badLinks.map(link => ({
|
|
16
|
+
id: link.id,
|
|
17
|
+
text: compact(link.textContent)
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const data = {
|
|
22
|
+
total: badLinkData.length
|
|
23
|
+
};
|
|
24
|
+
const totals = [data.total, 0, 0, 0];
|
|
25
|
+
const standardInstances = [];
|
|
26
|
+
if (withItems) {
|
|
27
|
+
data.items = badLinkData;
|
|
28
|
+
data.items.forEach(item => {
|
|
29
|
+
standardInstances.push({
|
|
30
|
+
ruleID: 'linkExt',
|
|
31
|
+
what: 'Element a has a target=_blank attribute',
|
|
32
|
+
ordinalSeverity: 0,
|
|
33
|
+
tagName: 'A',
|
|
34
|
+
id: item.id,
|
|
35
|
+
location: {
|
|
36
|
+
doc: '',
|
|
37
|
+
type: '',
|
|
38
|
+
spec: ''
|
|
39
|
+
},
|
|
40
|
+
excerpt: item.text
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (data.total) {
|
|
45
|
+
standardInstances.push({
|
|
46
|
+
ruleID: 'linkExt',
|
|
47
|
+
what: 'Links have target=_blank attributes',
|
|
48
|
+
count: data.total,
|
|
49
|
+
ordinalSeverity: 0,
|
|
50
|
+
tagName: 'A',
|
|
51
|
+
id: '',
|
|
52
|
+
location: {
|
|
53
|
+
doc: '',
|
|
54
|
+
type: '',
|
|
55
|
+
spec: ''
|
|
56
|
+
},
|
|
57
|
+
excerpt: ''
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
data,
|
|
62
|
+
totals,
|
|
63
|
+
standardInstances
|
|
64
|
+
};
|
|
65
|
+
};
|
package/tests/testaro.js
CHANGED
|
@@ -19,6 +19,7 @@ const evalRules = {
|
|
|
19
19
|
focVis: 'links that are invisible when focused',
|
|
20
20
|
hover: 'hover-caused content changes',
|
|
21
21
|
labClash: 'labeling inconsistencies',
|
|
22
|
+
linkExt: 'links that automatically open new windows',
|
|
22
23
|
linkTo: 'links without destinations',
|
|
23
24
|
linkUl: 'missing underlines on inline links',
|
|
24
25
|
menuNav: 'nonstandard keyboard navigation between focusable menu items',
|