Skip to content

fixrule(svg_graphics_labelled, img_alt_valid) Ignore SVG accessible name requirement when its ancestor is a widget or requires presentational child V3 #2268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b2bedf8
chore(all): Sync with the master and update libraries (#1960)
shunguoy Aug 22, 2024
01c107f
chore(repo): Update main-4.x (#2118)
tombrunet Dec 10, 2024
89a2072
Merge-12-12 (#2130)
tombrunet Dec 13, 2024
a66e96e
Merge branch 'master' into main-4.x
tombrunet Dec 13, 2024
981a467
chore(repo): Update main-4.x for Jan release (#2148)
tombrunet Jan 14, 2025
a5559ab
fixrule(meta_refresh_delay | meta_redirect_optional) Fix the rules to…
shunguoy Feb 4, 2025
968333c
fix(engine): fix circular structure caused by aria-owns V4 (#2166)
shunguoy Feb 4, 2025
a08baf4
fix(engine): Fix issues related to accessible name concatenation and …
shunguoy Feb 4, 2025
4707675
chore(repo): Add note of unapproved in ACT txt debug result (for 4.x …
tombrunet Feb 4, 2025
514874b
Merge branch 'mjs-js-ext' into mjs-js-ext-v4
tombrunet Feb 4, 2025
78ae4d6
Merge branch 'mjs-js-ext' into mjs-js-ext-v4
tombrunet Feb 4, 2025
4d1f8c4
Merge pull request #2182 from IBMa/mjs-js-ext-v4
philljenkins Feb 4, 2025
9feb8f0
update the rule and add a test case #dev-2085 (#2187)
shunguoy Feb 10, 2025
951f882
chore(archive): Create archive for Feb 10, 2025 for v4.x (#2198)
tombrunet Feb 10, 2025
0511c6d
bug(node): File extensions not correct for ESM (v4.x) (#2203)
tombrunet Feb 18, 2025
b5695ae
No longer need to build old report
tombrunet Feb 18, 2025
81b9749
Merge branch 'act-hang-v3' into act-hang-v4
tombrunet Feb 18, 2025
1847dc3
Merge pull request #2205 from IBMa/act-hang-v4
philljenkins Feb 18, 2025
a6119fe
Merge branch 'dev-958' into dev-958-v4
shunguoy Feb 19, 2025
dc1943a
Merge pull request #2210 from IBMa/dev-958-v4
sct-will Feb 24, 2025
6fa955a
Merge branch 'dev-2183' into dev-2183-v4
shunguoy Feb 25, 2025
1b7a1d8
Merge pull request #2214 from IBMa/dev-2183-v4
philljenkins Feb 27, 2025
22d56df
Merge branch 'dev-1918' into dev-1918-v4
shunguoy Mar 10, 2025
b60981d
Merge branch 'dev-1918' into dev-1918-v4
shunguoy Mar 11, 2025
d62b124
Merge branch 'issue-e2e-7049' into issue-e2e-7049-v4
tombrunet Mar 12, 2025
8bf5619
Merge pull request #2222 from IBMa/dev-1918-v4
philljenkins Mar 13, 2025
2465f54
Merge branch 'main-4.x' into issue-e2e-7049-v4
philljenkins Mar 13, 2025
721da34
Merge pull request #2226 from IBMa/issue-e2e-7049-v4
philljenkins Mar 13, 2025
d51e761
Merge branch 'dev-2220-a' into dev-2220-a-v4
shunguoy Mar 24, 2025
15e7dae
Merge branch 'dev-2220-a' into dev-2220-a-v4
shunguoy Mar 25, 2025
2db3924
Merge pull request #2233 from IBMa/dev-2220-a-v4
philljenkins Mar 27, 2025
38fdb8c
Merge branch 'archive-2025-03-27' into main-4.x
tombrunet Mar 27, 2025
d6ef2b5
Merge pull request #2236 from IBMa/archive-2025-03-27-v4
philljenkins Mar 27, 2025
f3306ab
update the baselines #dev-2109-v4
shunguoy Apr 3, 2025
807bb50
Merge branch 'dev-2109' into dev-2109-v4
shunguoy Apr 3, 2025
e235b96
Merge pull request #2241 from IBMa/dev-2109-v4
philljenkins Apr 15, 2025
f4f80df
Merge branch 'issue-2186' into issue-2186-4.x
tombrunet Apr 17, 2025
a10cba9
Pup type error
tombrunet Apr 17, 2025
c4504e3
Merge pull request #2252 from IBMa/issue-2186-4.x
philljenkins Apr 22, 2025
fd7a6e3
fixrule(input_label_exists, aria_widget_labelled, aria_accessiblename…
shunguoy Apr 24, 2025
c54f897
chore(node,karma,cypress): Dependency updates (4.x only) (#2253)
tombrunet Apr 24, 2025
9d0cf68
chore(archive): Create archive for April 24, 2025 (4.x) (#2260)
tombrunet Apr 24, 2025
497ac2d
add test file #dev-2219-v4
shunguoy Apr 28, 2025
22914a7
Merge branch 'dev-2219' into dev-2219-v4
shunguoy Apr 28, 2025
5cb8dc9
Merge branch 'dev-2219' into dev-2219-v4
shunguoy Apr 28, 2025
eda6def
Merge pull request #2265 from IBMa/dev-2219-v4
philljenkins May 1, 2025
7e75ec3
modify the img/svg rules #dev-2224
shunguoy May 1, 2025
c9b99af
update the rule logic #dev-2224
shunguoy May 2, 2025
3041d0f
Merge branch 'main-4.x' into dev-2224
shunguoy May 2, 2025
8ce3835
update the comparison logic #dev-2224
shunguoy May 2, 2025
3bf68b7
Merge branch 'dev-2224' into dev-2224-v3
shunguoy May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ jobs:
- run: npm run build
working-directory: accessibility-checker

- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Baselines/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Baselines/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Functions.Defined/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Functions.Defined/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.ObjectStructure/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.ObjectStructure/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.assertionCompliance.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.assertionCompliance.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.Puppeteer.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.Puppeteer.test.mjs
working-directory: accessibility-checker

###############################################################################
Expand All @@ -154,7 +154,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 18.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -183,15 +183,15 @@ jobs:
- run: npm run build
working-directory: accessibility-checker

- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Baselines/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Baselines/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Functions.Defined/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Functions.Defined/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.ObjectStructure/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.ObjectStructure/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.assertionCompliance.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.assertionCompliance.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.Puppeteer.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.Puppeteer.test.mjs
working-directory: accessibility-checker

###############################################################################
Expand Down Expand Up @@ -231,9 +231,9 @@ jobs:
- run: npm run build
working-directory: accessibility-checker

- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.Content.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.URL.test.js
- run: npx mocha -R dot test/mocha/aChecker.Fast/aChecker.Scans/aChecker.URL.test.mjs
working-directory: accessibility-checker

###############################################################################
Expand Down Expand Up @@ -273,9 +273,9 @@ jobs:
- run: npm run build
working-directory: accessibility-checker

- run: npx mocha -R dot test/mocha/aChecker.Slow1/aChecker.Scans/**/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Slow1/aChecker.Scans/**/*.test.mjs
working-directory: accessibility-checker
- run: npx mocha -R dot test/mocha/aChecker.Slow1/aChecker.ObjectStructure/**/*.test.js
- run: npx mocha -R dot test/mocha/aChecker.Slow1/aChecker.ObjectStructure/**/*.test.mjs
working-directory: accessibility-checker


Expand Down Expand Up @@ -474,6 +474,8 @@ jobs:
working-directory: common/module
- run: npm install
working-directory: karma-accessibility-checker
- run: npm install --no-save forever
working-directory: karma-accessibility-checker
- run: npm run setup
working-directory: karma-accessibility-checker
- run: sleep 10
Expand Down
5 changes: 3 additions & 2 deletions accessibility-checker-engine/src/v4/rules/img_alt_valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Rule, RuleResult, RuleFail, RuleContext, RulePass, RuleContextHierarchy
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
import { AriaUtil } from "../util/AriaUtil";
import { VisUtil } from "../util/VisUtil";
import { AccNameUtil } from "../util/AccNameUtil";

export const img_alt_valid: Rule = {
id: "img_alt_valid",
Expand Down Expand Up @@ -53,8 +54,8 @@ export const img_alt_valid: Rule = {
act: "23a2a8",
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;
// If not visible to the screen reader, ignore
if (VisUtil.isNodeHiddenFromAT(ruleContext))
// If not visible to the screen reader, or can be ignored
if (VisUtil.isNodeHiddenFromAT(ruleContext) || AccNameUtil.isAccessibleNameIgnorable(ruleContext))
return null;

if (AriaUtil.getAriaLabel(ruleContext).trim().length !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const svg_graphics_labelled: Rule = {
const ruleContext = context["dom"].node as Element;

//skip the rule
if (VisUtil.isNodeHiddenFromAT(ruleContext) || VisUtil.isNodePresentational(ruleContext)) return null;
if (VisUtil.isNodeHiddenFromAT(ruleContext) || VisUtil.isNodePresentational(ruleContext) || AccNameUtil.isAccessibleNameIgnorable(ruleContext)) return null;

const name_pair = AccNameUtil.computeAccessibleName(ruleContext);
if (name_pair && name_pair.name && name_pair.name.trim().length > 0)
Expand Down
16 changes: 16 additions & 0 deletions accessibility-checker-engine/src/v4/util/AccNameUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,20 @@ export class AccNameUtil {

return null;
}

// if accessible name can be ignored for image or svg
public static isAccessibleNameIgnorable(elem: Element) : boolean {
if (!elem) return false;

const nodeName = elem.nodeName.toLowerCase();
if (nodeName !== 'img' && nodeName !== 'svg') return false;

let parent = elem.parentElement;
if (parent) {
// if the parent is a widget and has an aria label, then image/svg label is not necessary
if ((AriaUtil.isWidget(parent) || AriaUtil.containsPresentationalChildrenOnly(parent)) && AriaUtil.hasAriaLabel(parent))
return true;
}
return false;
}
}
4 changes: 2 additions & 2 deletions accessibility-checker-engine/src/v4/util/ClipPathUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export class ClipPathUtil {

// to prevent the bottom edge from crossing over the top edge and right edge from crossing over the left edge.
// for example, rect(10px 0 0 20px) is clamped to rect(10px 20px 10px 20px)
if (numbers[2] < numbers[0] ) numbers[2] = numbers[0];
if (numbers[1] < numbers[3] ) numbers[1] = numbers[3];
numbers[2] = Math.max(numbers[0], numbers[2]);
numbers[1] = Math.max(numbers[1], numbers[3])

let top = parseInt(numbers[0]);
if (isNaN(top)) {
Expand Down
148 changes: 76 additions & 72 deletions accessibility-checker-engine/test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,53 @@
<title>test case</title>
</head>
<body>
<a href="https://ibm.com">Content</a>
<hr style="margin-top:50px;">
<div>Auto Scrollable w/o tabindex</div>
<section id='section1' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;">
<hr style="margin-top:50px;">
<section id='section1' style="height: 100px; width: 500px; overflow-x: hidden; overflow-y: hidden;">
<p>
Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
accessible.
</p>

</section>
<div>Auto Scrollable w/o tabindex</div>
<section id='section3' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;">
<h1>WCAG Abstract (no tabindex)</h1>
<p>
Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
accessible. Following these guidelines will make content more accessible to a wider range of people with
disabilities, including accommodations for blindness and low vision, deafness and hearing loss, limited movement,
speech disabilities, photosensitivity, and combinations of these, and some accommodation for learning disabilities
and cognitive limitations; but will not address every user need for people with these disabilities. These guidelines
address accessibility of web content on desktops, laptops, tablets, and mobile devices. Following these guidelines
will also often make Web content more usable to users in general.
</p>
</section>
<hr style="margin-top:50px;">
<div>Auto Scrollable w/ tabindex='-1'</div>
<section id='section3' tabindex='-1' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;">
<h1>WCAG Abstract</h1>
<p>
Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
accessible. Following these guidelines will make content more accessible to a wider range of people with
disabilities, including accommodations for blindness and low vision, deafness and hearing loss, limited movement,
speech disabilities, photosensitivity, and combinations of these, and some accommodation for learning disabilities
and cognitive limitations; but will not address every user need for people with these disabilities. These guidelines
address accessibility of web content on desktops, laptops, tablets, and mobile devices. Following these guidelines
will also often make Web content more usable to users in general.
</p>
</section>

<hr style="margin-top:50px;">
<div>iframe w/o tabindex short content</div>
<iframe id='section2' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;"
srcdoc="Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
accessible."

>
</iframe>

<hr style="margin-top:50px;">
<div>iframe w/o tabindex long content</div>
<iframe id='section2' role='none' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;"
srcdoc="Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
<iframe id='section2' src='./test2.html' style="height: 100px; width: 500px; overflow-x: hidden; overflow-y: hidden;">

</body>
Expand All @@ -26,14 +64,29 @@
<h1>WCAG Abstract</h1>
<p>
Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more

will also often make Web content more usable to users in general."

>
</iframe>

<hr style="margin-top:50px;">
<div>iframe w/ tabindex='-1'</div>
<iframe id='section2' tabindex='-1' style="height: 100px; width: 500px; overflow-x: auto; overflow-y: auto;"
srcdoc="Web Content Accessibility Guidelines (WCAG) covers a wide range of recommendations for making Web content more
accessible. Following these guidelines will make content more accessible to a wider range of people with
disabilities, including accommodations for blindness and low vision, deafness and hearing loss, limited movement,
speech disabilities, photosensitivity, and combinations of these, and some accommodation for learning disabilities
and cognitive limitations; but will not address every user need for people with these disabilities. These guidelines
address accessibility of web content on desktops, laptops, tablets, and mobile devices. Following these guidelines
will also often make Web content more usable to users in general.
</p>
</section>
will also often make Web content more usable to users in general."

>
</iframe>

<iframe role='none' src="./tinker.html">
</iframe>


<hr style="margin-top:50px;">
<button aria-label="a test button">
Expand All @@ -49,73 +102,24 @@ <h1>WCAG Abstract</h1>
<button aria-label="a test nutton"><img src="http://thinkingstiff.com/images/matt.jpg" alt=""></button>
<button aria-label="a test nutton"><img src="http://thinkingstiff.com/images/matt.jpg" role="none"></button>

<a href="http://ibm.com"><img src="http://thinkingstiff.com/images/matt.jpg" />Here</a>

<a href="http://ibm.com"><img src="http://thinkingstiff.com/images/matt.jpg" alt="image" /></a>
will also often make Web content more usable to users in general.
</p>
</section>

<ol>
<li>Option 1<img src="http://thinkingstiff.com/images/matt.jpg"></li>
<li>Option 2<img src="http://thinkingstiff.com/images/matt.jpg"></li>
</ol>
<hr style="margin-top:50px;">
<button aria-label="a test button">
<svg>
</svg>
</button>

<button aria-label="a test nutton"><img src="http://thinkingstiff.com/images/matt.jpg"></button>
<button><img src="http://thinkingstiff.com/images/matt.jpg" alt="an image"></button>
<button><img src="http://thinkingstiff.com/images/matt.jpg">Submit</button>
<button><img src="http://thinkingstiff.com/images/matt.jpg" alt="">Submit</button>

</main>
<button aria-label="a test nutton"><img src="http://thinkingstiff.com/images/matt.jpg" alt=""></button>
<button aria-label="a test nutton"><img src="http://thinkingstiff.com/images/matt.jpg" role="none"></button>

<script>
UnitTest = {
ruleIds: ["element_scrollable_tabbable", "element_tabbable_role_valid"],
results: [
{
"ruleId": "element_scrollable_tabbable",
"value": [
"INFORMATION",
"PASS"
],
"path": {
"dom": "/html[1]/body[1]/section[1]",
"aria": "/document[1]"
},
"reasonId": "pass_tabbable",
"message": "The scrollable element is tabbable",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_tabbable_role_valid",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/section[2]",
"aria": "/document[1]"
},
"reasonId": "fail_no_valid_role",
"message": "The tabbable element does not have a valid widget role",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_tabbable_role_valid",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/section[3]",
"aria": "/document[1]"
},
"reasonId": "fail_no_valid_role",
"message": "The tabbable element does not have a valid widget role",
"messageArgs": [],
"apiArgs": [],
"category": "Accessibility"
}
]
}
</script>
</body>

</html>
Loading