-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlandmark-has-body-context.js
More file actions
47 lines (38 loc) · 1.7 KB
/
landmark-has-body-context.js
File metadata and controls
47 lines (38 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
describe('landmark-has-body-context', function () {
'use strict';
const fixtureSetup = axe.testUtils.fixtureSetup;
let rule;
const shadowSupport = axe.testUtils.shadowSupport.v1;
beforeEach(function () {
rule = axe.utils.getRule('landmark-banner-is-top-level');
});
it('returns true for elements with a role', function () {
fixtureSetup('<main><footer role="contentinfo"></footer></main>');
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0];
assert.isTrue(rule.matches(vNode.actualNode, vNode));
});
it('returns true for elements not contained in a landmark', function () {
fixtureSetup('<div><footer role="contentinfo"></footer></div>');
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0];
assert.isTrue(rule.matches(vNode.actualNode, vNode));
});
it('returns false for elements contained in a landmark', function () {
fixtureSetup('<main><footer></footer></main>');
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0];
assert.isFalse(rule.matches(vNode.actualNode, vNode));
});
(shadowSupport ? it : xit)(
'returns false for elements contained in a landmark in a shadow DOM tree',
function () {
// Safari has a bug in 12.0 that throws an error when calling
// attachShadow on <main>
// @see https://bugs.webkit.org/show_bug.cgi?id=197726
const article = document.createElement('article');
const shadow = article.attachShadow({ mode: 'open' });
shadow.innerHTML = '<footer></footer>';
fixtureSetup(article);
const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0];
assert.isFalse(rule.matches(vNode.actualNode, vNode));
}
);
});