Skip to content

Commit a5559ab

Browse files
shunguoydependabot[bot]tombrunetnam-singh
authored
fixrule(meta_refresh_delay | meta_redirect_optional) Fix the rules to align with ACT V4 (#2168)
* Bump path-to-regexp and express in /rule-server (#2128) Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) to 0.1.12 and updates ancestor dependency [express](https://github.com/expressjs/express). These dependencies need to be updated together. Updates `path-to-regexp` from 0.1.10 to 0.1.12 - [Release notes](https://github.com/pillarjs/path-to-regexp/releases) - [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md) - [Commits](pillarjs/path-to-regexp@v0.1.10...v0.1.12) Updates `express` from 4.21.0 to 4.21.2 - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/4.21.2/History.md) - [Commits](expressjs/express@4.21.0...4.21.2) --- updated-dependencies: - dependency-name: path-to-regexp dependency-type: indirect - dependency-name: express dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * fix dark mode react portal pop-up (#2138) * fix(extension):Fix reset filter link #1877 (#2136) * reset filter fix * css fix --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * fix(extension): Don't show full data:text/html content on generated HTML report page (#2140) * truncating url * remove unused import * Adjust tooltip location --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * chore(extension): carbon package update and use new carbon combobutton #1842 (#2137) * carbon package update and use new carbon combobutton * alignment fix --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> * Update the rules and test cases * update the baselines --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Brunet <thbrunet@us.ibm.com> Co-authored-by: Namrata Singh <nam.singh@ibm.com>
1 parent 981a467 commit a5559ab

37 files changed

+938
-32
lines changed

accessibility-checker-engine/src/v4/rules/meta_redirect_optional.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
limitations under the License.
1212
*****************************************************************************/
1313

14-
import { FragmentUtil } from "../../v2/checker/accessibility/util/fragment";
15-
import { CommonUtil } from "../util/CommonUtil";
1614
import { Rule, RuleResult, RuleFail, RuleContext, RulePass, RuleContextHierarchy } from "../api/IRule";
1715
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
16+
import { CacheUtil } from "../util/CacheUtil";
1817

1918
export const meta_redirect_optional: Rule = {
2019
id: "meta_redirect_optional",
@@ -49,39 +48,51 @@ export const meta_redirect_optional: Rule = {
4948
"toolkitLevel": eToolkitLevel.LEVEL_THREE
5049
}],
5150
// Removed ACT bisz58 AAA
52-
act: [{
51+
/**act: [{
5352
"bc659a" : {
5453
"pass": "pass",
5554
"fail": "fail",
5655
"fail_longrefresh": "pass"
5756
}
58-
}],
57+
}],*/
58+
act: [ "bisz58"], // fail even if a page is redirected after more than 20 hours (7200)
5959
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
6060
const ruleContext = context["dom"].node as Element;
61-
// JCH - NO OUT OF SCOPE hidden in context
61+
6262
if (ruleContext.getAttribute("http-equiv").toLowerCase() !== 'refresh') {
6363
return null;
6464
}
6565

66+
let doc = ruleContext.ownerDocument;
67+
if (!doc) return;
68+
69+
// check if the rule already passed or failed: only the first one tridders if multiple
70+
if (CacheUtil.getCache(doc, "meta_redirect_optional_done", false))
71+
return null;
72+
6673
let content = ruleContext.getAttribute("content").toLowerCase();
67-
// Invalid content field
68-
if (!content.match(/^\d+$/) && !content.match(/^\d+;/)) {
74+
if (!content || content.trim().length ===0)
6975
return null;
76+
77+
let time:number = -1;
78+
if (content.match(/^\d+$/))
79+
time = parseInt(content);
80+
else if (content.match(/^\d+;/)) {
81+
let pos = content.indexOf(";");
82+
time = parseInt(content.substring(0, pos));
7083
}
71-
// Only check the first one since it takes priority
72-
if (CommonUtil.triggerOnce(FragmentUtil.getOwnerFragment(ruleContext), "meta_redirect_optional", false)) {
84+
// Invalid content field
85+
if (time === -1) {
7386
return null;
7487
}
75-
let timeMatch = content.match(/^(\d+); +[^ ]/);
76-
if (!timeMatch || parseInt(timeMatch[1]) === 0) {
88+
89+
CacheUtil.setCache(doc, "meta_redirect_optional_done", true);
90+
if (time === 0)
7791
return RulePass("pass");
78-
} else {
79-
let time = parseInt(timeMatch[1]);
80-
if (time < 72001) {
81-
return RuleFail("fail");
82-
} else {
83-
return RuleFail("fail_longrefresh");
84-
}
85-
}
92+
else if (time < 72001)
93+
return RuleFail("fail");
94+
95+
return RuleFail("fail_longrefresh");
96+
8697
}
8798
}

accessibility-checker-engine/src/v4/rules/meta_refresh_delay.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,29 @@
1313

1414
import { Rule, RuleResult, RuleContext, RulePotential, RulePass, RuleContextHierarchy } from "../api/IRule";
1515
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
16+
import { CacheUtil } from "../util/CacheUtil";
1617

1718
export const meta_refresh_delay: Rule = {
1819
id: "meta_refresh_delay",
1920
context: "dom:meta[http-equiv][content]",
2021
refactor: {
2122
"RPT_Meta_Refresh": {
22-
"Pass_0": "Pass_0",
23-
"Potential_1": "Potential_1"
23+
"Pass_0": "pass",
24+
"Potential_1": "potential_refresh"
2425
}
2526
},
2627
help: {
2728
"en-US": {
2829
"group": "meta_refresh_delay.html",
29-
"Pass_0": "meta_refresh_delay.html",
30-
"Potential_1": "meta_refresh_delay.html"
30+
"pass": "meta_refresh_delay.html",
31+
"potential_refresh": "meta_refresh_delay.html"
3132
}
3233
},
3334
messages: {
3435
"en-US": {
3536
"group": "Pages should not refresh automatically",
36-
"Pass_0": "Rule Passed",
37-
"Potential_1": "Verify page is not being caused to refresh automatically",
37+
"pass": "Pages do not refresh automatically",
38+
"potential_refresh": "Verify page is not being caused to refresh automatically",
3839
}
3940
},
4041
rulesets: [{
@@ -43,18 +44,39 @@ export const meta_refresh_delay: Rule = {
4344
"level": eRulePolicy.VIOLATION,
4445
"toolkitLevel": eToolkitLevel.LEVEL_THREE
4546
}],
46-
act: [ "bisz58", "bc659a" ],
47+
//act: [ "bisz58", "bc659a" ],
48+
act: [ "bc659a" ], // pass if a page is redirected after more than 20 hours (7200)
4749
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
4850
const ruleContext = context["dom"].node as Element;
4951
if (ruleContext.getAttribute("http-equiv").toLowerCase() !== 'refresh')
5052
return null;
5153

54+
let doc = ruleContext.ownerDocument;
55+
if (!doc) return;
56+
57+
// check if the rule already passed: the first one takes priority
58+
if (CacheUtil.getCache(doc, "meta_refresh_delay_done", false))
59+
return null;
60+
5261
let content = ruleContext.getAttribute("content").toLowerCase();
62+
if (!content || content.trim().length ===0)
63+
return null;
64+
65+
let time:number = -1;
66+
if (content.match(/^\d+$/))
67+
time = parseInt(content);
68+
else if (content.match(/^\d+;/)) {
69+
let pos = content.indexOf(";");
70+
time = parseInt(content.substring(0, pos));
71+
}
5372
// Invalid content field
54-
if (!content.match(/^\d+$/) && !content.match(/^\d+;/)) {
73+
if (time === -1) {
5574
return null;
5675
}
57-
let fail = !content.match(/^\d+; +[^ ]/);
58-
return !fail ? RulePass("Pass_0") : RulePotential("Potential_1");
76+
77+
CacheUtil.setCache(doc, "meta_refresh_delay_done", true);
78+
if (time === 0)
79+
return RulePass("pass");
80+
return RulePotential("potential_refresh");
5981
}
6082
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="30" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
{
14+
"ruleId": "meta_redirect_optional",
15+
"value": [
16+
"INFORMATION",
17+
"FAIL"
18+
],
19+
"path": {
20+
"dom": "/html[1]/head[1]/meta[1]",
21+
"aria": "/document[1]"
22+
},
23+
"reasonId": "fail",
24+
"message": "Check page does not automatically refresh without warning or options",
25+
"messageArgs": [],
26+
"apiArgs": [],
27+
"category": "Accessibility"
28+
}
29+
]
30+
}
31+
</script>
32+
</body>
33+
34+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="72001; URL='https://w3.org'" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
{
14+
"ruleId": "meta_redirect_optional",
15+
"value": [
16+
"INFORMATION",
17+
"FAIL"
18+
],
19+
"path": {
20+
"dom": "/html[1]/head[1]/meta[1]",
21+
"aria": "/document[1]"
22+
},
23+
"reasonId": "fail_longrefresh",
24+
"message": "Check page does not automatically refresh without warning or options",
25+
"messageArgs": [],
26+
"apiArgs": [],
27+
"category": "Accessibility"
28+
}
29+
]
30+
}
31+
</script>
32+
</body>
33+
34+
</html>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="0: https://w3.org" />
5+
<meta http-equiv="refresh" content="72001; https://w3.org" />
6+
</head>
7+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
8+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
9+
10+
<script>
11+
UnitTest = {
12+
ruleIds: ["meta_redirect_optional"],
13+
results: [
14+
{
15+
"ruleId": "meta_redirect_optional",
16+
"value": [
17+
"INFORMATION",
18+
"FAIL"
19+
],
20+
"path": {
21+
"dom": "/html[1]/head[1]/meta[2]",
22+
"aria": "/document[1]"
23+
},
24+
"reasonId": "fail_longrefresh",
25+
"message": "Check page does not automatically refresh without warning or options",
26+
"messageArgs": [],
27+
"apiArgs": [],
28+
"category": "Accessibility"
29+
}
30+
]
31+
}
32+
</script>
33+
</body>
34+
35+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
14+
]
15+
}
16+
</script>
17+
</body>
18+
19+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta content="72001" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
14+
]
15+
}
16+
</script>
17+
</body>
18+
19+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="0: http://example.com" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
14+
]
15+
}
16+
</script>
17+
</body>
18+
19+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="-00.12 foo" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
14+
]
15+
}
16+
</script>
17+
</body>
18+
19+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="; 72001" />
5+
</head>
6+
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
7+
<img src="/WAI/content-assets/wcag-act-rules/test-assets/shared/w3c-logo.png" alt="" aria-labelledby="label"> <span hidden="" id="label">W3C logo</span>
8+
9+
<script>
10+
UnitTest = {
11+
ruleIds: ["meta_redirect_optional"],
12+
results: [
13+
14+
]
15+
}
16+
</script>
17+
</body>
18+
19+
</html>

0 commit comments

Comments
 (0)