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

feat(list,listitem): do not allow group as allowed parent or child #3784

Merged
merged 2 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions lib/standards/aria-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const ariaRoles = {
},
list: {
type: 'structure',
requiredOwned: ['group', 'listitem'],
requiredOwned: ['listitem'],
allowedAttrs: ['aria-expanded'],
superclassRole: ['section']
},
Expand All @@ -298,7 +298,7 @@ const ariaRoles = {
},
listitem: {
type: 'structure',
requiredContext: ['list', 'group'],
requiredContext: ['list'],
allowedAttrs: [
'aria-level',
'aria-posinset',
Expand Down
7 changes: 5 additions & 2 deletions test/act-rules/act-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const testCaseJsonPath = path.resolve(
const addr = `http://localhost:${serverPort}/WAI/content-assets/wcag-act-rules/`;
const testCaseJson = require(testCaseJsonPath);

module.exports = ({ id, title, axeRules }) => {
module.exports = ({ id, title, axeRules, skipTests = [] }) => {
describe(`${title} (${id})`, function () {
let driver, server;
const testcases = testCaseJson.testcases.filter(
Expand Down Expand Up @@ -64,7 +64,10 @@ module.exports = ({ id, title, axeRules }) => {
});

testcases.forEach(testcase => {
const shouldRun = testcase.relativePath.match(/\.(xhtml|html?)$/);
const shouldRun =
testcase.relativePath.match(/\.(xhtml|html?)$/) &&
!skipTests.includes(testcase.testcaseId);

(shouldRun ? it : xit)(testcase.testcaseTitle, async () => {
await driver.get(`${addr}/${testcase.relativePath}`);

Expand Down
3 changes: 2 additions & 1 deletion test/act-rules/aria-required-owned-element-bc4a75.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require('./act-runner.js')({
id: 'bc4a75',
title: 'ARIA required owned elements',
axeRules: ['aria-required-children']
axeRules: ['aria-required-children'],
skipTests: ['52c725e462af074a3559cf4bf4d4dd2386168938']
});
8 changes: 4 additions & 4 deletions test/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('aria-required-children', function () {
.getCheckEvaluate('aria-required-children')
.apply(checkContext, params)
);
assert.deepEqual(checkContext._data, ['group', 'listitem']);
assert.deepEqual(checkContext._data, ['listitem']);
});

(shadowSupported ? it : xit)(
Expand All @@ -43,7 +43,7 @@ describe('aria-required-children', function () {
.getCheckEvaluate('aria-required-children')
.apply(checkContext, params)
);
assert.deepEqual(checkContext._data, ['group', 'listitem']);
assert.deepEqual(checkContext._data, ['listitem']);
}
);

Expand Down Expand Up @@ -138,7 +138,7 @@ describe('aria-required-children', function () {
.apply(checkContext, params)
);

assert.deepEqual(checkContext._data, ['group', 'listitem']);
assert.deepEqual(checkContext._data, ['listitem']);
});

it('should fail when list has intermediate child with role that is not a required role', function () {
Expand Down Expand Up @@ -361,7 +361,7 @@ describe('aria-required-children', function () {

it('should fail when role does not allow group', function () {
var params = checkSetup(
'<div role="table" id="target"><ul role="group"><li role="row">Option</li></ul></div>'
'<div role="list" id="target"><ul role="group"><li role="listitem">Item</li></ul></div>'
);
assert.isFalse(
axe.testUtils
Expand Down
16 changes: 8 additions & 8 deletions test/checks/aria/required-parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('aria-required-parent', function () {
.getCheckEvaluate('aria-required-parent')
.apply(checkContext, params)
);
assert.deepEqual(checkContext._data, ['list', 'group']);
assert.deepEqual(checkContext._data, ['list']);
});

(shadowSupported ? it : xit)(
Expand All @@ -44,7 +44,7 @@ describe('aria-required-parent', function () {
.getCheckEvaluate('aria-required-parent')
.apply(checkContext, params)
);
assert.deepEqual(checkContext._data, ['list', 'group']);
assert.deepEqual(checkContext._data, ['list']);
}
);

Expand All @@ -70,7 +70,7 @@ describe('aria-required-parent', function () {
.getCheckEvaluate('aria-required-parent')
.apply(checkContext, params)
);
assert.deepEqual(checkContext._data, ['list', 'group']);
assert.deepEqual(checkContext._data, ['list']);
});

it('should pass when required parent is present in an aria-owns context', function () {
Expand Down Expand Up @@ -165,13 +165,13 @@ describe('aria-required-parent', function () {
describe('group with ownGroupRoles', function () {
it('should pass when the role and grand parent role is in ownGroupRoles', function () {
var params = checkSetup(
'<div role="list">' +
'<div role="listitem">' +
'<div role="tree">' +
'<div role="treeitem">' +
'<div role="group">' +
'<div role="listitem" id="target">' +
'<div role="treeitem" id="target">' +
'</div></div></div></div>',
{
ownGroupRoles: ['listitem']
ownGroupRoles: ['treeitem']
}
);

Expand Down Expand Up @@ -245,7 +245,7 @@ describe('aria-required-parent', function () {

it('should pass for multiple group and presentational roles', function () {
var params = checkSetup(
'<div role="list"><div role="none"><div role="group"><div role="none"><div role="group"><div role="listitem" id="target">Nothing here.</div></div></div></div></div></div>'
'<div role="tree"><div role="none"><div role="group"><div role="none"><div role="group"><div role="treeitem" id="target">Nothing here.</div></div></div></div></div></div>'
);
assert.isTrue(
axe.testUtils
Expand Down