diff --git a/lib/core/utils/get-selector.js b/lib/core/utils/get-selector.js
index ab64f6fa54..afe6dcd183 100644
--- a/lib/core/utils/get-selector.js
+++ b/lib/core/utils/get-selector.js
@@ -306,8 +306,8 @@ function getThreeLeastCommonFeatures(elm, selectorData) {
return a.species !== b.species && a.species === 'class'
? -1
: a.species === b.species
- ? 0
- : 1;
+ ? 0
+ : 1;
});
}
}
diff --git a/lib/rules/html-has-lang.json b/lib/rules/html-has-lang.json
index 9fa967c003..cc28f6e577 100644
--- a/lib/rules/html-has-lang.json
+++ b/lib/rules/html-has-lang.json
@@ -1,6 +1,7 @@
{
"id": "html-has-lang",
"selector": "html",
+ "matches": "window-is-top.js",
"tags": ["cat.language", "wcag2a", "wcag311"],
"metadata": {
"description": "Ensures every HTML document has a lang attribute",
diff --git a/test/integration/full/context/context.js b/test/integration/full/context/context.js
index e680564789..5776851373 100644
--- a/test/integration/full/context/context.js
+++ b/test/integration/full/context/context.js
@@ -1,7 +1,7 @@
describe('context test', function() {
'use strict';
- var config = { runOnly: { type: 'rule', values: ['html-has-lang'] } };
+ var config = { runOnly: { type: 'rule', values: ['html-lang-valid'] } };
var shadowSupported = axe.testUtils.shadowSupport.v1;
before(function(done) {
@@ -321,6 +321,7 @@ describe('context test', function() {
});
});
});
+
describe('direct include', function() {
it('should find the frames given a context object', function(done) {
axe.run({ include: [['#myframe']] }, config, function(err, results) {
diff --git a/test/integration/full/context/frames/level1.html b/test/integration/full/context/frames/level1.html
index 2a0e14e44b..fe48132563 100644
--- a/test/integration/full/context/frames/level1.html
+++ b/test/integration/full/context/frames/level1.html
@@ -1,5 +1,5 @@
-
+
diff --git a/test/integration/full/context/frames/level2-a.html b/test/integration/full/context/frames/level2-a.html
index a8aad540ba..9a051ee942 100644
--- a/test/integration/full/context/frames/level2-a.html
+++ b/test/integration/full/context/frames/level2-a.html
@@ -1,5 +1,5 @@
-
+
diff --git a/test/integration/full/context/frames/level2-b.html b/test/integration/full/context/frames/level2-b.html
index 7d2ca7ec4a..a31c8a6da0 100644
--- a/test/integration/full/context/frames/level2-b.html
+++ b/test/integration/full/context/frames/level2-b.html
@@ -1,5 +1,5 @@
-
+
diff --git a/test/integration/full/html-has-lang/html-has-lang.html b/test/integration/full/html-has-lang/html-has-lang-fail.html
similarity index 77%
rename from test/integration/full/html-has-lang/html-has-lang.html
rename to test/integration/full/html-has-lang/html-has-lang-fail.html
index 4123f34533..738cdd41d5 100644
--- a/test/integration/full/html-has-lang/html-has-lang.html
+++ b/test/integration/full/html-has-lang/html-has-lang-fail.html
@@ -1,5 +1,6 @@
-
+
+
html-has-lang test
@@ -16,10 +17,17 @@
var assert = chai.assert;
+
+
+
-
+
-
+
+
\ No newline at end of file
diff --git a/test/integration/full/html-has-lang/html-has-lang-fail.js b/test/integration/full/html-has-lang/html-has-lang-fail.js
new file mode 100644
index 0000000000..fe3ead2ef3
--- /dev/null
+++ b/test/integration/full/html-has-lang/html-has-lang-fail.js
@@ -0,0 +1,37 @@
+/**
+ * Note:
+ * This rule does not include `iframe` uses matches "window-is-top.js"
+ */
+describe('html-has-lang fail test', function() {
+ 'use strict';
+
+ var results;
+ before(function(done) {
+ axe.testUtils.awaitNestedLoad(function() {
+ axe.run(
+ { runOnly: { type: 'rule', values: ['html-has-lang'] } },
+ function(err, r) {
+ assert.isNull(err);
+ results = r;
+ done();
+ }
+ );
+ });
+ });
+
+ describe('violations', function() {
+ it('should find 1 violations', function() {
+ assert.lengthOf(results.violations, 1);
+ });
+
+ it('should find #fail1', function() {
+ assert.deepEqual(results.violations[0].nodes[0].target, ['#fail1']);
+ });
+ });
+
+ describe('passes', function() {
+ it('should find 0 passes', function() {
+ assert.lengthOf(results.passes, 0);
+ });
+ });
+});
diff --git a/test/integration/full/html-has-lang/html-has-lang-pass.html b/test/integration/full/html-has-lang/html-has-lang-pass.html
new file mode 100644
index 0000000000..eb3f94b23b
--- /dev/null
+++ b/test/integration/full/html-has-lang/html-has-lang-pass.html
@@ -0,0 +1,32 @@
+
+
+
+
+ html-has-lang test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/integration/full/html-has-lang/html-has-lang-pass.js b/test/integration/full/html-has-lang/html-has-lang-pass.js
new file mode 100644
index 0000000000..fba87e4778
--- /dev/null
+++ b/test/integration/full/html-has-lang/html-has-lang-pass.js
@@ -0,0 +1,36 @@
+/**
+ * Note:
+ * This rule does not include `iframe` uses matches "window-is-top.js"
+ */
+describe('html-has-lang pass test', function() {
+ 'use strict';
+ var results;
+ before(function(done) {
+ axe.testUtils.awaitNestedLoad(function() {
+ axe.run(
+ { runOnly: { type: 'rule', values: ['html-has-lang'] } },
+ function(err, r) {
+ assert.isNull(err);
+ results = r;
+ done();
+ }
+ );
+ });
+ });
+
+ describe('violations', function() {
+ it('should find 0 violations', function() {
+ assert.lengthOf(results.violations, 0);
+ });
+ });
+
+ describe('passes', function() {
+ it('should find 1', function() {
+ assert.lengthOf(results.passes[0].nodes, 1);
+ });
+
+ it('should find #pass1', function() {
+ assert.deepEqual(results.passes[0].nodes[0].target, ['#pass1']);
+ });
+ });
+});
diff --git a/test/integration/full/html-has-lang/html-has-lang.js b/test/integration/full/html-has-lang/html-has-lang.js
deleted file mode 100644
index 8f881e3c04..0000000000
--- a/test/integration/full/html-has-lang/html-has-lang.js
+++ /dev/null
@@ -1,53 +0,0 @@
-describe('html-has-lang test', function() {
- 'use strict';
- var results;
- before(function(done) {
- axe.testUtils.awaitNestedLoad(function() {
- axe.run(
- { runOnly: { type: 'rule', values: ['html-has-lang'] } },
- function(err, r) {
- assert.isNull(err);
- results = r;
- done();
- }
- );
- });
- });
-
- describe('violations', function() {
- it('should find 2', function() {
- assert.lengthOf(results.violations[0].nodes, 2);
- });
- it('should find first level iframe', function() {
- assert.deepEqual(results.violations[0].nodes[0].target, [
- '#frame1',
- '#violation1'
- ]);
- });
- it('should find second level iframe', function() {
- assert.deepEqual(results.violations[0].nodes[1].target, [
- '#frame1',
- '#frame2',
- '#violation2'
- ]);
- });
- });
-
- describe('passes', function() {
- it('should find 2', function() {
- assert.lengthOf(results.passes[0].nodes, 2);
- });
-
- it('should find #pass1', function() {
- assert.deepEqual(results.passes[0].nodes[0].target, ['#pass1']);
- });
-
- it('should find #pass2', function() {
- assert.deepEqual(results.passes[0].nodes[1].target, [
- '#frame1',
- '#frame3',
- '#pass2'
- ]);
- });
- });
-});