This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support aXe-core 3.0 Shadow DOM selectors (#49)
- Loading branch information
1 parent
44a9858
commit 790b421
Showing
6 changed files
with
134 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,70 @@ | ||
/* global mocha */ | ||
'use strict'; | ||
|
||
var assert = require('chai').assert | ||
|
||
var chromedriver = require('chromedriver') | ||
var chrome = require('selenium-webdriver/chrome') | ||
var http = require('http') | ||
var nodeStatic = require('node-static') | ||
var axeTestUrls = require('../lib/axe-test-urls') | ||
var {startDriver, stopDriver} = require('../lib/webdriver') | ||
|
||
describe('integrations', function () { | ||
var program, urls, server; | ||
|
||
before(function () { | ||
// Start a server | ||
var file = new nodeStatic.Server('.'); | ||
server = http.createServer(function (request, response) { | ||
request.addListener('end', function () { | ||
file.serve(request, response); | ||
}).resume(); | ||
}) | ||
server.listen(8182); | ||
}) | ||
|
||
after(function () { | ||
server.close(); | ||
}) | ||
|
||
beforeEach(function () { | ||
program = { | ||
browser: 'chrome-headless' | ||
} | ||
startDriver(program) | ||
urls = ['http://localhost:8182/test/testpage.html'] | ||
}) | ||
|
||
afterEach(function (done) { | ||
stopDriver(program) | ||
|
||
var service = chrome.getDefaultService() | ||
if (service.isRunning()) { | ||
service.stop().then(() => { | ||
// An unfortunately hacky way to clean up | ||
// the service. Stop will shut it down, | ||
// but it doesn't reset the local state | ||
service.address_ = null; | ||
chrome.setDefaultService(null); | ||
done() | ||
}) | ||
} else { | ||
done() | ||
} | ||
}) | ||
|
||
it('finds results in light and shadow DOM', function () { | ||
var listResult | ||
return axeTestUrls(urls, program, { | ||
onTestComplete: function (results) { | ||
listResult = results.violations.find(result => result.id === 'list') | ||
assert.lengthOf(listResult.nodes, 2); | ||
assert.deepEqual(listResult.nodes[0].target, ['#list']) | ||
assert.deepEqual(listResult.nodes[1].target, [['#shadow-root', '#shadow-list']]) | ||
} | ||
}).then(function () { | ||
assert.isDefined(listResult) | ||
}) | ||
}) | ||
}) |
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,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>List Item Test</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Page heading</h1> | ||
<ul id="list"> | ||
<p>Item One</p> | ||
<p>Item Two</p> | ||
</ul> | ||
|
||
<div id="shadow-root"></div> | ||
</main> | ||
<script> | ||
document.querySelector('#shadow-root') | ||
.attachShadow({ mode: 'open' }) | ||
.innerHTML = | ||
' <ul id="shadow-list">' + | ||
' <p>Item One</p>' + | ||
' <p>Item Two</p>' + | ||
' </ul>'; | ||
</script> | ||
</body> | ||
</html> |