From ca8177b929bfacf1d661f26e8a7247fc4cb53050 Mon Sep 17 00:00:00 2001 From: jkodu Date: Wed, 13 Mar 2019 10:51:18 +0000 Subject: [PATCH 1/4] fix: exclude iframe for html-has-lang rule --- lib/rules/html-has-lang.json | 1 + .../html-has-lang/html-has-lang-fail.html | 31 +++++++++++ .../full/html-has-lang/html-has-lang-fail.js | 37 +++++++++++++ ...-has-lang.html => html-has-lang-pass.html} | 12 +++-- .../full/html-has-lang/html-has-lang-pass.js | 36 +++++++++++++ .../full/html-has-lang/html-has-lang.js | 53 ------------------- 6 files changed, 114 insertions(+), 56 deletions(-) create mode 100644 test/integration/full/html-has-lang/html-has-lang-fail.html create mode 100644 test/integration/full/html-has-lang/html-has-lang-fail.js rename test/integration/full/html-has-lang/{html-has-lang.html => html-has-lang-pass.html} (79%) create mode 100644 test/integration/full/html-has-lang/html-has-lang-pass.js delete mode 100644 test/integration/full/html-has-lang/html-has-lang.js 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/html-has-lang/html-has-lang-fail.html b/test/integration/full/html-has-lang/html-has-lang-fail.html new file mode 100644 index 0000000000..8b57f39ed9 --- /dev/null +++ b/test/integration/full/html-has-lang/html-has-lang-fail.html @@ -0,0 +1,31 @@ + + + + + html-has-lang test + + + + + + + + + + + +
+ + + + + \ 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.html b/test/integration/full/html-has-lang/html-has-lang-pass.html similarity index 79% rename from test/integration/full/html-has-lang/html-has-lang.html rename to test/integration/full/html-has-lang/html-has-lang-pass.html index 4123f34533..321cff2b25 100644 --- a/test/integration/full/html-has-lang/html-has-lang.html +++ b/test/integration/full/html-has-lang/html-has-lang-pass.html @@ -1,5 +1,6 @@ + html-has-lang test @@ -16,10 +17,15 @@ var assert = chai.assert; + - +
- + - + + \ 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' - ]); - }); - }); -}); From d5261f683ce6e4e7cfbe9bb84f2b16658e94f0ef Mon Sep 17 00:00:00 2001 From: jkodu Date: Thu, 4 Apr 2019 11:39:40 +0100 Subject: [PATCH 2/4] test: updatee context test to not use html-has-lang --- test/integration/full/context/context.js | 3 ++- test/integration/full/context/frames/level1.html | 2 +- test/integration/full/context/frames/level2-a.html | 2 +- test/integration/full/context/frames/level2-b.html | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) 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 @@ - + From df8440fc5eaab28d6c9b241a367af5e4742b0fef Mon Sep 17 00:00:00 2001 From: jkodu Date: Thu, 11 Apr 2019 13:32:47 +0100 Subject: [PATCH 3/4] ftest: update --- test/integration/full/html-has-lang/html-has-lang-pass.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 321cff2b25..eb3f94b23b 100644 --- a/test/integration/full/html-has-lang/html-has-lang-pass.html +++ b/test/integration/full/html-has-lang/html-has-lang-pass.html @@ -21,8 +21,9 @@ +
From 74ab741d2a8db257a29470ed895600885ee28e61 Mon Sep 17 00:00:00 2001 From: jkodu Date: Mon, 15 Apr 2019 15:24:18 +0100 Subject: [PATCH 4/4] test: readd iframe with nno lang --- test/integration/full/html-has-lang/html-has-lang-fail.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/full/html-has-lang/html-has-lang-fail.html b/test/integration/full/html-has-lang/html-has-lang-fail.html index 8b57f39ed9..738cdd41d5 100644 --- a/test/integration/full/html-has-lang/html-has-lang-fail.html +++ b/test/integration/full/html-has-lang/html-has-lang-fail.html @@ -23,6 +23,8 @@ Note: This rule does not include `iframe` uses matches "window-is-top.js" --> + +