testilo 3.9.12 → 3.9.14
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/procs/score/spA11yMessage.js +55 -49
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
This proc computes a score that is intended to represent how accessibly a web page offers
|
|
11
11
|
a user an opportunity to report an accessibility issue about that page. Scores can range
|
|
12
|
-
from 0 to 16.
|
|
12
|
+
from perfect 0 to 16.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// CONSTANTS
|
|
@@ -22,69 +22,75 @@ const scoreProcID = 'a11ymessage';
|
|
|
22
22
|
// Scores the contact links of a type.
|
|
23
23
|
const contactScorer = (result, score, type) => {
|
|
24
24
|
const links = result.items;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
) {
|
|
31
|
-
score[type] += 2;
|
|
25
|
+
if (links.some(
|
|
26
|
+
link => link.textContent.toLowerCase().includes('accessibility')
|
|
27
|
+
)) {
|
|
28
|
+
score[type] -= 3;
|
|
32
29
|
}
|
|
33
|
-
else if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
) {
|
|
38
|
-
score[type] += 1;
|
|
30
|
+
else if (links.some(
|
|
31
|
+
link => link.parentTextContent.toLowerCase().includes('accessibility')
|
|
32
|
+
)) {
|
|
33
|
+
score[type] -= 2;
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
36
|
// Scores a report.
|
|
42
37
|
exports.scorer = async report => {
|
|
43
38
|
const {acts} = report;
|
|
39
|
+
report.scoreProcID = scoreProcID;
|
|
44
40
|
report.score = {
|
|
45
|
-
page:
|
|
46
|
-
a11yLink:
|
|
47
|
-
title:
|
|
48
|
-
heading:
|
|
49
|
-
mailLink:
|
|
50
|
-
telLink:
|
|
51
|
-
total: 0
|
|
41
|
+
page: 3,
|
|
42
|
+
a11yLink: 4,
|
|
43
|
+
title: 3,
|
|
44
|
+
heading: 3,
|
|
45
|
+
mailLink: 3,
|
|
46
|
+
telLink: 3
|
|
52
47
|
};
|
|
53
48
|
const {score} = report;
|
|
54
49
|
if (Array.isArray(acts)) {
|
|
55
50
|
// Act 1: page loads.
|
|
56
51
|
if (acts[1].result.startsWith('http')) {
|
|
57
|
-
score.page
|
|
52
|
+
score.page -= 2;
|
|
53
|
+
if (acts[1].endTime - acts[1].startTime < 2500) {
|
|
54
|
+
score.page -= 1;
|
|
55
|
+
}
|
|
58
56
|
// Act 2: accessibility link exists and loads promptly.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
score.
|
|
57
|
+
const {result} = acts[2];
|
|
58
|
+
// If a link with text content including accessibility was found:
|
|
59
|
+
if (result.found) {
|
|
60
|
+
score.a11yLink -= 2;
|
|
61
|
+
// If it was clickable and the resulting load finished:
|
|
62
|
+
if (result.success) {
|
|
63
|
+
score.a11yLink -= 1;
|
|
64
|
+
// If the navigation and load took less than 1.5 seconds:
|
|
65
|
+
if (acts[2].endTime - acts[2].startTime < 1500) {
|
|
66
|
+
score.a11yLink -= 1;
|
|
67
|
+
}
|
|
68
|
+
// Act 3: next page has an accessibility title.
|
|
69
|
+
let {result} = acts[3];
|
|
70
|
+
if (result && result.success) {
|
|
71
|
+
score.title -= 1;
|
|
72
|
+
if (result.title.toLowerCase().includes('accessibility')) {
|
|
73
|
+
score.title -= 2;
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
// Act 4: page has 1 h1 heading, and it is about accessibility.
|
|
77
|
+
result = acts[4].result;
|
|
78
|
+
if (result && result.total === 1) {
|
|
79
|
+
score.heading -= 1;
|
|
80
|
+
if (result.items[0].textContent.toLowerCase().includes('accessibility')) {
|
|
81
|
+
score.heading -= 2;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Act 5: page has an accessibility email link.
|
|
85
|
+
result = acts[5].result;
|
|
86
|
+
if (result.total) {
|
|
87
|
+
contactScorer(result, score, 'mailLink');
|
|
88
|
+
}
|
|
89
|
+
// Act 6: page has accessibility telephone link.
|
|
90
|
+
result = acts[6].result;
|
|
91
|
+
if (result.total) {
|
|
92
|
+
contactScorer(result, score, 'telLink');
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
}
|