-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(color-contrast): improve speed and accuracy of code blocks with s…
…yntax highlighting (#2003) * fix(color-contrast): improve speed and accuracy of code block with syntax highlighting * add integration test * figure out why firefox fails on opacity, but just in circle (works in localhost) * try again * fix tests * comment
- Loading branch information
Showing
6 changed files
with
205 additions
and
35 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
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
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,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Test Page</title> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="/node_modules/mocha/mocha.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism.min.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-okaidia.min.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> | ||
<script src="/test/integration/no-ui-reporter.js"></script> | ||
<style></style> | ||
</head> | ||
|
||
<body> | ||
<div id="fixture"> | ||
<pre> | ||
<code class="language-html"><!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Test Page</title> | ||
<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> | ||
<script src="/test/integration/no-ui-reporter.js"></script> | ||
<style></style> | ||
</head> | ||
|
||
<body> | ||
<pre> | ||
<code> | ||
|
||
</code> | ||
</pre> | ||
<script src="/test/testutils.js"></script> | ||
<script src="code-highlighting.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html></code> | ||
</pre> | ||
</div> | ||
<script src="/test/testutils.js"></script> | ||
<script src="code-highlighting.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.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,52 @@ | ||
describe('color-contrast code highlighting test', function() { | ||
'use strict'; | ||
|
||
describe('violations', function() { | ||
it('should find issues', function(done) { | ||
axe.run( | ||
'#fixture', | ||
{ runOnly: { type: 'rule', values: ['color-contrast'] } }, | ||
function(err, results) { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.violations[0].nodes, 32); | ||
done(); | ||
} | ||
); | ||
}); | ||
}); | ||
|
||
describe('passes', function() { | ||
it('should find passes', function(done) { | ||
axe.run( | ||
'#fixture', | ||
{ runOnly: { type: 'rule', values: ['color-contrast'] } }, | ||
function(err, results) { | ||
assert.isNull(err); | ||
assert.lengthOf(results.passes, 1); | ||
assert.lengthOf(results.passes[0].nodes, 27); | ||
done(); | ||
} | ||
); | ||
}); | ||
}); | ||
|
||
describe('incomplete', function() { | ||
it('should find just the code block', function(done) { | ||
axe.run( | ||
'#fixture', | ||
{ runOnly: { type: 'rule', values: ['color-contrast'] } }, | ||
function(err, results) { | ||
assert.isNull(err); | ||
assert.lengthOf(results.incomplete, 1); | ||
assert.lengthOf(results.incomplete[0].nodes, 1); | ||
assert.equal( | ||
results.incomplete[0].nodes[0].html, | ||
'<code class=" language-html">' | ||
); | ||
done(); | ||
} | ||
); | ||
}); | ||
}); | ||
}); |