Skip to content
7 changes: 6 additions & 1 deletion lib/checks/aria/aria-valid-attr-value-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ export default function ariaValidAttrValueEvaluate(node, options, virtualNode) {
}

if (needsReview) {
this.data({ messageKey, needsReview });
this.data({
messageKey,
needsReview,
// a11y-rule-aria-valid-attr-value: emit reviewPayload
reviewPayload: { visualHelperData: { ariaAttribute: needsReview } }
});
return undefined;
}

Expand Down
1 change: 1 addition & 0 deletions lib/rules/aria-valid-attr-value.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"actIds": ["6a7281"],
"metadata": {
"defaultCategory": "aria-attributes",
"description": "Ensure all ARIA attributes have valid values",
"help": "ARIA attributes must conform to valid values",
"needsReviewConfidence": 49.99
Expand Down
1 change: 1 addition & 0 deletions lib/rules/bypass.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"actIds": ["cf77f2", "047fe0", "b40fd1", "3e12e1", "ye5d6e"],
"metadata": {
"defaultCategory": "bypass-blocks",
"description": "Ensure each page has at least one mechanism for a user to bypass navigation and jump straight to the content",
"help": "Page must have means to bypass repeated blocks",
"needsReviewConfidence": 49.99
Expand Down
1 change: 1 addition & 0 deletions lib/rules/css-orientation-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"actIds": ["b33eff"],
"metadata": {
"defaultCategory": "orientation",
"description": "Ensure content is not locked to any specific display orientation, and the content is operable in all display orientations",
"help": "CSS Media queries must not lock display orientation",
"violationConfidence": 90,
Expand Down
1 change: 1 addition & 0 deletions lib/rules/video-caption.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"actIds": ["eac66b"],
"metadata": {
"defaultCategory": "media-captions",
"description": "Ensure <video> elements have captions",
"help": "<video> elements must have captions",
"needsReviewConfidence": 49.99
Expand Down
46 changes: 46 additions & 0 deletions test/checks/aria/aria-valid-attr-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
describe('aria-valid-attr-value', () => {
'use strict';

const checkContext = axe.testUtils.MockCheckContext();
const checkSetup = axe.testUtils.checkSetup;
const checkEvaluate = axe.testUtils.getCheckEvaluate('aria-valid-attr-value');

afterEach(() => {
checkContext.reset();
});

it('emits the flagged aria-current attribute in reviewPayload.visualHelperData', () => {
const params = checkSetup(
'<div id="target" aria-current="active">Contents</div>'
);
assert.isUndefined(checkEvaluate.apply(checkContext, params));
assert.equal(checkContext._data.messageKey, 'ariaCurrent');
assert.equal(checkContext._data.needsReview, 'aria-current="active"');
assert.deepEqual(checkContext._data.reviewPayload, {
visualHelperData: { ariaAttribute: 'aria-current="active"' }
});
});

it('emits the flagged aria-labelledby attribute in reviewPayload.visualHelperData', () => {
const params = checkSetup(
'<div id="target" aria-labelledby="missing-id">Contents</div>'
);
assert.isUndefined(checkEvaluate.apply(checkContext, params));
assert.equal(
checkContext._data.needsReview,
'aria-labelledby="missing-id"'
);
assert.deepEqual(checkContext._data.reviewPayload, {
visualHelperData: { ariaAttribute: 'aria-labelledby="missing-id"' }
});
});

it('does not add a reviewPayload on the invalid-value (violation) path', () => {
const params = checkSetup(
'<div id="target" role="checkbox" aria-checked="foo">Contents</div>'
);
assert.isFalse(checkEvaluate.apply(checkContext, params));
assert.isArray(checkContext._data);
assert.notProperty(checkContext._data, 'reviewPayload');
});
});
36 changes: 28 additions & 8 deletions test/checks/aria/valid-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'controlsWithinPopup',
needsReview: 'aria-controls="test"'
needsReview: 'aria-controls="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-controls="test"' }
}
});
});

Expand Down Expand Up @@ -160,7 +163,10 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'noId',
needsReview: 'aria-describedby="test"'
needsReview: 'aria-describedby="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-describedby="test"' }
}
});
});

Expand All @@ -174,7 +180,10 @@ describe('aria-valid-attr-value', function () {
assert.isUndefined(validAttrValueCheck.apply(checkContext, params));
assert.deepEqual(checkContext._data, {
messageKey: 'noIdShadow',
needsReview: 'aria-describedby="test"'
needsReview: 'aria-describedby="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-describedby="test"' }
}
});
}
);
Expand All @@ -188,7 +197,10 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'noId',
needsReview: 'aria-labelledby="test"'
needsReview: 'aria-labelledby="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-labelledby="test"' }
}
});
});

Expand All @@ -202,7 +214,10 @@ describe('aria-valid-attr-value', function () {
assert.isUndefined(validAttrValueCheck.apply(checkContext, params));
assert.deepEqual(checkContext._data, {
messageKey: 'noIdShadow',
needsReview: 'aria-labelledby="test"'
needsReview: 'aria-labelledby="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-labelledby="test"' }
}
});
}
);
Expand Down Expand Up @@ -248,7 +263,8 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'empty',
needsReview: 'aria-checked'
needsReview: 'aria-checked',
reviewPayload: { visualHelperData: { ariaAttribute: 'aria-checked' } }
});
});

Expand All @@ -261,7 +277,8 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'empty',
needsReview: 'aria-checked'
needsReview: 'aria-checked',
reviewPayload: { visualHelperData: { ariaAttribute: 'aria-checked' } }
});
});

Expand Down Expand Up @@ -320,7 +337,10 @@ describe('aria-valid-attr-value', function () {
);
assert.deepEqual(checkContext._data, {
messageKey: 'idrefs',
needsReview: 'aria-owns="test"'
needsReview: 'aria-owns="test"',
reviewPayload: {
visualHelperData: { ariaAttribute: 'aria-owns="test"' }
}
});
});

Expand Down
Loading