Skip to content

Commit

Permalink
Merge branch 'master' into issue-1563
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickRenteria authored Aug 3, 2023
2 parents 26962eb + 9d205bb commit 5ddaaf2
Show file tree
Hide file tree
Showing 16 changed files with 6,322 additions and 6,583 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { getDeprecatedAriaRoles, getDeprecatedAriaAttributes, getRolesUndefinedB

export let aria_accessiblename_exists: Rule = {
id: "aria_accessiblename_exists",
context: "aria:columnheader, aria:form, aria:heading, aria:link, aria:rowheader, aria:table, doc-backlink, doc-biblioentry, doc-biblioref, doc-glossref, doc-noteref, doc-pagebreak",
context: "aria:columnheader, aria:form, aria:heading, aria:rowheader, aria:table, doc-backlink, doc-biblioentry, doc-biblioref, doc-glossref, doc-noteref, doc-pagebreak",
help: {
"en-US": {
"pass": "aria_accessiblename_exists.html",
Expand All @@ -32,13 +32,13 @@ export let aria_accessiblename_exists: Rule = {
"en-US": {
"pass": "An accessible name is provided for the element",
"fail_no_accessible_name": "Element <{0}> with \"{1}\" role has no accessible name",
"group": "Elements with cerain roles must have accessible names per ARIA specification"
"group": "Elements with certain roles should have accessible names"
}
},
rulesets: [{
"id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0"],
"num": ["4.1.2"],
"level": eRulePolicy.VIOLATION,
"num": ["1.3.1"],
"level": eRulePolicy.RECOMMENDATION,
"toolkitLevel": eToolkitLevel.LEVEL_ONE
}],
act: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { eRulePolicy, eToolkitLevel } from "../api/IRule";
import { ARIAMapper } from "../../v2/aria/ARIAMapper";
import { FragmentUtil } from "../../v2/checker/accessibility/util/fragment";
import { getCache, setCache } from "../util/CacheUtil";
import { RPTUtil } from "../../v2/checker/accessibility/util/legacy";
import { VisUtil } from "../../v2/dom/VisUtil";

export let fieldset_label_valid: Rule = {
id: "fieldset_label_valid",
Expand Down Expand Up @@ -51,6 +53,11 @@ export let fieldset_label_valid: Rule = {
act: [],
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;

//skip the check if the element is hidden or disabled
if (VisUtil.isNodeHiddenFromAT(ruleContext) || RPTUtil.isNodeDisabled(ruleContext))
return;

let ownerDocument = FragmentUtil.getOwnerFragment(ruleContext);
let formCache = getCache(
ruleContext.ownerDocument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
limitations under the License.
*****************************************************************************/

import { Rule, RuleResult, RuleFail, RuleContext, RulePotential, RuleManual, RulePass, RuleContextHierarchy } from "../api/IRule";
import { Rule, RuleResult, RuleFail, RuleContext, RulePass, RuleContextHierarchy } from "../api/IRule";
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
import { RPTUtil } from "../../v2/checker/accessibility/util/legacy";

Expand Down Expand Up @@ -40,13 +40,13 @@ export let fieldset_legend_valid: Rule = {
"Fail_1": "<fieldset> element does not have a <legend>",
"Fail_2": "<fieldset> element has more than one <legend>",
"Fail_3": "<fieldset> element <legend> is empty",
"group": " <fieldset> elements must have a single, non-empty <legend> as a label"
"group": " <fieldset> elements should have a single, non-empty <legend> as a label"
}
},
rulesets: [{
"id": ["IBM_Accessibility", "WCAG_2_1", "WCAG_2_0"],
"num": ["1.3.1"],
"level": eRulePolicy.VIOLATION,
"num": ["1.3.1"], //https://www.w3.org/WAI/WCAG22/Techniques/html/H71
"level": eRulePolicy.RECOMMENDATION,
"toolkitLevel": eToolkitLevel.LEVEL_ONE
}],
act: [],
Expand All @@ -63,8 +63,7 @@ export let fieldset_legend_valid: Rule = {
} else if (RPTUtil.getInnerText(legends[0]).trim().length === 0) {
// Fieldset has legend but legend is empty
return RuleFail("Fail_3");
} else {
return RulePass("Pass_0");
}
return RulePass("Pass_0");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,6 @@ <h3>Accessible Name Tests</h3>
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "aria_accessiblename_exists",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/div[2]",
"aria": "/document[1]/form[1]/link[1]"
},
"reasonId": "fail_no_accessible_name",
"message": "Element <div> with \"link\" role has no accessible name",
"messageArgs": [
"div",
"link"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "input_label_exists",
"value": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
/******************************************************************************
Copyright:: 2020- IBM, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
-->

<html lang="en">

<head>
<title>RPT Test Suite</title>
</head>

<body>

<a href="#navskip">skip to main content</a>


<h2>Test case: FieldSet-hasarialabel.html</h2>



<!-- ################################################################### -->


<h3>Input type Tests</h3>

<ul>
<li>Test - best practice</li>
</ul>
<form action="..." method="post">
<fieldset aria-labelledby="mylegend">
<legend id="mylegend">Please enter your company information.</legend>

<label for="cpname">Company Name</label>
<input type="text" name="cpname" id="cpname" value="enter company name">

</fieldset>

</form>

<ul>
<li>Test - no legend for fieldset but with label</li>
</ul>

<form action="..." method="post">
<fieldset aria-label="this is a potentially very long description of the fieldset and more description is possible">
<label for="fn1">First Name</label>
<input type="text" name="firstname" id="fn1" value="enter first name" title="enter first name">

<label for="ln1">Last Name</label>
<input type="text" name="lastname" id="ln1" value="enter last name" title="enter last name">

<button type="submit">Submit</button>
</fieldset>
</form>
<ul>
<li>Test - with a legend for fieldset but without label</li>
</ul>
<form action="..." method="post">
<fieldset>
<legend id="mylegend">this is a potentially very long description of the fieldset and more description is possible</legend>

<label for="name">Name</label>
<input type="text" name="name" id="name" value="enter name" title="enter name">

<button type="submit">Submit</button>
</fieldset>

</form>

<form action="..." method="post">
<fieldset aria-label="this is a potentially very long description of the fieldset and more description is possible">
<label for="fn1">First Name</label>
<input type="text" name="firstname" id="fn1" value="enter first name" title="enter first name">

<label for="ln1">Last Name</label>
<input type="text" name="lastname" id="ln1" value="enter last name" title="enter last name">

<button type="submit">Submit</button>
</fieldset>
</form>

<a name="navskip"></a>


<script>
UnitTest = {
ruleIds: ["fieldset_label_valid"],
results: [
{
"ruleId": "fieldset_label_valid",
"value": [
"INFORMATION",
"PASS"
],
"path": {
"dom": "/html[1]/body[1]/form[1]/fieldset[1]",
"aria": "/document[1]/form[1]/group[1]"
},
"reasonId": "Pass_1",
"message": "Group/Fieldset \"Please enter your company information.\" with an input has a unique name",
"messageArgs": [
"Please enter your company information."
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "fieldset_label_valid",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/form[2]/fieldset[1]",
"aria": "/document[1]/form[2]/group[1]"
},
"reasonId": "Fail_2",
"message": "Group/Fieldset \"this is a potentially very long description of the fieldset and more description is possible\" has a duplicate name to another group",
"messageArgs": [
"this is a potentially very long description of the fieldset and more description is possible"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "fieldset_label_valid",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/form[3]/fieldset[1]",
"aria": "/document[1]/form[3]/group[1]"
},
"reasonId": "Fail_2",
"message": "Group/Fieldset \"this is a potentially very long description of the fieldset and more description is possible\" has a duplicate name to another group",
"messageArgs": [
"this is a potentially very long description of the fieldset and more description is possible"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "fieldset_label_valid",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/form[4]/fieldset[1]",
"aria": "/document[1]/form[4]/group[1]"
},
"reasonId": "Fail_2",
"message": "Group/Fieldset \"this is a potentially very long description of the fieldset and more description is possible\" has a duplicate name to another group",
"messageArgs": [
"this is a potentially very long description of the fieldset and more description is possible"
],
"apiArgs": [],
"category": "Accessibility"
}
]

}
</script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h3>Input type Tests</h3>
passedXpaths: [
],
failedXpaths: [
"/html/body/form/fieldset"
"/html/body/form/fieldset"
]
},
];
Expand Down
Loading

0 comments on commit 5ddaaf2

Please sign in to comment.