-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test showing axe runs under strict csp (#1744)
* test: add test showing axe runs under strict csp * use meta tag directly * check for errors
- Loading branch information
1 parent
a0f3eef
commit 94950c7
Showing
2 changed files
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<script id="check-phantomjs"> | ||
// phantomjs requires running in non-strict csp | ||
if (!window.PHANTOMJS) { | ||
var thisScript = document.getElementById('check-phantomjs'); | ||
var meta = document.createElement('meta'); | ||
meta.setAttribute('http-equiv', 'Content-Security-Policy'); | ||
meta.setAttribute( | ||
'content', | ||
"script-src 'nonce-4AEemGb0xJptoIGFP3Nd'; style-src 'nonce-4AEemGb0xJptoIGFP3Nd'" | ||
); | ||
document.head.appendChild(meta); | ||
} | ||
</script> | ||
<link | ||
nonce="4AEemGb0xJptoIGFP3Nd" | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<script | ||
nonce="4AEemGb0xJptoIGFP3Nd" | ||
src="/node_modules/mocha/mocha.js" | ||
></script> | ||
<script | ||
nonce="4AEemGb0xJptoIGFP3Nd" | ||
src="/node_modules/chai/chai.js" | ||
></script> | ||
<script nonce="4AEemGb0xJptoIGFP3Nd" src="/axe.js"></script> | ||
<script nonce="4AEemGb0xJptoIGFP3Nd"> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script nonce="4AEemGb0xJptoIGFP3Nd" src="/test/testutils.js"></script> | ||
<script nonce="4AEemGb0xJptoIGFP3Nd" src="strict-csp.js"></script> | ||
<script | ||
nonce="4AEemGb0xJptoIGFP3Nd" | ||
src="/test/integration/adapter.js" | ||
></script> | ||
</body> | ||
</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,17 @@ | ||
// phantomjs requires running in non-strict csp | ||
(window.PHANTOMJS ? describe.skip : describe)('strict-csp', function() { | ||
'use strict'; | ||
|
||
it('should parse without errors', function() { | ||
assert.isDefined(window.axe), 'axe is not defined'; | ||
assert.isDefined(window.axe.run, 'axe.run is not defined'); | ||
}); | ||
|
||
it('should run without errors', function(done) { | ||
axe.run(function(err, results) { | ||
assert.isNull(err); | ||
assert.isDefined(results); | ||
done(); | ||
}); | ||
}); | ||
}); |