Skip to content
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

fix(checks/unsupportedrole): support unsupported dpub and fallback roles, add role to message #3395

Merged
merged 53 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2467b3a
refactor(checks/navigation): improve `internal-link-present-evaluate`
dan-tripp Aug 20, 2021
bde2684
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 2, 2021
9f996bc
test commit 1
dan-tripp Sep 3, 2021
c011d2c
test commit 2
dan-tripp Sep 3, 2021
a386166
test commit 3
dan-tripp Sep 3, 2021
428e015
Merge branch 'dan-test-branch-1' into develop
dan-tripp Sep 3, 2021
31b19a3
Revert "Merge branch 'dan-test-branch-1' into develop"
dan-tripp Sep 3, 2021
ac32146
Revert "test commit 1"
dan-tripp Sep 3, 2021
6e389a1
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 10, 2021
739f035
Merge branch 'dequelabs:develop' into develop
dan-tripp Sep 15, 2021
30f0e01
fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-inte…
dan-tripp Sep 24, 2021
9caefd7
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 1, 2021
41fd8e2
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 3, 2021
7aeac06
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 8, 2021
c37be71
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 9, 2021
2896478
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 14, 2021
02cfb18
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 22, 2021
f2ae004
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 23, 2021
b687d45
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 27, 2021
0729846
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 28, 2021
b257208
Merge branch 'dequelabs:develop' into develop
dan-tripp Oct 31, 2021
6c5a5ed
Merge branch 'develop' of https://github.com/dequelabs/axe-core into …
dan-tripp Nov 27, 2021
0d92cf2
Merge pull request #4 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 27, 2021
5baa656
Merge branch 'dequelabs:develop' into develop
dan-tripp Nov 27, 2021
40025ad
work in progress
dan-tripp Nov 28, 2021
f12379e
Merge pull request #5 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 28, 2021
92dc637
work in progress
dan-tripp Nov 28, 2021
2666eeb
Merge pull request #6 from dan-tripp/dequelabs-develop-2
dan-tripp Nov 28, 2021
7e692b4
Merge branch 'dequelabs:develop' into develop
dan-tripp Nov 30, 2021
6d8a0f6
test commit 1
dan-tripp Sep 3, 2021
9373c58
Revert "test commit 1"
dan-tripp Sep 3, 2021
0a4fd4f
fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-inte…
dan-tripp Sep 24, 2021
d50b56a
work in progress
dan-tripp Nov 28, 2021
74d5656
work in progress
dan-tripp Nov 28, 2021
54329dd
fix whitespace
dan-tripp Nov 30, 2021
499768f
add new case to test test/checks/keyboard/no-focusable-content.js
dan-tripp Nov 30, 2021
8c32f03
change "disabled" test case in test/checks/keyboard/no-focusable-cont…
dan-tripp Nov 30, 2021
ed9da3e
Merge branch 'develop' into dequelabs-develop-2
dan-tripp Dec 5, 2021
99000d4
Merge branch 'dequelabs-develop-2' into develop
dan-tripp Dec 5, 2021
7ad504f
Merge branch 'develop' of https://github.com/dan-tripp/axe-core into …
dan-tripp Dec 5, 2021
e69a0f5
Merge branch 'dequelabs:develop' into develop
dan-tripp Dec 5, 2021
d6a5573
fix merge problem
dan-tripp Dec 5, 2021
9a61752
Merge remote-tracking branch 'remotes/origin/develop' into develop
dan-tripp Dec 5, 2021
02c91ed
Merge branch 'dequelabs:develop' into develop
dan-tripp Jan 22, 2022
18a7ac6
Merge branch 'dequelabs:develop' into develop
dan-tripp Feb 12, 2022
7c40451
Merge branch 'dequelabs:develop' into develop
dan-tripp Feb 21, 2022
e0e5580
Merge branch 'dequelabs:develop' into develop
dan-tripp Feb 26, 2022
e2ae194
fix(rules): unsupportedrole check bugs
dan-tripp Feb 21, 2022
3096c92
lint fix
dan-tripp Feb 21, 2022
9df22d1
add assertion on checkContext._data to unit tests
dan-tripp Feb 27, 2022
c284508
refactor(checks/unsupportedrole): change this.data from using array t…
dan-tripp Feb 27, 2022
840a581
Revert "refactor(checks/unsupportedrole): change this.data from using…
dan-tripp Feb 27, 2022
4bbd863
refactor(checks/unsupportedrole): change this.data from using array t…
dan-tripp Feb 27, 2022
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
8 changes: 7 additions & 1 deletion lib/checks/aria/unsupportedrole-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { isUnsupportedRole, getRole } from '../../commons/aria';
* @return {Boolean} True if the elements semantic role is unsupported. False otherwise.
*/
function unsupportedroleEvaluate(node, options, virtualNode) {
return isUnsupportedRole(getRole(virtualNode));
const role = getRole(virtualNode, { dpub: true, fallback: true });
const isUnsupported = isUnsupportedRole(role);
if (isUnsupported) {
this.data(role);
}
return isUnsupported;

}

export default unsupportedroleEvaluate;
2 changes: 1 addition & 1 deletion lib/checks/aria/unsupportedrole.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"impact": "critical",
"messages": {
"pass": "ARIA role is supported",
"fail": "The role used is not widely supported in screen readers and assistive technologies: ${data.values}"
"fail": "The role used is not widely supported in screen readers and assistive technologies: ${data}"
}
}
}
67 changes: 58 additions & 9 deletions test/checks/aria/unsupportedrole.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
describe('unsupportedrole', function() {
'use strict';

var queryFixture = axe.testUtils.queryFixture;
var checkContext = axe.testUtils.MockCheckContext();
var checkSetup = axe.testUtils.checkSetup;
var check = checks.unsupportedrole;
afterEach(function() {
checkContext.reset();
axe.reset();
});

it('should return true if applied to an unsupported role', function() {
axe.configure({
Expand All @@ -15,22 +21,65 @@ describe('unsupportedrole', function() {
}
});

var vNode = queryFixture(
var params = checkSetup(
'<div id="target" role="mccheddarton">Contents</div>'
);
assert.isTrue(checks.unsupportedrole.evaluate(null, null, vNode));
assert.isTrue(check.evaluate.apply(checkContext, params));
assert.deepEqual(checkContext._data, "mccheddarton");
});

it('should return false if applied to a supported role', function() {
var vNode = queryFixture('<div id="target" role="alert">Contents</div>');
assert.isFalse(checks.unsupportedrole.evaluate(null, null, vNode));
var params = checkSetup('<div id="target" role="alert">Contents</div>');
assert.isFalse(check.evaluate.apply(checkContext, params));
assert.isNull(checkContext._data);

var vNode = queryFixture('<button id="target">Contents</button>');
assert.isFalse(checks.unsupportedrole.evaluate(null, null, vNode));
var params = checkSetup('<button id="target">Contents</button>');
assert.isFalse(check.evaluate.apply(checkContext, params));
assert.isNull(checkContext._data);
});

it('should return false if applied to an invalid role', function() {
var vNode = queryFixture('<input id="target" role="foo">');
assert.isFalse(checks.unsupportedrole.evaluate(null, null, vNode));
var params = checkSetup('<input id="target" role="foo">');
assert.isFalse(check.evaluate.apply(checkContext, params));
assert.isNull(checkContext._data);
});

it('should return true if applied to an unsupported dpub role', function() {
axe.configure({
standards: {
ariaRoles: {
'doc-abstract': {
type: 'section',
unsupported: true
}
}
}
});

var params = checkSetup(
'<div id="target" role="doc-abstract">Contents</div>'
);
assert.isTrue(check.evaluate.apply(checkContext, params));
assert.deepEqual(checkContext._data, "doc-abstract");
});

it('should return true if applied to an unsupported fallback role', function() {
axe.configure({
standards: {
ariaRoles: {
alert: {
type: 'widget',
unsupported: true
}
}
}
});

var params = checkSetup(
'<div id="target" role="unsupported alert">Contents</div>'
);
assert.isTrue(check.evaluate.apply(checkContext, params));
assert.deepEqual(checkContext._data, "alert");
});

});