Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions test/checks/label/label-content-name-mismatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe('label-content-name-mismatch tests', () => {
const html = axe.testUtils.html;

const queryFixture = axe.testUtils.queryFixture;
const queryShadowFixture = axe.testUtils.queryShadowFixture;
const check = checks['label-content-name-mismatch'];
const options = undefined;

Expand Down Expand Up @@ -224,4 +225,35 @@ describe('label-content-name-mismatch tests', () => {
assert.isFalse(actual);
}
);

it('returns true when a visually-hidden child is excluded from the visible text', () => {
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
const vNode = queryFixture(
'<a id="target" href="#" aria-label="deque are great">' +
'deque <span style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0px,0px,0px,0px);">labs</span> are great' +
'</a>'
);
const actual = check.evaluate(vNode.actualNode, options, vNode);
assert.isTrue(actual);
});

it('returns false when the visible text alone is not contained in the accessible name', () => {
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
const vNode = queryFixture(
'<a id="target" href="#" aria-label="deque are great">' +
'deque <span style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0px,0px,0px,0px);">labs</span> are truly great' +
'</a>'
);
const actual = check.evaluate(vNode.actualNode, options, vNode);
assert.isFalse(actual);
});

it('returns true when a visually-hidden child inside shadow DOM is excluded from the visible text', () => {
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
const vNode = queryShadowFixture(
'<div id="shadow"></div>',
'<a id="target" href="#" aria-label="deque are great">' +
'deque <span style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0px,0px,0px,0px);">labs</span> are great' +
'</a>'
);
const actual = check.evaluate(vNode.actualNode, options, vNode);
assert.isTrue(actual);
});
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
</svg>
Hello World
</a>
<a id="pass10" href="#" aria-label="deque are great">
Comment thread
chutchins25 marked this conversation as resolved.
deque
<span
style="
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0px, 0px, 0px, 0px);
"
>labs</span
>
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
are great
</a>
Comment thread
chutchins25 marked this conversation as resolved.

<!-- Fail -->
<div id="fail1" role="link" aria-label="OK">Next</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
["#pass6"],
["#pass7"],
["#pass8"],
["#pass9"]
["#pass9"],
["#pass10"]
],
"incomplete": [
["#incomplete1"],
Expand Down
Loading