Skip to content

Commit

Permalink
feat(aria-prohibited-attr): add rule aria-prohibited-attr (#4088)
Browse files Browse the repository at this point in the history
* feat(aria-prohibited-attr): add rule aria-prohibited-attr

* fix act

* fixes

* Apply suggestions from code review

Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>

---------

Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
  • Loading branch information
straker and WilcoFiers authored Jul 14, 2023
1 parent f151508 commit 7b115d3
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 92 deletions.
3 changes: 2 additions & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
| Rule ID | Description | Impact | Tags | Issue Type | ACT Rules |
| :------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------- | :--------------------------------------------------------------------------------------------------------------------------------- | :------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [area-alt](https://dequeuniversity.com/rules/axe/4.7/area-alt?application=RuleDescription) | Ensures &lt;area&gt; elements of image maps have alternate text | Critical | cat.text-alternatives, wcag2a, wcag244, wcag412, section508, section508.22.a, TTv5, TT6.a, EN-301-549, EN-9.2.4.4, EN-9.4.1.2, ACT | failure, needs&nbsp;review | [c487ae](https://act-rules.github.io/rules/c487ae) |
| [aria-allowed-attr](https://dequeuniversity.com/rules/axe/4.7/aria-allowed-attr?application=RuleDescription) | Ensures ARIA attributes are allowed for an element&apos;s role | Serious, Critical | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure, needs&nbsp;review | [5c01ea](https://act-rules.github.io/rules/5c01ea) |
| [aria-allowed-attr](https://dequeuniversity.com/rules/axe/4.7/aria-allowed-attr?application=RuleDescription) | Ensures an element&apos;s role supports its ARIA attributes | Serious, Critical | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure, needs&nbsp;review | [5c01ea](https://act-rules.github.io/rules/5c01ea) |
| [aria-command-name](https://dequeuniversity.com/rules/axe/4.7/aria-command-name?application=RuleDescription) | Ensures every ARIA button, link and menuitem has an accessible name | Serious | cat.aria, wcag2a, wcag412, TTv5, TT6.a, EN-301-549, EN-9.4.1.2, ACT | failure, needs&nbsp;review | [97a4e1](https://act-rules.github.io/rules/97a4e1) |
| [aria-deprecated-role](https://dequeuniversity.com/rules/axe/4.7/aria-deprecated-role?application=RuleDescription) | Ensures elements do not use deprecated roles | Minor | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure | [674b10](https://act-rules.github.io/rules/674b10) |
| [aria-hidden-body](https://dequeuniversity.com/rules/axe/4.7/aria-hidden-body?application=RuleDescription) | Ensures aria-hidden=&apos;true&apos; is not present on the document body. | Critical | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure | |
| [aria-hidden-focus](https://dequeuniversity.com/rules/axe/4.7/aria-hidden-focus?application=RuleDescription) | Ensures aria-hidden elements are not focusable nor contain focusable elements | Serious | cat.name-role-value, wcag2a, wcag412, TTv5, TT6.a, EN-301-549, EN-9.4.1.2 | failure, needs&nbsp;review | [6cfa84](https://act-rules.github.io/rules/6cfa84) |
| [aria-input-field-name](https://dequeuniversity.com/rules/axe/4.7/aria-input-field-name?application=RuleDescription) | Ensures every ARIA input field has an accessible name | Moderate, Serious | cat.aria, wcag2a, wcag412, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT | failure, needs&nbsp;review | [e086e5](https://act-rules.github.io/rules/e086e5) |
| [aria-meter-name](https://dequeuniversity.com/rules/axe/4.7/aria-meter-name?application=RuleDescription) | Ensures every ARIA meter node has an accessible name | Serious | cat.aria, wcag2a, wcag111, EN-301-549, EN-9.1.1.1 | failure, needs&nbsp;review | |
| [aria-progressbar-name](https://dequeuniversity.com/rules/axe/4.7/aria-progressbar-name?application=RuleDescription) | Ensures every ARIA progressbar node has an accessible name | Serious | cat.aria, wcag2a, wcag111, EN-301-549, EN-9.1.1.1 | failure, needs&nbsp;review | |
| [aria-prohibited-attr](https://dequeuniversity.com/rules/axe/4.7/aria-prohibited-attr?application=RuleDescription) | Ensures ARIA attributes are not prohibited for an element&apos;s role | Serious | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure, needs&nbsp;review | [5c01ea](https://act-rules.github.io/rules/5c01ea) |
| [aria-required-attr](https://dequeuniversity.com/rules/axe/4.7/aria-required-attr?application=RuleDescription) | Ensures elements with ARIA roles have all required ARIA attributes | Critical | cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2 | failure | [4e8ab6](https://act-rules.github.io/rules/4e8ab6) |
| [aria-required-children](https://dequeuniversity.com/rules/axe/4.7/aria-required-children?application=RuleDescription) | Ensures elements with an ARIA role that require child roles contain them | Critical | cat.aria, wcag2a, wcag131, EN-301-549, EN-9.1.3.1 | failure, needs&nbsp;review | [bc4a75](https://act-rules.github.io/rules/bc4a75), [ff89c9](https://act-rules.github.io/rules/ff89c9) |
| [aria-required-parent](https://dequeuniversity.com/rules/axe/4.7/aria-required-parent?application=RuleDescription) | Ensures elements with an ARIA role that require parent roles are contained by them | Critical | cat.aria, wcag2a, wcag131, EN-301-549, EN-9.1.3.1 | failure | [ff89c9](https://act-rules.github.io/rules/ff89c9) |
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/aria-allowed-attr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5c01ea"],
"metadata": {
"description": "Ensures ARIA attributes are allowed for an element's role",
"help": "Elements must only use allowed ARIA attributes"
"description": "Ensures an element's role supports its ARIA attributes",
"help": "Elements must only use supported ARIA attributes"
},
"all": ["aria-allowed-attr", "aria-conditional-attr"],
"any": [],
"none": ["aria-unsupported-attr", "aria-prohibited-attr"]
"none": ["aria-unsupported-attr"]
}
14 changes: 14 additions & 0 deletions lib/rules/aria-prohibited-attr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "aria-prohibited-attr",
"matches": "aria-allowed-attr-matches",
"tags": ["cat.aria", "wcag2a", "wcag412", "EN-301-549", "EN-9.4.1.2"],
"actIds": ["5c01ea"],
"impact": "serious",
"metadata": {
"description": "Ensures ARIA attributes are not prohibited for an element's role",
"help": "Elements must only use permitted ARIA attributes"
},
"all": [],
"any": [],
"none": ["aria-prohibited-attr"]
}
8 changes: 6 additions & 2 deletions locales/_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"help": "Active <area> elements must have alternate text"
},
"aria-allowed-attr": {
"description": "Ensures ARIA attributes are allowed for an element's role",
"help": "Elements must only use allowed ARIA attributes"
"description": "Ensures an element's role supports its ARIA attributes",
"help": "Elements must only use supported ARIA attributes"
},
"aria-allowed-role": {
"description": "Ensures role attribute has an appropriate value for the element",
Expand Down Expand Up @@ -49,6 +49,10 @@
"description": "Ensures every ARIA progressbar node has an accessible name",
"help": "ARIA progressbar nodes must have an accessible name"
},
"aria-prohibited-attr": {
"description": "Ensures ARIA attributes are not prohibited for an element's role",
"help": "Elements must only use permitted ARIA attributes"
},
"aria-required-attr": {
"description": "Ensures elements with ARIA roles have all required ARIA attributes",
"help": "Required ARIA attributes must be provided"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('./act-runner.js')({
id: '5c01ea',
title: 'ARIA state or property is permitted',
axeRules: ['aria-allowed-attr']
axeRules: ['aria-allowed-attr', 'aria-prohibited-attr']
});
7 changes: 5 additions & 2 deletions test/core/public/finish-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ describe('axe.finishRun', function () {
it('can report violations results', function (done) {
fixture.innerHTML = '<div aria-label="foo"></div>';
axe
.runPartial({ include: [['#fixture']] }, { runOnly: 'aria-allowed-attr' })
.runPartial(
{ include: [['#fixture']] },
{ runOnly: 'aria-prohibited-attr' }
)
.then(function (result) {
return axe.finishRun([result]);
})
Expand Down Expand Up @@ -186,7 +189,7 @@ describe('axe.finishRun', function () {
allResults.push(results);
return axe.runPartial(
{ include: [['#fail']] },
{ runOnly: 'aria-allowed-attr' }
{ runOnly: 'aria-prohibited-attr' }
);
})
.then(function (results) {
Expand Down
55 changes: 13 additions & 42 deletions test/integration/rules/aria-allowed-attr/failures.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,28 @@
<div role="link" aria-selected="true" id="fail2"></div>
<div role="row" aria-colcount="value" id="fail3"></div>
<div role="row" aria-rowcount="value" id="fail4"></div>
<div role="caption" aria-label="value" id="fail5"></div>
<div role="caption" aria-labelledby="value" id="fail6"></div>
<div role="code" aria-label="value" id="fail7"></div>
<div role="code" aria-labelledby="value" id="fail8"></div>
<div role="deletion" aria-label="value" id="fail9"></div>
<div role="deletion" aria-labelledby="value" id="fail10"></div>
<div role="emphasis" aria-label="value" id="fail11"></div>
<div role="emphasis" aria-labelledby="value" id="fail12"></div>
<div role="insertion" aria-label="value" id="fail13"></div>
<div role="insertion" aria-labelledby="value" id="fail14"></div>
<div role="paragraph" aria-label="value" id="fail15"></div>
<div role="paragraph" aria-labelledby="value" id="fail16"></div>
<div role="strong" aria-label="value" id="fail17"></div>
<div role="strong" aria-labelledby="value" id="fail18"></div>
<div role="subscript" aria-label="value" id="fail19"></div>
<div role="subscript" aria-labelledby="value" id="fail20"></div>
<div role="superscript" aria-label="value" id="fail21"></div>
<div role="superscript" aria-labelledby="value" id="fail22"></div>
<div aria-label="value" id="fail23"></div>
<div aria-labelledby="value" id="fail24"></div>
<!-- technically presentation and none roles do not allow aria-label and aria-labelledby, but since those are global attributes the presentation role conflict will not resolve the roles to none or presentation -->
<span aria-label="value" id="fail25"></span>
<strong aria-label="value" id="fail26"></strong>
<kbd aria-label="value" id="fail27"></kbd>
<abbr aria-label="value" id="fail28"></abbr>
<custom-elm aria-label="value" id="fail29"></custom-elm>

<audio
src="/test/assets/moon-speech.mp3"
controls
aria-orientation="horizontal"
id="fail30"
id="fail5"
></audio>
<div role="mark" aria-label="value" id="fail31"></div>
<div role="mark" aria-labelledby="value" id="fail32"></div>
<div role="suggestion" aria-label="value" id="fail33"></div>
<div role="suggestion" aria-labelledby="value" id="fail34"></div>

<div role="table">
<div role="row" aria-expanded="false" id="fail35"></div>
<div role="row" aria-posinset="1" id="fail36"></div>
<div role="row" aria-setsize="10" id="fail37"></div>
<div role="row" aria-level="1" id="fail38"></div>
<div role="row" aria-expanded="false" id="fail6"></div>
<div role="row" aria-posinset="1" id="fail7"></div>
<div role="row" aria-setsize="10" id="fail8"></div>
<div role="row" aria-level="1" id="fail9"></div>
</div>

<div role="grid">
<div role="row" aria-expanded="false" id="fail39"></div>
<div role="row" aria-posinset="1" id="fail40"></div>
<div role="row" aria-setsize="10" id="fail41"></div>
<div role="row" aria-level="1" id="fail42"></div>
<div role="row" aria-expanded="false" id="fail10"></div>
<div role="row" aria-posinset="1" id="fail11"></div>
<div role="row" aria-setsize="10" id="fail12"></div>
<div role="row" aria-level="1" id="fail13"></div>
</div>

<input type="checkbox" aria-checked="mixed" id="fail43" />
<input type="checkbox" aria-checked="true" id="fail44" />
<input type="checkbox" aria-checked="false" checked id="fail45" />
<input type="checkbox" aria-checked="mixed" id="fail14" />
<input type="checkbox" aria-checked="true" id="fail15" />
<input type="checkbox" aria-checked="false" checked id="fail16" />
31 changes: 1 addition & 30 deletions test/integration/rules/aria-allowed-attr/failures.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,6 @@
["#fail13"],
["#fail14"],
["#fail15"],
["#fail16"],
["#fail17"],
["#fail18"],
["#fail19"],
["#fail20"],
["#fail21"],
["#fail22"],
["#fail23"],
["#fail24"],
["#fail25"],
["#fail26"],
["#fail27"],
["#fail28"],
["#fail29"],
["#fail30"],
["#fail31"],
["#fail32"],
["#fail33"],
["#fail34"],
["#fail35"],
["#fail36"],
["#fail37"],
["#fail38"],
["#fail39"],
["#fail40"],
["#fail41"],
["#fail42"],
["#fail43"],
["#fail44"],
["#fail45"]
["#fail16"]
]
}
5 changes: 1 addition & 4 deletions test/integration/rules/aria-allowed-attr/incomplete.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<div id="incomplete0" aria-label="foo">Foo</div>
<div id="incomplete1" aria-labelledby="missing">Foo</div>
<my-custom-elm id="incomplete2" aria-expanded="true">Foo</my-custom-elm>
<div id="incomplete3" aria-label="foo" role="code">Foo</div>
<my-custom-elm id="incomplete1" aria-expanded="true">Foo</my-custom-elm>
7 changes: 1 addition & 6 deletions test/integration/rules/aria-allowed-attr/incomplete.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"description": "aria-allowed-attr incomplete tests",
"rule": "aria-allowed-attr",
"incomplete": [
["#incomplete0"],
["#incomplete1"],
["#incomplete2"],
["#incomplete3"]
]
"incomplete": [["#incomplete1"]]
}
6 changes: 6 additions & 0 deletions test/integration/rules/aria-allowed-attr/passes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2153,3 +2153,9 @@

<input type="checkbox" aria-checked="false" id="pass92" />
<input type="checkbox" aria-checked="true" checked id="pass93" />

<!-- Prohibited attributes fail in aria-prohibited-attr -->
<div role="caption" aria-label="value" id="pass94"></div>
<div role="caption" aria-labelledby="value" id="pass95"></div>
<div role="paragraph" aria-labelledby="value" id="pass96"></div>
<div role="strong" aria-label="value" id="pass97"></div>
6 changes: 5 additions & 1 deletion test/integration/rules/aria-allowed-attr/passes.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
["#treegrid"],
["#pass91"],
["#pass92"],
["#pass93"]
["#pass93"],
["#pass94"],
["#pass95"],
["#pass96"],
["#pass97"]
]
}
Loading

0 comments on commit 7b115d3

Please sign in to comment.