';
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -281,6 +281,7 @@ describe('color.getBackgroundColor', function() {
'' +
'
Text
' +
'';
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -304,7 +305,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -326,7 +327,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -348,7 +349,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -370,7 +371,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -392,7 +393,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -414,7 +415,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -433,7 +434,7 @@ describe('color.getBackgroundColor', function() {
var bgNodes = [];
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.equal(actual.red, expected.red);
@@ -450,7 +451,7 @@ describe('color.getBackgroundColor', function() {
'';
var target = fixture.querySelector('#target');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(0, 0, 0, 1);
assert.equal(actual.red, expected.red);
@@ -468,7 +469,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(255, 255, 255, 1);
assert.equal(actual.red, expected.red);
@@ -494,7 +495,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target'),
parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(243, 243, 243, 1);
assert.equal(actual.red, expected.red);
@@ -516,7 +517,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(255, 255, 255, 1);
@@ -537,7 +538,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var parent = fixture.querySelector('#parent');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes);
var expected = new axe.commons.color.Color(255, 255, 255, 1);
@@ -560,7 +561,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var shifted = fixture.querySelector('#shifted');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, bgNodes, false);
var expected = new axe.commons.color.Color(0, 0, 0, 1);
@@ -586,7 +587,7 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false);
assert.isNull(outcome);
assert.equal(axe.commons.color.incompleteData.get('bgColor'), 'bgImage');
@@ -606,66 +607,19 @@ describe('color.getBackgroundColor', function() {
var target = fixture.querySelector('#target');
var bgNodes = [];
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var outcome = axe.commons.color.getBackgroundColor(target, bgNodes, false);
assert.isNull(outcome);
assert.equal(axe.commons.color.incompleteData.get('bgColor'), 'imgNode');
});
- it('does not change the scroll when scroll is disabled', function() {
- fixture.innerHTML =
- '
' +
- '
' +
- '
';
- var targetEl = fixture.querySelector('#target');
- var bgNodes = [];
- window.scroll(0, 0);
-
- axe.testUtils.flatTreeSetup(fixture.firstChild);
- axe.commons.color.getBackgroundColor(targetEl, bgNodes, true);
-
- assert.equal(window.pageYOffset, 0);
- });
-
- it('scrolls into view when scroll is enabled', function() {
- fixture.innerHTML =
- '
' +
- '
' +
- '
';
- var targetEl = fixture.querySelector('#target');
- var bgNodes = [];
- window.scroll(0, 0);
-
- axe.testUtils.flatTreeSetup(fixture.firstChild);
- axe.commons.color.getBackgroundColor(targetEl, bgNodes, false);
-
- assert.notEqual(window.pageYOffset, 0);
- });
-
- it('scrolls horizontally into view when scroll is enabled', function() {
- fixture.innerHTML =
- '
long text to test scrolling
';
- var targetEl = fixture.querySelector('#target');
- var bgNodes = [];
- window.scroll(100, 0);
-
- axe.testUtils.flatTreeSetup(fixture.firstChild);
- axe.commons.color.getBackgroundColor(targetEl, bgNodes, false);
-
- assert.equal(document.documentElement.scrollLeft, 0);
- });
-
it('returns elements with negative z-index', function() {
fixture.innerHTML =
'' +
'
Some text
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -687,7 +641,7 @@ describe('color.getBackgroundColor', function() {
var orig = document.body.style.background;
document.body.style.background = '#FFF';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -708,7 +662,7 @@ describe('color.getBackgroundColor', function() {
var orig = document.body.style.background;
document.body.style.background = '#F00';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -727,7 +681,7 @@ describe('color.getBackgroundColor', function() {
var orig = document.body.style.background;
document.body.style.background = '#F00';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -746,7 +700,7 @@ describe('color.getBackgroundColor', function() {
var orig = document.documentElement.style.background;
document.documentElement.style.background = '#0F0';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(
document.getElementById('target'),
[]
@@ -760,46 +714,20 @@ describe('color.getBackgroundColor', function() {
assert.closeTo(actual.alpha, expected.alpha, 0.1);
});
- it('avoids scrolling elements with overflow:hidden', function() {
- fixture.innerHTML =
- '
' +
- '
' +
- '
' +
- '
Some text here
' +
- '' +
- '
' +
- '
' +
- '
R_20
' +
- '
';
-
- // This shouldn't cause a scroll
- var target1 = document.getElementById('tgt1');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
- axe.commons.color.getBackgroundColor(target1, []);
-
- // Otherwise this would not be on the black bg anymore:
- var target2 = document.getElementById('tgt2');
- var actual = axe.commons.color.getBackgroundColor(target2, []);
-
- assert.closeTo(actual.red, 0, 0.5);
- assert.closeTo(actual.green, 0, 0.5);
- assert.closeTo(actual.blue, 0, 0.5);
- assert.closeTo(actual.alpha, 1, 0.1);
- });
-
- it('does returns null for inline elements that do not fit the viewport', function() {
+ it('should return background color for inline elements that do not fit the viewport', function() {
var html = '';
- for (var i = 0; i < 1000; i++) {
+ for (var i = 0; i < 300; i++) {
html += 'foo ';
}
fixture.innerHTML = '' + html + '';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
- var outcome = axe.commons.color.getBackgroundColor(fixture.firstChild, []);
- assert.isNull(outcome);
- assert.equal(
- axe.commons.color.incompleteData.get('bgColor'),
- 'outsideViewport'
- );
+ axe.testUtils.flatTreeSetup(fixture);
+ var actual = axe.commons.color.getBackgroundColor(fixture, []);
+ var expected = new axe.commons.color.Color(255, 255, 255, 1);
+
+ assert.closeTo(actual.red, expected.red, 0.5);
+ assert.closeTo(actual.green, expected.green, 0.5);
+ assert.closeTo(actual.blue, expected.blue, 0.5);
+ assert.closeTo(actual.alpha, expected.alpha, 0.1);
});
it('should return the body bgColor when content does not overlap', function() {
@@ -807,7 +735,7 @@ describe('color.getBackgroundColor', function() {
'
' +
'
Text' +
'
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getBackgroundColor(target, []);
@@ -827,6 +755,7 @@ describe('color.getBackgroundColor', function() {
document.body.style.height = '1px';
document.body.style.background = '#000';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getBackgroundColor(target, []);
@@ -851,6 +780,7 @@ describe('color.getBackgroundColor', function() {
document.body.style.background = '#0f0';
document.documentElement.style.background = '#f00';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getBackgroundColor(target, []);
@@ -872,7 +802,7 @@ describe('color.getBackgroundColor', function() {
'
' +
'Text' +
'
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var actual = axe.commons.color.getBackgroundColor(target, []);
@@ -892,7 +822,7 @@ describe('color.getBackgroundColor', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'Text';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var actual = axe.commons.color.getBackgroundColor(target, [], false);
@@ -914,7 +844,7 @@ describe('color.getBackgroundColor', function() {
'';
var target = shadow.querySelector('#target');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, []);
var expected = new axe.commons.color.Color(0, 0, 0, 1);
@@ -934,10 +864,10 @@ describe('color.getBackgroundColor', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
Text
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(target, []);
assert.equal(actual.red, 255);
assert.equal(actual.green, 255);
@@ -958,7 +888,7 @@ describe('color.getBackgroundColor', function() {
shadow1.innerHTML =
'';
var elm2 = document.querySelector('#elm2');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(elm2, []);
assert.equal(actual.red, 0);
assert.equal(actual.blue, 0);
@@ -987,7 +917,7 @@ describe('color.getBackgroundColor', function() {
'
';
var elm3 = shadow2.querySelector('#elm3');
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var actual = axe.commons.color.getBackgroundColor(elm3, []);
assert.closeTo(actual.red, 128, 2);
assert.closeTo(actual.blue, 128, 2);
@@ -1005,7 +935,7 @@ describe('color.getBackgroundColor', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
Text More text
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var actual = axe.commons.color.getBackgroundColor(target, []);
assert.equal(actual.red, 0);
@@ -1024,7 +954,7 @@ describe('color.getBackgroundColor', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
Text More text
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var actual = axe.commons.color.getBackgroundColor(target, []);
assert.isNull(actual);
@@ -1039,7 +969,7 @@ describe('color.getBackgroundColor', function() {
div.innerHTML = 'Link';
var shadow = div.attachShadow({ mode: 'open' });
shadow.innerHTML = '
';
- axe.testUtils.flatTreeSetup(fixture.firstChild);
+ axe.testUtils.flatTreeSetup(fixture);
var linkElm = div.querySelector('a');
var actual = axe.commons.color.getBackgroundColor(linkElm, []);
assert.equal(actual.red, 0);
diff --git a/test/commons/color/get-foreground-color.js b/test/commons/color/get-foreground-color.js
index d96c580388..e11da14546 100644
--- a/test/commons/color/get-foreground-color.js
+++ b/test/commons/color/get-foreground-color.js
@@ -19,6 +19,7 @@ describe('color.getForegroundColor', function() {
' background-color: rgba(0, 128, 0, 0.5);">' +
'This is my text' +
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(32, 32, 64, 1);
@@ -35,6 +36,7 @@ describe('color.getForegroundColor', function() {
' background-color: green; opacity: 0.5;">' +
'This is my text' +
'';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(32, 32, 64, 1);
@@ -51,6 +53,7 @@ describe('color.getForegroundColor', function() {
'
' +
'This is my text' +
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(119.5, 119.5, 119.5, 1);
@@ -68,6 +71,7 @@ describe('color.getForegroundColor', function() {
'
' +
'This is my text' +
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(119.5, 119.5, 119.5, 1);
@@ -83,6 +87,7 @@ describe('color.getForegroundColor', function() {
'background-color: #800000; background-image: url(image.png);">' +
'
' +
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
assert.equal(axe.commons.color.incompleteData.get('fgColor'), 'bgImage');
@@ -94,6 +99,7 @@ describe('color.getForegroundColor', function() {
'
' +
'
' +
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = fixture.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(0, 0, 128, 1);
@@ -123,6 +129,7 @@ describe('color.getForegroundColor', function() {
shadow.innerHTML =
'';
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#target');
var actual = axe.commons.color.getForegroundColor(target);
var expected = new axe.commons.color.Color(0, 0, 128, 1);
diff --git a/test/commons/dom/get-element-stack.js b/test/commons/dom/get-element-stack.js
index 52adc87cce..f2321900f4 100644
--- a/test/commons/dom/get-element-stack.js
+++ b/test/commons/dom/get-element-stack.js
@@ -3,7 +3,18 @@ describe('dom.getElementStack', function() {
var fixture = document.getElementById('fixture');
var getElementStack = axe.commons.dom.getElementStack;
- var queryFixture = axe.testUtils.queryFixture;
+ var getClientElementStack = axe.commons.dom.getClientElementStack;
+ var shadowSupported = axe.testUtils.shadowSupport.v1;
+
+ function mapToIDs(stack) {
+ return stack
+ .map(function(node) {
+ return node.id;
+ })
+ .filter(function(id) {
+ return !!id;
+ });
+ }
afterEach(function() {
fixture.innerHTML = '';
@@ -11,343 +22,459 @@ describe('dom.getElementStack', function() {
describe('stack order', function() {
it('should return stack in DOM order of non-positioned elements', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'' +
- '
';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = fixture.querySelector('#target');
+ var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['1', '4', 'target', '5', '3', '2']);
});
it('should correctly order children of position elements without z-index', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'
' +
- '' +
- '
'
- );
- var stack = getElementStack(vNode).map(function(vNode) {
- return vNode.actualNode.id;
- });
+ '' +
+ '';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = fixture.querySelector('#target');
+ var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '1', 'fixture']);
});
it('should correctly order children of position elements with z-index', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'
' +
- '' +
- '
'
- );
- var stack = getElementStack(vNode).map(function(vNode) {
- return vNode.actualNode.id;
- });
+ '' +
+ '';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = fixture.querySelector('#target');
+ var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '1', 'fixture']);
});
it('should handle modals on top of the stack', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'' +
- '
' +
+ '';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = fixture.querySelector('#target');
+ var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '3', '2', '1', 'fixture']);
});
it('should not return elements that do not fully cover the target', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'
' +
+ '';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = fixture.querySelector('#target');
+ var stack = mapToIDs(getElementStack(target));
assert.deepEqual(stack, ['target', '1', 'fixture']);
});
it('should not return parent elements that do not fully cover the target', function() {
- var vNode = queryFixture(
+ fixture.innerHTML =
'
'
+ );
+ assert.isTrue(
+ axe.commons.dom.visuallyContains(
+ target.actualNode,
+ target.parent.actualNode
+ )
+ );
});
it('should return true when element is inline', function() {
// result depends on the display property of the element
- fixture.innerHTML =
- '';
- var target = fixture.querySelector('#target');
- assert.isTrue(axe.commons.dom.visuallyContains(target, target.parentNode));
+ var target = queryFixture(
+ ''
+ );
+ assert.isTrue(
+ axe.commons.dom.visuallyContains(
+ target.actualNode,
+ target.parent.actualNode
+ )
+ );
});
it('should return false when element is partially contained', function() {
- fixture.innerHTML =
+ var target = queryFixture(
'
' +
- '
Text more text
';
- var target = fixture.querySelector('#target');
- var result = axe.commons.dom.visuallyContains(target, target.parentNode);
+ '
Text more text
'
+ );
+ var result = axe.commons.dom.visuallyContains(
+ target.actualNode,
+ target.parent.actualNode
+ );
assert.isFalse(result);
});
+ it('should return true when element is contained by scroll region', function() {
+ var target = queryFixture(
+ '
' +
+ '
' +
+ '' +
+ '
Text
'
+ );
+ var parent = fixture.querySelector('#parent');
+ var result = axe.commons.dom.visuallyContains(target.actualNode, parent);
+ assert.isTrue(result);
+ });
+
(shadowSupported ? it : xit)(
'should return true when element is visually contained across shadow boundary',
function() {
@@ -91,12 +138,32 @@ describe('dom.visuallyContains', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'';
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#target');
var result = axe.commons.dom.visuallyContains(target, container);
assert.isTrue(result);
}
);
+ (shadowSupported ? it : xit)(
+ 'should return true when element is contained by scroll region across shadow boundary',
+ function() {
+ fixture.innerHTML =
+ '
' +
+ '
' +
+ '' +
+ '
';
+ var container = fixture.querySelector('#container');
+ var shadow = container.attachShadow({ mode: 'open' });
+ shadow.innerHTML = '
Text
';
+ axe.testUtils.flatTreeSetup(fixture);
+ var target = shadow.querySelector('#target');
+ var parent = fixture.querySelector('#parent');
+ var result = axe.commons.dom.visuallyContains(target, parent);
+ assert.isTrue(result);
+ }
+ );
+
(shadowSupported ? it : xit)(
'should return false when element is not visually contained across shadow boundary',
function() {
@@ -106,6 +173,7 @@ describe('dom.visuallyContains', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
';
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#target');
var result = axe.commons.dom.visuallyContains(target, container);
assert.isFalse(result);
@@ -121,7 +189,7 @@ describe('dom.visuallyContains', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
Text
';
-
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var result = axe.commons.dom.visuallyContains(target, container);
assert.isFalse(result);
@@ -137,7 +205,7 @@ describe('dom.visuallyContains', function() {
var shadow = container.attachShadow({ mode: 'open' });
shadow.innerHTML =
'
Text
';
-
+ axe.testUtils.flatTreeSetup(fixture);
var target = shadow.querySelector('#shadowTarget');
var result = axe.commons.dom.visuallyContains(target, container);
assert.isFalse(result);