From cef54a0fd4156f7b1e6f6ba9cb36bde060a65622 Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Tue, 8 Sep 2020 08:37:05 -0600 Subject: [PATCH] feat(checks): deprecate role-none and role-presentation for presentational-role (#2503) * feat(checks): deprecate role-none and role-presentation for presentational-role * fix locales * Update lib/checks/shared/presentational-role.json Co-authored-by: Wilco Fiers * Update lib/checks/shared/presentational-role.json Co-authored-by: Wilco Fiers Co-authored-by: Wilco Fiers --- build/configure.js | 1 + .../shared/presentational-role-evaluate.js | 42 ++++++++++++ lib/checks/shared/presentational-role.json | 16 +++++ lib/checks/shared/role-none.json | 1 + lib/checks/shared/role-presentation.json | 1 + lib/core/base/metadata-function-map.js | 2 + lib/rules/button-name.json | 3 +- lib/rules/frame-title.json | 3 +- lib/rules/image-alt.json | 3 +- lib/rules/input-button-name.json | 3 +- lib/rules/label.json | 3 +- lib/rules/link-name.json | 2 - lib/rules/object-alt.json | 3 +- lib/rules/select-name.json | 3 +- test/checks/shared/presentational-role.js | 66 +++++++++++++++++++ .../rules/button-name/button-name.html | 6 ++ .../rules/button-name/button-name.json | 14 +++- .../rules/frame-title/frame-title.html | 25 +++++++ .../rules/frame-title/frame-title.json | 6 +- .../rules/image-alt/image-alt.html | 5 ++ .../rules/image-alt/image-alt.json | 6 +- .../input-button-name/input-button-name.html | 5 ++ .../input-button-name/input-button-name.json | 8 ++- .../rules/link-name/link-name.html | 3 + .../rules/link-name/link-name.json | 4 +- .../rules/object-alt/object-alt.html | 7 ++ .../rules/object-alt/object-alt.json | 14 +++- .../rules/select-name/select-name.html | 9 ++- .../rules/select-name/select-name.json | 9 ++- test/integration/virtual-rules/button-name.js | 42 ++++++++++-- .../virtual-rules/input-button-name.js | 38 +++++++++-- test/integration/virtual-rules/label.js | 42 ++++++++++-- test/integration/virtual-rules/link-name.js | 36 ---------- test/integration/virtual-rules/select-name.js | 42 ++++++++++-- 34 files changed, 392 insertions(+), 81 deletions(-) create mode 100644 lib/checks/shared/presentational-role-evaluate.js create mode 100644 lib/checks/shared/presentational-role.json create mode 100644 test/checks/shared/presentational-role.js diff --git a/build/configure.js b/build/configure.js index a5cf76c0ae..ed69c17d9a 100644 --- a/build/configure.js +++ b/build/configure.js @@ -87,6 +87,7 @@ function buildRules(grunt, options, commons, callback) { var tags = options.tags ? options.tags.split(/\s*,\s*/) : []; var rules = result.rules; var checks = result.checks; + parseChecks(checks); // Translate checks if (locale && locale.checks) { diff --git a/lib/checks/shared/presentational-role-evaluate.js b/lib/checks/shared/presentational-role-evaluate.js new file mode 100644 index 0000000000..ef76d0ee3a --- /dev/null +++ b/lib/checks/shared/presentational-role-evaluate.js @@ -0,0 +1,42 @@ +import { getExplicitRole, getRole } from '../../commons/aria'; +import { getGlobalAriaAttrs } from '../../commons/standards'; +import { isFocusable } from '../../commons/dom'; + +function presentationalRoleEvaluate(node, options, virtualNode) { + const role = getRole(virtualNode); + const explicitRole = getExplicitRole(virtualNode); + + if (['presentation', 'none'].includes(role)) { + this.data({ role }); + return true; + } + + // if the user didn't intended to make this presentational we fail + if (!['presentation', 'none'].includes(explicitRole)) { + return false; + } + + // user intended to make this presentational so inform them of + // problems caused by role conflict resolution + const hasGlobalAria = getGlobalAriaAttrs().some(attr => + virtualNode.hasAttr(attr) + ); + const focusable = isFocusable(virtualNode); + let messageKey; + + if (hasGlobalAria && !focusable) { + messageKey = 'globalAria'; + } else if (!hasGlobalAria && focusable) { + messageKey = 'focusable'; + } else { + messageKey = 'both'; + } + + this.data({ + messageKey, + role + }); + return false; +} + +export default presentationalRoleEvaluate; diff --git a/lib/checks/shared/presentational-role.json b/lib/checks/shared/presentational-role.json new file mode 100644 index 0000000000..7c35cefd19 --- /dev/null +++ b/lib/checks/shared/presentational-role.json @@ -0,0 +1,16 @@ +{ + "id": "presentational-role", + "evaluate": "presentational-role-evaluate", + "metadata": { + "impact": "minor", + "messages": { + "pass": "Element's default semantics were overriden with role=\"${data.role}\"", + "fail": { + "default": "Element's default semantics were not overridden with role=\"none\" or role=\"presentation\"", + "globalAria": "Element's role is not presentational because it has a global ARIA attribute", + "focusable": "Element's role is not presentational because it is focusable", + "both": "Element's role is not presentational because it has a global ARIA attribute and is focusable" + } + } + } +} diff --git a/lib/checks/shared/role-none.json b/lib/checks/shared/role-none.json index e2836ddd6a..3d411a9306 100644 --- a/lib/checks/shared/role-none.json +++ b/lib/checks/shared/role-none.json @@ -1,6 +1,7 @@ { "id": "role-none", "evaluate": "matches-definition-evaluate", + "deprecated": true, "options": { "matcher": { "attributes": { diff --git a/lib/checks/shared/role-presentation.json b/lib/checks/shared/role-presentation.json index 64dffecaa0..961765182a 100644 --- a/lib/checks/shared/role-presentation.json +++ b/lib/checks/shared/role-presentation.json @@ -1,6 +1,7 @@ { "id": "role-presentation", "evaluate": "matches-definition-evaluate", + "deprecated": true, "options": { "matcher": { "attributes": { diff --git a/lib/core/base/metadata-function-map.js b/lib/core/base/metadata-function-map.js index b55c64977f..ea04ab202c 100644 --- a/lib/core/base/metadata-function-map.js +++ b/lib/core/base/metadata-function-map.js @@ -69,6 +69,7 @@ import existsEvaluate from '../../checks/shared/exists-evaluate'; import hasAltEvaluate from '../../checks/shared/has-alt-evaluate'; import isOnScreenEvaluate from '../../checks/shared/is-on-screen-evaluate'; import nonEmptyIfPresentEvaluate from '../../checks/shared/non-empty-if-present-evaluate'; +import presentationalRoleEvaluate from '../../checks/shared/presentational-role-evaluate'; import svgNonEmptyTitleEvaluate from '../../checks/shared/svg-non-empty-title-evaluate'; // mobile @@ -231,6 +232,7 @@ const metadataFunctionMap = { 'has-alt-evaluate': hasAltEvaluate, 'is-on-screen-evaluate': isOnScreenEvaluate, 'non-empty-if-present-evaluate': nonEmptyIfPresentEvaluate, + 'presentational-role-evaluate': presentationalRoleEvaluate, 'svg-non-empty-title-evaluate': svgNonEmptyTitleEvaluate, // mobile diff --git a/lib/rules/button-name.json b/lib/rules/button-name.json index 12da4bef2a..14c59174f5 100644 --- a/lib/rules/button-name.json +++ b/lib/rules/button-name.json @@ -17,8 +17,7 @@ "button-has-visible-text", "aria-label", "aria-labelledby", - "role-presentation", - "role-none", + "presentational-role", "non-empty-title" ], "none": [] diff --git a/lib/rules/frame-title.json b/lib/rules/frame-title.json index 8b411ec2b7..c06b75a5da 100644 --- a/lib/rules/frame-title.json +++ b/lib/rules/frame-title.json @@ -18,8 +18,7 @@ "aria-label", "aria-labelledby", "non-empty-title", - "role-presentation", - "role-none" + "presentational-role" ], "none": [] } diff --git a/lib/rules/image-alt.json b/lib/rules/image-alt.json index 4738b3629a..d72ac8128f 100644 --- a/lib/rules/image-alt.json +++ b/lib/rules/image-alt.json @@ -18,8 +18,7 @@ "aria-label", "aria-labelledby", "non-empty-title", - "role-presentation", - "role-none" + "presentational-role" ], "none": ["alt-space-value"] } diff --git a/lib/rules/input-button-name.json b/lib/rules/input-button-name.json index 2e75cb6926..ccf0c65a4a 100644 --- a/lib/rules/input-button-name.json +++ b/lib/rules/input-button-name.json @@ -18,8 +18,7 @@ "non-empty-value", "aria-label", "aria-labelledby", - "role-presentation", - "role-none", + "presentational-role", "non-empty-title" ], "none": [] diff --git a/lib/rules/label.json b/lib/rules/label.json index 22999f272b..f8a606e554 100644 --- a/lib/rules/label.json +++ b/lib/rules/label.json @@ -22,8 +22,7 @@ "explicit-label", "non-empty-title", "non-empty-placeholder", - "role-none", - "role-presentation" + "presentational-role" ], "none": ["help-same-as-label", "hidden-explicit-label"] } diff --git a/lib/rules/link-name.json b/lib/rules/link-name.json index 99941d1a47..a972cae477 100644 --- a/lib/rules/link-name.json +++ b/lib/rules/link-name.json @@ -18,8 +18,6 @@ "has-visible-text", "aria-label", "aria-labelledby", - "role-presentation", - "role-none", "non-empty-title" ], "none": ["focusable-no-name"] diff --git a/lib/rules/object-alt.json b/lib/rules/object-alt.json index e1036832ac..c5502d4c42 100644 --- a/lib/rules/object-alt.json +++ b/lib/rules/object-alt.json @@ -18,8 +18,7 @@ "aria-label", "aria-labelledby", "non-empty-title", - "role-presentation", - "role-none" + "presentational-role" ], "none": [] } diff --git a/lib/rules/select-name.json b/lib/rules/select-name.json index e65fc81eb0..fdb349d652 100644 --- a/lib/rules/select-name.json +++ b/lib/rules/select-name.json @@ -20,8 +20,7 @@ "implicit-label", "explicit-label", "non-empty-title", - "role-none", - "role-presentation" + "presentational-role" ], "none": ["help-same-as-label", "hidden-explicit-label"] } diff --git a/test/checks/shared/presentational-role.js b/test/checks/shared/presentational-role.js new file mode 100644 index 0000000000..3593ab2a88 --- /dev/null +++ b/test/checks/shared/presentational-role.js @@ -0,0 +1,66 @@ +describe('presentational-role', function() { + 'use strict'; + + var fixture = document.getElementById('fixture'); + var queryFixture = axe.testUtils.queryFixture; + var checkEvaluate = axe.testUtils.getCheckEvaluate('presentational-role'); + var checkContext = axe.testUtils.MockCheckContext(); + + afterEach(function() { + fixture.innerHTML = ''; + checkContext.reset(); + }); + + it('should detect role="none" on the element', function() { + var vNode = queryFixture('
'); + + assert.isTrue(checkEvaluate.call(checkContext, null, null, vNode)); + assert.deepEqual(checkContext._data.role, 'none'); + }); + + it('should detect role="presentation" on the element', function() { + var vNode = queryFixture(''); + + assert.isTrue(checkEvaluate.call(checkContext, null, null, vNode)); + assert.deepEqual(checkContext._data.role, 'presentation'); + }); + + it('should return false when role !== none', function() { + var vNode = queryFixture('
'); + + assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode)); + }); + + it('should return false when there is no role attribute', function() { + var vNode = queryFixture('
'); + + assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode)); + }); + + it('should return false when the element is focusable', function() { + var vNode = queryFixture( + '' + ); + + assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode)); + assert.deepEqual(checkContext._data.messageKey, 'focusable'); + }); + + it('should return false when the element has global aria attributes', function() { + var vNode = queryFixture( + '' + ); + + assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode)); + assert.deepEqual(checkContext._data.messageKey, 'globalAria'); + }); + + it('should return false when the element has global aria attributes and is focusable', function() { + var vNode = queryFixture( + '' + ); + + assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode)); + assert.deepEqual(checkContext._data.messageKey, 'both'); + }); +}); diff --git a/test/integration/rules/button-name/button-name.html b/test/integration/rules/button-name/button-name.html index bb43145644..6e30089da4 100644 --- a/test/integration/rules/button-name/button-name.html +++ b/test/integration/rules/button-name/button-name.html @@ -13,3 +13,9 @@ + + + + + + diff --git a/test/integration/rules/button-name/button-name.json b/test/integration/rules/button-name/button-name.json index df76873b53..c0046ff163 100644 --- a/test/integration/rules/button-name/button-name.json +++ b/test/integration/rules/button-name/button-name.json @@ -7,7 +7,17 @@ ["#alempty"], ["#albmissing"], ["#albempty"], - ["#buttonvalue"] + ["#buttonvalue"], + ["#fail1"], + ["#fail2"] ], - "passes": [["#text"], ["#al"], ["#alb"], ["#combo"], ["#buttonTitle"]] + "passes": [ + ["#text"], + ["#al"], + ["#alb"], + ["#combo"], + ["#buttonTitle"], + ["#pass1"], + ["#pass2"] + ] } diff --git a/test/integration/rules/frame-title/frame-title.html b/test/integration/rules/frame-title/frame-title.html index 0a0ad460bc..e663ef8bc3 100644 --- a/test/integration/rules/frame-title/frame-title.html +++ b/test/integration/rules/frame-title/frame-title.html @@ -32,3 +32,28 @@ role="presentation" > + + + + + diff --git a/test/integration/rules/frame-title/frame-title.json b/test/integration/rules/frame-title/frame-title.json index 6fb5d22686..8b9b85ab90 100644 --- a/test/integration/rules/frame-title/frame-title.json +++ b/test/integration/rules/frame-title/frame-title.json @@ -4,7 +4,11 @@ "violations": [ ["#violation1"], ["#violation1", "#violation2"], - ["#violation3"] + ["#violation3"], + ["#violation4"], + ["#violation5"], + ["#violation6"], + ["#violation7"] ], "passes": [ ["#violation1", "#pass1"], diff --git a/test/integration/rules/image-alt/image-alt.html b/test/integration/rules/image-alt/image-alt.html index f543da13c7..ca136a6668 100644 --- a/test/integration/rules/image-alt/image-alt.html +++ b/test/integration/rules/image-alt/image-alt.html @@ -14,3 +14,8 @@  + + + + + diff --git a/test/integration/rules/image-alt/image-alt.json b/test/integration/rules/image-alt/image-alt.json index 807d5542cd..bb19138101 100644 --- a/test/integration/rules/image-alt/image-alt.json +++ b/test/integration/rules/image-alt/image-alt.json @@ -7,7 +7,11 @@ ["#violation3"], ["#violation4"], ["#violation5"], - ["#violation6"] + ["#violation6"], + ["#violation7"], + ["#violation8"], + ["#violation9"], + ["#violation10"] ], "passes": [ ["#pass1"], diff --git a/test/integration/rules/input-button-name/input-button-name.html b/test/integration/rules/input-button-name/input-button-name.html index 6fa0529d72..7830f20001 100644 --- a/test/integration/rules/input-button-name/input-button-name.html +++ b/test/integration/rules/input-button-name/input-button-name.html @@ -18,4 +18,9 @@ + + + + + diff --git a/test/integration/rules/input-button-name/input-button-name.json b/test/integration/rules/input-button-name/input-button-name.json index 9227368afd..5dbcf38083 100644 --- a/test/integration/rules/input-button-name/input-button-name.json +++ b/test/integration/rules/input-button-name/input-button-name.json @@ -7,7 +7,9 @@ ["#fail3"], ["#fail4"], ["#fail5"], - ["#fail6"] + ["#fail6"], + ["#fail7"], + ["#fail8"] ], "passes": [ ["#pass1"], @@ -20,6 +22,8 @@ ["#pass8"], ["#pass9"], ["#pass10"], - ["#pass11"] + ["#pass11"], + ["#pass12"], + ["#pass13"] ] } diff --git a/test/integration/rules/link-name/link-name.html b/test/integration/rules/link-name/link-name.html index 101f8379db..9e3f18f74a 100644 --- a/test/integration/rules/link-name/link-name.html +++ b/test/integration/rules/link-name/link-name.html @@ -40,3 +40,6 @@ Does not apply + + + diff --git a/test/integration/rules/link-name/link-name.json b/test/integration/rules/link-name/link-name.json index a6085c0443..4d331ba7c4 100644 --- a/test/integration/rules/link-name/link-name.json +++ b/test/integration/rules/link-name/link-name.json @@ -7,7 +7,9 @@ ["#violation3"], ["#violation4"], ["#violation5"], - ["#violation6"] + ["#violation6"], + ["#violation7"], + ["#violation8"] ], "passes": [ ["#pass1"], diff --git a/test/integration/rules/object-alt/object-alt.html b/test/integration/rules/object-alt/object-alt.html index fb949de7a9..dd244e1871 100644 --- a/test/integration/rules/object-alt/object-alt.html +++ b/test/integration/rules/object-alt/object-alt.html @@ -10,3 +10,10 @@

This object has no text.

+ + + + + + + diff --git a/test/integration/rules/object-alt/object-alt.json b/test/integration/rules/object-alt/object-alt.json index 007f3308f2..36514678c4 100644 --- a/test/integration/rules/object-alt/object-alt.json +++ b/test/integration/rules/object-alt/object-alt.json @@ -1,13 +1,23 @@ { "description": "object-alt tests", "rule": "object-alt", - "violations": [["#violation1"], ["#violation2"], ["#violation3"]], + "violations": [ + ["#violation1"], + ["#violation2"], + ["#violation3"], + ["#violation4"], + ["#violation5"], + ["#violation6"], + ["#violation7"] + ], "passes": [ ["#pass1"], ["#pass2"], ["#pass3"], ["#pass4"], ["#pass5"], - ["#pass6"] + ["#pass6"], + ["#pass7"], + ["#pass8"] ] } diff --git a/test/integration/rules/select-name/select-name.html b/test/integration/rules/select-name/select-name.html index d0d600cec5..6d15f2c55b 100644 --- a/test/integration/rules/select-name/select-name.html +++ b/test/integration/rules/select-name/select-name.html @@ -19,9 +19,6 @@ - - -
+ + + + + + diff --git a/test/integration/rules/select-name/select-name.json b/test/integration/rules/select-name/select-name.json index 4dbaf3257d..a6f4705694 100644 --- a/test/integration/rules/select-name/select-name.json +++ b/test/integration/rules/select-name/select-name.json @@ -1,7 +1,14 @@ { "description": "select-name test", "rule": "select-name", - "violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"]], + "violations": [ + ["#fail1"], + ["#fail2"], + ["#fail3"], + ["#fail4"], + ["#fail5"], + ["#fail6"] + ], "passes": [ ["#pass1"], ["#pass2"], diff --git a/test/integration/virtual-rules/button-name.js b/test/integration/virtual-rules/button-name.js index ede4f4b4d5..9b175f67cb 100644 --- a/test/integration/virtual-rules/button-name.js +++ b/test/integration/virtual-rules/button-name.js @@ -38,11 +38,12 @@ describe('button-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=presentation', function() { + it('should pass for role=presentation when disabled', function() { var results = axe.runVirtualRule('button-name', { nodeName: 'button', attributes: { - role: 'presentation' + role: 'presentation', + disabled: true } }); @@ -51,11 +52,12 @@ describe('button-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=none', function() { + it('should pass for role=none when disabled', function() { var results = axe.runVirtualRule('button-name', { nodeName: 'button', attributes: { - role: 'none' + role: 'none', + disabled: true } }); @@ -153,4 +155,36 @@ describe('button-name', function() { assert.lengthOf(results.violations, 1); assert.lengthOf(results.incomplete, 0); }); + + it('should fail for role=presentation', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'button', + attributes: { + role: 'presentation' + } + }); + node.children = []; + + var results = axe.runVirtualRule('button-name', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); + + it('should fail for role=none', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'button', + attributes: { + role: 'none' + } + }); + node.children = []; + + var results = axe.runVirtualRule('button-name', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); }); diff --git a/test/integration/virtual-rules/input-button-name.js b/test/integration/virtual-rules/input-button-name.js index 889c4938a5..0ed0fc02b7 100644 --- a/test/integration/virtual-rules/input-button-name.js +++ b/test/integration/virtual-rules/input-button-name.js @@ -68,12 +68,13 @@ describe('input-button-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=presentation', function() { + it('should pass for role=presentation when disabled', function() { var results = axe.runVirtualRule('input-button-name', { nodeName: 'input', attributes: { type: 'button', - role: 'presentation' + role: 'presentation', + disabled: true } }); @@ -82,12 +83,13 @@ describe('input-button-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=none', function() { + it('should pass for role=none when disabled', function() { var results = axe.runVirtualRule('input-button-name', { nodeName: 'input', attributes: { type: 'button', - role: 'none' + role: 'none', + disabled: true } }); @@ -164,4 +166,32 @@ describe('input-button-name', function() { assert.lengthOf(results.violations, 1); assert.lengthOf(results.incomplete, 0); }); + + it('should pass for role=presentation', function() { + var results = axe.runVirtualRule('input-button-name', { + nodeName: 'input', + attributes: { + type: 'button', + role: 'presentation' + } + }); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); + + it('should pass for role=none', function() { + var results = axe.runVirtualRule('input-button-name', { + nodeName: 'input', + attributes: { + type: 'button', + role: 'none' + } + }); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); }); diff --git a/test/integration/virtual-rules/label.js b/test/integration/virtual-rules/label.js index 16893b4b79..ba20e858eb 100644 --- a/test/integration/virtual-rules/label.js +++ b/test/integration/virtual-rules/label.js @@ -102,11 +102,12 @@ describe('label', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=presentation', function() { + it('should pass for role=presentation when disabled', function() { var results = axe.runVirtualRule('label', { nodeName: 'input', attributes: { - role: 'presentation' + role: 'presentation', + disabled: true } }); @@ -115,11 +116,12 @@ describe('label', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=none', function() { + it('should pass for role=none when disabled', function() { var results = axe.runVirtualRule('label', { nodeName: 'input', attributes: { - role: 'none' + role: 'none', + disabled: true } }); @@ -188,4 +190,36 @@ describe('label', function() { assert.lengthOf(results.violations, 1); assert.lengthOf(results.incomplete, 0); }); + + it('should fail for role=presentation', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'input', + attributes: { + role: 'presentation' + } + }); + node.parent = null; + + var results = axe.runVirtualRule('label', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); + + it('should fail for role=none', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'input', + attributes: { + role: 'presentation' + } + }); + node.parent = null; + + var results = axe.runVirtualRule('label', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); }); diff --git a/test/integration/virtual-rules/link-name.js b/test/integration/virtual-rules/link-name.js index 3da3fdb20d..b2dadc5647 100644 --- a/test/integration/virtual-rules/link-name.js +++ b/test/integration/virtual-rules/link-name.js @@ -31,42 +31,6 @@ describe('link-name', function() { assert.lengthOf(results.incomplete, 1); }); - it('should pass for role=presentation', function() { - var node = new axe.SerialVirtualNode({ - nodeName: 'a', - attributes: { - href: '/foo.html', - tabindex: '-1', - role: 'presentation' - } - }); - node.children = []; - - var results = axe.runVirtualRule('link-name', node); - - assert.lengthOf(results.passes, 1); - assert.lengthOf(results.violations, 0); - assert.lengthOf(results.incomplete, 0); - }); - - it('should pass for role=none', function() { - var node = new axe.SerialVirtualNode({ - nodeName: 'a', - attributes: { - href: '/foo.html', - tabindex: '-1', - role: 'none' - } - }); - node.children = []; - - var results = axe.runVirtualRule('link-name', node); - - assert.lengthOf(results.passes, 1); - assert.lengthOf(results.violations, 0); - assert.lengthOf(results.incomplete, 0); - }); - it('should pass for visible text content', function() { var node = new axe.SerialVirtualNode({ nodeName: 'span', diff --git a/test/integration/virtual-rules/select-name.js b/test/integration/virtual-rules/select-name.js index 7505978235..652566a9f3 100644 --- a/test/integration/virtual-rules/select-name.js +++ b/test/integration/virtual-rules/select-name.js @@ -75,11 +75,12 @@ describe('select-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=presentation', function() { + it('should pass for role=presentation when disabled', function() { var results = axe.runVirtualRule('select-name', { nodeName: 'select', attributes: { - role: 'presentation' + role: 'presentation', + disabled: true } }); @@ -88,11 +89,12 @@ describe('select-name', function() { assert.lengthOf(results.incomplete, 0); }); - it('should pass for role=none', function() { + it('should pass for role=none when disabled', function() { var results = axe.runVirtualRule('select-name', { nodeName: 'select', attributes: { - role: 'none' + role: 'none', + disabled: true } }); @@ -161,4 +163,36 @@ describe('select-name', function() { assert.lengthOf(results.violations, 1); assert.lengthOf(results.incomplete, 0); }); + + it('should pass for role=presentation', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'select', + attributes: { + role: 'presentation' + } + }); + node.parent = null; + + var results = axe.runVirtualRule('select-name', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); + + it('should pass for role=none', function() { + var node = new axe.SerialVirtualNode({ + nodeName: 'select', + attributes: { + role: 'none' + } + }); + node.parent = null; + + var results = axe.runVirtualRule('select-name', node); + + assert.lengthOf(results.passes, 0); + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.incomplete, 0); + }); });