Skip to content

Commit

Permalink
Merge branch 'master' into dev-2122-new
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrunet authored Feb 4, 2025
2 parents 2e8a402 + dea41a2 commit 987863e
Show file tree
Hide file tree
Showing 40 changed files with 1,014 additions and 37 deletions.
6 changes: 3 additions & 3 deletions accessibility-checker-engine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
//{ pattern: 'test/v2/checker/accessibility/rules/label_name_visible_ruleunit/label_offscreen.html', watched: true },
//{ pattern: 'test/v2/checker/accessibility/rules/aria_role_valid_ruleunit/td_attribute_invalid_copy.html', watched: true },
//{ pattern: 'test/v2/checker/accessibility/rules/text_block_heading_ruleunit/Headings-noneUsedEmphasizedText.html', watched: true },
{ pattern: 'test/v2/checker/accessibility/rules/aria_landmark_name_unique_ruleunit/*.html', watched: true },
//{ pattern: 'test/v2/checker/accessibility/rules/aria_landmark_name_unique_ruleunit/*.html', watched: true },
// { pattern: 'test/v2/checker/accessibility/rules/aria_parent_required_ruleunit/webComponentPass2.html', watched: true },


// { pattern: 'test/**/*_ruleunit/*.html', watched: true },
// { pattern: 'test/**/*_ruleunit/*.htm', watched: true },
{ pattern: 'test/**/*_ruleunit/*.html', watched: true },
{ pattern: 'test/**/*_ruleunit/*.htm', watched: true },
// all files ending in "_test"
// { pattern: 'test/*_test.js', watched: true },
{ pattern: 'test/**/*_test.js', watched: true }
Expand Down
41 changes: 39 additions & 2 deletions accessibility-checker-engine/src/v2/aria/ARIAMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,45 @@ export class ARIAMapper extends CommonMapper {
for (let iId=0; iId < ownIds.length; ++iId) {
const owned = doc.getElementById(ownIds[iId]);
//ignore if the aria-owns point to the element itself
if (owned && !DOMUtil.sameNode(owner, owned)) {
CacheUtil.setCache(owned, "aria-owned", owner);
//if (owned && !DOMUtil.sameNode(owner, owned)) {
// CacheUtil.setCache(owned, "aria-owned", owner);
//}
/**
* circular hierarchy check:
* (1) the owned element is neither the same element with the owner nor any ascendant of the owner
* (2) any child with aria-owns cannot point to the owner or any ascendant of the owner
*/
if (owned && !DOMUtil.sameNode(owner, owned)) {
// check if the owned with aria-owns that points to another element
let ownedNodes = [];
const sub_owners = owned.querySelectorAll("[aria-owns]");
for (let i = 0; i < sub_owners.length; ++i) {
const sub_owner = sub_owners[i];
const sub_ownIds = sub_owner.getAttribute("aria-owns").split(/ +/g);
for (let j=0; j < sub_ownIds.length; ++j) {
const ownedNode = doc.getElementById(sub_ownIds[j]);
if (ownedNode)
ownedNodes.push(ownedNode);
}
}
if (ownedNodes.length === 0) {
CacheUtil.setCache(owned, "aria-owned", owner);
continue;
}
// check if any aria-owns points to the element itself or any of it's parent
let parent : Element = owner;
let circular = false;
while (parent !== null) {
const found = ownedNodes.some(item => DOMUtil.sameNode(parent, item));
if (!found)
parent = DOMWalker.parentElement(parent);
else {
circular = true;
break;
}
}
if (!circular)
CacheUtil.setCache(owned, "aria-owned", owner);
}
}
}
Expand Down
49 changes: 30 additions & 19 deletions accessibility-checker-engine/src/v4/rules/meta_redirect_optional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
limitations under the License.
*****************************************************************************/

import { FragmentUtil } from "../../v2/checker/accessibility/util/fragment";
import { CommonUtil } from "../util/CommonUtil";
import { Rule, RuleResult, RuleFail, RuleContext, RulePass, RuleContextHierarchy } from "../api/IRule";
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
import { CacheUtil } from "../util/CacheUtil";

export const meta_redirect_optional: Rule = {
id: "meta_redirect_optional",
Expand Down Expand Up @@ -49,39 +48,51 @@ export const meta_redirect_optional: Rule = {
"toolkitLevel": eToolkitLevel.LEVEL_THREE
}],
// Removed ACT bisz58 AAA
act: [{
/**act: [{
"bc659a" : {
"pass": "pass",
"fail": "fail",
"fail_longrefresh": "pass"
}
}],
}],*/
act: [ "bisz58"], // fail even if a page is redirected after more than 20 hours (7200)
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;
// JCH - NO OUT OF SCOPE hidden in context

if (ruleContext.getAttribute("http-equiv").toLowerCase() !== 'refresh') {
return null;
}

let doc = ruleContext.ownerDocument;
if (!doc) return;

// check if the rule already passed or failed: only the first one tridders if multiple
if (CacheUtil.getCache(doc, "meta_redirect_optional_done", false))
return null;

let content = ruleContext.getAttribute("content").toLowerCase();
// Invalid content field
if (!content.match(/^\d+$/) && !content.match(/^\d+;/)) {
if (!content || content.trim().length ===0)
return null;

let time:number = -1;
if (content.match(/^\d+$/))
time = parseInt(content);
else if (content.match(/^\d+;/)) {
let pos = content.indexOf(";");
time = parseInt(content.substring(0, pos));
}
// Only check the first one since it takes priority
if (CommonUtil.triggerOnce(FragmentUtil.getOwnerFragment(ruleContext), "meta_redirect_optional", false)) {
// Invalid content field
if (time === -1) {
return null;
}
let timeMatch = content.match(/^(\d+); +[^ ]/);
if (!timeMatch || parseInt(timeMatch[1]) === 0) {

CacheUtil.setCache(doc, "meta_redirect_optional_done", true);
if (time === 0)
return RulePass("pass");
} else {
let time = parseInt(timeMatch[1]);
if (time < 72001) {
return RuleFail("fail");
} else {
return RuleFail("fail_longrefresh");
}
}
else if (time < 72001)
return RuleFail("fail");

return RuleFail("fail_longrefresh");

}
}
42 changes: 32 additions & 10 deletions accessibility-checker-engine/src/v4/rules/meta_refresh_delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@

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

export const meta_refresh_delay: Rule = {
id: "meta_refresh_delay",
context: "dom:meta[http-equiv][content]",
refactor: {
"RPT_Meta_Refresh": {
"Pass_0": "Pass_0",
"Potential_1": "Potential_1"
"Pass_0": "pass",
"Potential_1": "potential_refresh"
}
},
help: {
"en-US": {
"group": "meta_refresh_delay.html",
"Pass_0": "meta_refresh_delay.html",
"Potential_1": "meta_refresh_delay.html"
"pass": "meta_refresh_delay.html",
"potential_refresh": "meta_refresh_delay.html"
}
},
messages: {
"en-US": {
"group": "Pages should not refresh automatically",
"Pass_0": "Rule Passed",
"Potential_1": "Verify page is not being caused to refresh automatically",
"pass": "Pages do not refresh automatically",
"potential_refresh": "Verify page is not being caused to refresh automatically",
}
},
rulesets: [{
Expand All @@ -43,18 +44,39 @@ export const meta_refresh_delay: Rule = {
"level": eRulePolicy.VIOLATION,
"toolkitLevel": eToolkitLevel.LEVEL_THREE
}],
act: [ "bisz58", "bc659a" ],
//act: [ "bisz58", "bc659a" ],
act: [ "bc659a" ], // pass if a page is redirected after more than 20 hours (7200)
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;
if (ruleContext.getAttribute("http-equiv").toLowerCase() !== 'refresh')
return null;

let doc = ruleContext.ownerDocument;
if (!doc) return;

// check if the rule already passed: the first one takes priority
if (CacheUtil.getCache(doc, "meta_refresh_delay_done", false))
return null;

let content = ruleContext.getAttribute("content").toLowerCase();
if (!content || content.trim().length ===0)
return null;

let time:number = -1;
if (content.match(/^\d+$/))
time = parseInt(content);
else if (content.match(/^\d+;/)) {
let pos = content.indexOf(";");
time = parseInt(content.substring(0, pos));
}
// Invalid content field
if (!content.match(/^\d+$/) && !content.match(/^\d+;/)) {
if (time === -1) {
return null;
}
let fail = !content.match(/^\d+; +[^ ]/);
return !fail ? RulePass("Pass_0") : RulePotential("Potential_1");

CacheUtil.setCache(doc, "meta_refresh_delay_done", true);
if (time === 0)
return RulePass("pass");
return RulePotential("potential_refresh");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en-US">

<head>
<title>Sandbox</title>
<meta charset="UTF-8" />
</head>

<body>
<div class="mm-panels">
<div id="mm-1" class="mm-panel mm-panel_opened">
<ul class="mm-listview">
<li class="mm-listitem"><a href="#mm-2" aria-owns="mm-2">Open submenu</a>
<li class="mm-listitem"><a href="#mm-3" aria-owns="mm-3">Open Another submenu</a>
</li>
</ul>
</div>
<div id="mm-3">
<div class="mm-navbar"><a href="#mm-1" aria-owns="mm-1">Close submenu</a>
</div>
</div>
</div>
</body>
<script>
UnitTest = {
ruleIds: ["aria_descendant_valid"],
results: [

]
}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

<html lang="en">
<head>
<meta http-equiv="refresh" content="30" />
</head>
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
<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>

<script>
UnitTest = {
ruleIds: ["meta_redirect_optional"],
results: [
{
"ruleId": "meta_redirect_optional",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/head[1]/meta[1]",
"aria": "/document[1]"
},
"reasonId": "fail",
"message": "Check page does not automatically refresh without warning or options",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
}
]
}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

<html lang="en">
<head>
<meta http-equiv="refresh" content="72001; URL='https://w3.org'" />
</head>
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
<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>

<script>
UnitTest = {
ruleIds: ["meta_redirect_optional"],
results: [
{
"ruleId": "meta_redirect_optional",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/head[1]/meta[1]",
"aria": "/document[1]"
},
"reasonId": "fail_longrefresh",
"message": "Check page does not automatically refresh without warning or options",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
}
]
}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

<html lang="en">
<head>
<meta http-equiv="refresh" content="0: https://w3.org" />
<meta http-equiv="refresh" content="72001; https://w3.org" />
</head>
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
<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>

<script>
UnitTest = {
ruleIds: ["meta_redirect_optional"],
results: [
{
"ruleId": "meta_redirect_optional",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/head[1]/meta[2]",
"aria": "/document[1]"
},
"reasonId": "fail_longrefresh",
"message": "Check page does not automatically refresh without warning or options",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
}
]
}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

<html lang="en">
<head>
<meta http-equiv="refresh" />
</head>
<body data-new-gr-c-s-check-loaded="14.1192.0" data-gr-ext-installed="">
<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>

<script>
UnitTest = {
ruleIds: ["meta_redirect_optional"],
results: [

]
}
</script>
</body>

</html>
Loading

0 comments on commit 987863e

Please sign in to comment.