testaro 18.11.0 → 18.12.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
CHANGED
package/testaro/targetSize.js
CHANGED
|
@@ -6,89 +6,44 @@
|
|
|
6
6
|
|
|
7
7
|
// ########## IMPORTS
|
|
8
8
|
|
|
9
|
-
// Module to
|
|
10
|
-
const {
|
|
9
|
+
// Module to perform common operations.
|
|
10
|
+
const {init, report} = require('../procs/testaro');
|
|
11
11
|
// Module to classify links.
|
|
12
12
|
const {isInlineLink} = require('../procs/isInlineLink');
|
|
13
13
|
|
|
14
14
|
// ########## FUNCTIONS
|
|
15
15
|
|
|
16
|
+
// Runs the test and returns the result.
|
|
16
17
|
exports.reporter = async (page, withItems) => {
|
|
17
|
-
// Initialize the result.
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (const loc of linkLocsAll) {
|
|
28
|
-
if (! await isInlineLink(loc)) {
|
|
29
|
-
locs.push(loc);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// For each of them:
|
|
33
|
-
for (const loc of locs) {
|
|
34
|
-
// Get whether it violates the rule, and, if so, how.
|
|
35
|
-
const howBad = await loc.evaluate(element => {
|
|
36
|
-
const width = element.offsetWidth;
|
|
37
|
-
const height = element.offsetHeight;
|
|
38
|
-
if (width < 44 || height < 44) {
|
|
39
|
-
return {
|
|
40
|
-
width,
|
|
41
|
-
height
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
18
|
+
// Initialize the locators and result.
|
|
19
|
+
const all = await init(page, 'a, button, input');
|
|
20
|
+
// For each locator:
|
|
21
|
+
for (const loc of all.allLocs) {
|
|
22
|
+
// Get the size of its element, if small.
|
|
23
|
+
const sizeData = await loc.evaluate(el => {
|
|
24
|
+
const width = el.offsetWidth;
|
|
25
|
+
const height = el.offsetHeight;
|
|
26
|
+
const tagName = el.tagName;
|
|
27
|
+
return width < 44 || height < 44 ? {tagName, width, height} : null;
|
|
47
28
|
});
|
|
48
|
-
// If
|
|
49
|
-
if (
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
what:
|
|
60
|
-
`Interactive element is only ${howBad.width} pixels wide and ${howBad.height} pixels high`,
|
|
61
|
-
ordinalSeverity: 0,
|
|
62
|
-
tagName: elData.tagName,
|
|
63
|
-
id: elData.id,
|
|
64
|
-
location: elData.location,
|
|
65
|
-
excerpt: elData.excerpt
|
|
66
|
-
});
|
|
29
|
+
// If it is small:
|
|
30
|
+
if (sizeData) {
|
|
31
|
+
// Get whether it violates the rule.
|
|
32
|
+
let isBad = true;
|
|
33
|
+
if (sizeData.tagName === 'A') {
|
|
34
|
+
isBad = await isInlineLink(loc);
|
|
35
|
+
}
|
|
36
|
+
// If it does:
|
|
37
|
+
if (isBad) {
|
|
38
|
+
// Add the locator to the array of violators.
|
|
39
|
+
all.locs.push([loc, `${sizeData.width} wide by ${sizeData.height} high`]);
|
|
67
40
|
}
|
|
68
41
|
}
|
|
69
42
|
}
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ordinalSeverity: 0,
|
|
77
|
-
count: totals[0],
|
|
78
|
-
tagName: '',
|
|
79
|
-
id: '',
|
|
80
|
-
location: {
|
|
81
|
-
doc: '',
|
|
82
|
-
type: '',
|
|
83
|
-
spec: ''
|
|
84
|
-
},
|
|
85
|
-
excerpt: ''
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// Return the result.
|
|
89
|
-
return {
|
|
90
|
-
data,
|
|
91
|
-
totals,
|
|
92
|
-
standardInstances
|
|
93
|
-
};
|
|
43
|
+
// Populate and return the result.
|
|
44
|
+
const whats = [
|
|
45
|
+
'Interactive element pixel size (__param__) is less than 44 by 44',
|
|
46
|
+
'Interactive elements are smaller than 44 pixels wide and high'
|
|
47
|
+
];
|
|
48
|
+
return await report(withItems, all, 'targetSize', whats, 1);
|
|
94
49
|
};
|
package/testaro/titledEl.js
CHANGED
|
@@ -6,61 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
// ########## IMPORTS
|
|
8
8
|
|
|
9
|
-
// Module to
|
|
10
|
-
const {
|
|
9
|
+
// Module to perform common operations.
|
|
10
|
+
const {init, report} = require('../procs/testaro');
|
|
11
11
|
|
|
12
12
|
// ########## FUNCTIONS
|
|
13
13
|
|
|
14
|
+
// Runs the test and returns the result.
|
|
14
15
|
exports.reporter = async (page, withItems) => {
|
|
15
|
-
// Initialize the result.
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// If itemization is required:
|
|
24
|
-
if (withItems) {
|
|
25
|
-
// Get data on the element.
|
|
26
|
-
const elData = await getLocatorData(loc);
|
|
27
|
-
const rawTitle = await loc.getAttribute('title');
|
|
28
|
-
const title = rawTitle.replace(/\s+/g, ' ').slice(0, 50);
|
|
29
|
-
// Add an instance to the result.
|
|
30
|
-
standardInstances.push({
|
|
31
|
-
ruleID: 'titledEl',
|
|
32
|
-
what: `Ineligible element has a title (${title})`,
|
|
33
|
-
ordinalSeverity: 2,
|
|
34
|
-
tagName: elData.tagName,
|
|
35
|
-
id: elData.id,
|
|
36
|
-
location: elData.location,
|
|
37
|
-
excerpt: elData.excerpt
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Define the totals.
|
|
42
|
-
const totals = [0, 0, locs.length, 0];
|
|
43
|
-
// If itemization is not required:
|
|
44
|
-
if (! withItems) {
|
|
45
|
-
// Add a summary instance to the result.
|
|
46
|
-
standardInstances.push({
|
|
47
|
-
ruleID: 'titledEl',
|
|
48
|
-
what: 'Ineligible elements have title attributes',
|
|
49
|
-
ordinalSeverity: 2,
|
|
50
|
-
count: totals[2],
|
|
51
|
-
tagName: '',
|
|
52
|
-
id: '',
|
|
53
|
-
location: {
|
|
54
|
-
doc: '',
|
|
55
|
-
type: '',
|
|
56
|
-
spec: ''
|
|
57
|
-
},
|
|
58
|
-
excerpt: ''
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
data,
|
|
63
|
-
totals,
|
|
64
|
-
standardInstances
|
|
65
|
-
};
|
|
16
|
+
// Initialize the locators and result.
|
|
17
|
+
const all = await init(page, '[title]:not(input, button, textarea, select, iframe):visible');
|
|
18
|
+
all.locs = all.allLocs;
|
|
19
|
+
// Populate and return the result.
|
|
20
|
+
const whats = [
|
|
21
|
+
'Ineligible element has a title attribute', 'Ineligible elements have title attributes'
|
|
22
|
+
];
|
|
23
|
+
return await report(withItems, all, 'titledEl', whats, 2);
|
|
66
24
|
};
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
[
|
|
24
24
|
"standardResult.totals.0",
|
|
25
25
|
"=",
|
|
26
|
-
|
|
26
|
+
0
|
|
27
27
|
],
|
|
28
28
|
[
|
|
29
29
|
"standardResult.totals.1",
|
|
30
30
|
"=",
|
|
31
|
-
|
|
31
|
+
4
|
|
32
32
|
],
|
|
33
33
|
[
|
|
34
34
|
"standardResult.instances.0.ruleID",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
[
|
|
39
39
|
"standardResult.instances.0.what",
|
|
40
40
|
"i",
|
|
41
|
-
"is
|
|
41
|
+
"is less than"
|
|
42
42
|
],
|
|
43
43
|
[
|
|
44
44
|
"standardResult.instances.0.ordinalSeverity",
|
|
45
45
|
"=",
|
|
46
|
-
|
|
46
|
+
1
|
|
47
47
|
],
|
|
48
48
|
[
|
|
49
49
|
"standardResult.instances.0.tagName",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
[
|
|
79
79
|
"standardResult.instances.2.what",
|
|
80
80
|
"i",
|
|
81
|
-
"is
|
|
81
|
+
"is less than"
|
|
82
82
|
],
|
|
83
83
|
[
|
|
84
84
|
"standardResult.instances.2.tagName",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
],
|
|
103
103
|
[
|
|
104
104
|
"standardResult.instances.3.excerpt",
|
|
105
|
-
"
|
|
106
|
-
"Wikimedia"
|
|
105
|
+
"=",
|
|
106
|
+
"Wikimedia Foundation"
|
|
107
107
|
]
|
|
108
108
|
],
|
|
109
109
|
"rules": [
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"stopOnFail": true,
|
|
119
119
|
"expect": [
|
|
120
120
|
[
|
|
121
|
-
"standardResult.totals.
|
|
121
|
+
"standardResult.totals.1",
|
|
122
122
|
"=",
|
|
123
123
|
4
|
|
124
124
|
],
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
[
|
|
141
141
|
"standardResult.instances.0.ordinalSeverity",
|
|
142
142
|
"=",
|
|
143
|
-
|
|
143
|
+
1
|
|
144
144
|
],
|
|
145
145
|
[
|
|
146
146
|
"standardResult.instances.0.count",
|
|
@@ -43,6 +43,15 @@
|
|
|
43
43
|
<ul>
|
|
44
44
|
<li style="min-height: 3rem"><a class="deep" href="https://w3c.org">World Wide Web Consortium</a></li>
|
|
45
45
|
<li><a href="https://wikimedia.org">Wikimedia Foundation</a></li>
|
|
46
|
+
</ul>
|
|
47
|
+
<ul>
|
|
48
|
+
<li style="min-height: 3rem">W3C: <a class="deep" href="https://w3c.org">World Wide Web Consortium</a></li>
|
|
49
|
+
<li>WF: <a href="https://wikimedia.org">Wikimedia Foundation</a></li>
|
|
50
|
+
</ul>
|
|
51
|
+
<h2>Conclusion</h2>
|
|
52
|
+
<p>2 buttons are too small.</p>
|
|
53
|
+
<p>1 input is too small.</p>
|
|
54
|
+
<p>1 link is too small.</p>
|
|
46
55
|
</main>
|
|
47
56
|
</body>
|
|
48
57
|
</html>
|