' +
+ if (shadowSupport) {
+ it('should match a descendant of an element across a shadow boundary', function () {
+ fixture.innerHTML = '
' +
+ '
';
+
+ var shadowRoot = document.getElementById('parent').attachShadow({ mode: 'open' });
+ shadowRoot.innerHTML = '
Text
';
+
+ var shadowTarget = fixture.firstChild.shadowRoot.querySelector('#shadowTarget');
+ var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
+ assert.isTrue(rule.matches(shadowTarget, axe.utils.getNodeFromTree(tree[0], shadowTarget)));
+ });
+
+ it('should look at the correct root node when looking up an explicit label and disabled input', function () {
+ fixture.innerHTML = '
'+
+ '' +
'
';
- var shadowRoot = document.getElementById('parent').attachShadow({ mode: 'open' });
- shadowRoot.innerHTML = '
Text
';
+ var shadowRoot = document.getElementById('parent').attachShadow({ mode: 'open' });
+ shadowRoot.innerHTML = '
' +
+ '' +
+ '' +
+ '
';
- var shadowTarget = fixture.firstChild.shadowRoot.querySelector('#shadowTarget');
- var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
- assert.isTrue(rule.matches(shadowTarget, axe.utils.getNodeFromTree(tree[0], shadowTarget)));
- });
+ var shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel');
+ var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
+ assert.isFalse(rule.matches(shadowLabel, axe.utils.getNodeFromTree(tree[0], shadowLabel)));
+ });
+
+ it('should look at the correct root node when looking up implicit label and disabled input', function () {
+ fixture.innerHTML = '
'+
+ '' +
+ '
';
+
+ var shadowRoot = document.getElementById('parent').attachShadow({ mode: 'open' });
+ shadowRoot.innerHTML = '
' +
+ '' +
+ '
';
+
+ var shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel');
+ var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
+ assert.isFalse(rule.matches(shadowLabel, axe.utils.getNodeFromTree(tree[0], shadowLabel)));
+ });
+
+ it('should look at the correct root node for a disabled control\'s label associated w/ aria-labelledby', function () {
+ fixture.innerHTML = '
'+
+ '' +
+ '
';
+
+ var shadowRoot = document.getElementById('parent').attachShadow({ mode: 'open' });
+ shadowRoot.innerHTML = '
' +
+ '' +
+ '' +
+ '
';
+
+ var shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel');
+ var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
+ assert.isFalse(rule.matches(shadowLabel, axe.utils.getNodeFromTree(tree[0], shadowLabel)));
+ });
+
+ it('should look at the children of a virtual node for overlap', function () {
+ fixture.innerHTML = '
';
+
+ var shadowRoot = document.getElementById('firstChild').attachShadow({ mode: 'open' });
+ shadowRoot.innerHTML = 'Some text' +
+ '
Other text
';
+
+ var firstChild = fixture.querySelector('#firstChild');
+ var tree = axe._tree = axe.utils.getFlattenedTree(fixture);
+ assert.isTrue(rule.matches(firstChild, axe.utils.getNodeFromTree(tree[0], firstChild)));
+ });
+ }
});