diff --git a/lib/checks/navigation/landmark.js b/lib/checks/navigation/landmark.js
index 6739a2bcc1..acd7aec4dd 100644
--- a/lib/checks/navigation/landmark.js
+++ b/lib/checks/navigation/landmark.js
@@ -1 +1 @@
-return node.getElementsByTagName('main').length > 0 || !!node.querySelector('[role="main"]') ;
\ No newline at end of file
+return axe.utils.querySelectorAll(virtualNode, 'main, [role="main"]').length > 0;
\ No newline at end of file
diff --git a/test/checks/navigation/landmark.js b/test/checks/navigation/landmark.js
index e2c2e94a0b..0d679d8913 100644
--- a/test/checks/navigation/landmark.js
+++ b/test/checks/navigation/landmark.js
@@ -2,24 +2,54 @@ describe('landmark', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
afterEach(function () {
fixture.innerHTML = '';
});
it('should return true when role=main is found', function () {
- fixture.innerHTML = '
';
- assert.isTrue(checks.landmark.evaluate(fixture));
+ var checkArgs = checkSetup('', '#fixture');
+ assert.isTrue(checks.landmark.evaluate.apply(null, checkArgs));
});
it('should return true when is found', function () {
- fixture.innerHTML = '';
- assert.isTrue(checks.landmark.evaluate(fixture));
+ var checkArgs = checkSetup('', '#fixture');
+ assert.isTrue(checks.landmark.evaluate.apply(null, checkArgs));
});
it('should otherwise return false', function () {
- fixture.innerHTML = '';
- assert.isFalse(checks.landmark.evaluate(fixture));
+ var checkArgs = checkSetup('', '#fixture');
+ assert.isFalse(checks.landmark.evaluate.apply(null, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should not automatically pass if there is a shadow tree', function () {
+ var node = document.createElement('div');
+ var shadow = node.attachShadow({ mode: 'open' });
+ shadow.innerHTML = '';
+ var checkArgs = checkSetup(node, '#fixture');
+
+ assert.isFalse(checks.landmark.evaluate.apply(null, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should find elements inside shadow trees', function () {
+ var node = document.createElement('div');
+ var shadow = node.attachShadow({ mode: 'open' });
+ shadow.innerHTML = '';
+ var checkArgs = checkSetup(node, '#fixture');
+
+ assert.isTrue(checks.landmark.evaluate.apply(null, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should find elements slotted in shadow trees', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '';
+ var shadow = node.attachShadow({ mode: 'open' });
+ shadow.innerHTML = '';
+ var checkArgs = checkSetup(node, '#fixture');
+
+ assert.isTrue(checks.landmark.evaluate.apply(null, checkArgs));
});
});