-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-rule): Add meta-refresh-no-exceptions (wcag2aaa, disabled by…
… default) (#3530) * feat(new-rule): Add meta-refresh-no-exceptions (wcag2aaa, disabled by default) * Add virtual rule tests
- Loading branch information
1 parent
5beb6c3
commit 27031a8
Showing
15 changed files
with
341 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"id": "meta-refresh-no-exceptions", | ||
"evaluate": "meta-refresh-evaluate", | ||
"options": { | ||
"minDelay": 0, | ||
"maxDelay": false | ||
}, | ||
"metadata": { | ||
"impact": "minor", | ||
"messages": { | ||
"pass": "<meta> tag does not immediately refresh the page", | ||
"fail": "<meta> tag forces timed refresh of page" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"id": "meta-refresh-no-exceptions", | ||
"selector": "meta[http-equiv=\"refresh\"][content]", | ||
"excludeHidden": false, | ||
"enabled": false, | ||
"tags": [ | ||
"cat.time-and-media", | ||
"wcag2aaa", | ||
"wcag224", | ||
"wcag325" | ||
], | ||
"actIds": ["bisz58"], | ||
"metadata": { | ||
"description": "Ensures <meta http-equiv=\"refresh\"> is not used for delayed refresh", | ||
"help": "Delayed refresh must not be used" | ||
}, | ||
"all": [], | ||
"any": ["meta-refresh-no-exceptions"], | ||
"none": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/integration/full/meta-refresh-no-exceptions/meta-refresh-fail.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe('meta-refresh-no-exceptions fail', function() { | ||
'use strict'; | ||
|
||
it('should be a violation', function(done) { | ||
axe.run({ runOnly: 'meta-refresh-no-exceptions' }, function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 1, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 0, 'inapplicable'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
test/integration/full/meta-refresh-no-exceptions/meta-refresh-fail1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Meta-refresh-no-exceptions fail 1</title> | ||
<meta http-equiv="refresh" content="10 https://deque.com/"> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="meta-refresh-fail.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
test/integration/full/meta-refresh-no-exceptions/meta-refresh-fail2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Meta-refresh-no-exceptions fail 2</title> | ||
<!-- Greater than 20 hour is still not allowed at Level AAA --> | ||
<meta http-equiv="refresh" content="90000; https://deque.com/"> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="meta-refresh-fail.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
test/integration/full/meta-refresh-no-exceptions/meta-refresh-inapplicable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe('meta-refresh-no-exceptions inapplicable', function() { | ||
'use strict'; | ||
|
||
it('should be inapplicable', function(done) { | ||
axe.run({ runOnly: 'meta-refresh-no-exceptions' }, function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 1, 'inapplicable'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
}); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/integration/full/meta-refresh-no-exceptions/meta-refresh-inapplicable1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Meta-refresh-no-exceptions inapplicable 1</title> | ||
<!-- no content attribute --> | ||
<meta http-equiv="refresh"> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="meta-refresh-inapplicable.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
test/integration/full/meta-refresh-no-exceptions/meta-refresh-inapplicable2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Meta-refresh-no-exceptions inapplicable 2</title> | ||
<!-- no http-equiv="refresh" attribute --> | ||
<meta http-equiv="something-else" content="5"> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="meta-refresh-inapplicable.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
test/integration/full/meta-refresh-no-exceptions/meta-refresh-pass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe('meta-refresh-no-exceptions pass', function() { | ||
'use strict'; | ||
|
||
it('should pass', function(done) { | ||
axe.run({ runOnly: 'meta-refresh-no-exceptions' }, function(err, results) { | ||
console.log(results) | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 1, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
}); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/integration/full/meta-refresh-no-exceptions/meta-refresh-pass1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Meta-refresh-no-exceptions pass 1</title> | ||
<!-- "-10" is not valid, this will be ignored --> | ||
<meta http-equiv="refresh" content="-10 https://deque.com/"> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="meta-refresh-pass.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |
85 changes: 85 additions & 0 deletions
85
test/integration/virtual-rules/meta-refresh-no-exceptions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
describe('meta-refresh-no-exceptions virtual-rule', function() { | ||
it('should be inapplicable for missing content', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 0); | ||
assert.lengthOf(results.inapplicable, 1); | ||
}); | ||
|
||
it('should pass for content=0', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh', | ||
content: '0' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 1); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should pass for content=0 and url', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh', | ||
content: '0;url=http://example.com/' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 1); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should fail for content other than 0', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh', | ||
content: '300' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should fail for content other than 0 and url', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh', | ||
content: '20;url=http://example.com/' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should fail for content greater than 20 hours', function() { | ||
var results = axe.runVirtualRule('meta-refresh-no-exceptions', { | ||
nodeName: 'meta', | ||
attributes: { | ||
'http-equiv': 'refresh', | ||
content: '72001' | ||
} | ||
}); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters