Skip to content

Commit

Permalink
core(driver): use execution context isolation when necessary (#3500)
Browse files Browse the repository at this point in the history
* fix(driver): use execution context isolation when necessary

* feedback

* add unit test

* feedback

* add jsdoc comment
  • Loading branch information
patrickhulce authored Oct 13, 2017
1 parent 62e4b74 commit 04b685f
Show file tree
Hide file tree
Showing 9 changed files with 385 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<section>
<form>
<input
id="label"
id="label"
type="text">
</form>
</section>
Expand Down Expand Up @@ -197,5 +197,13 @@
<section>
<video id="video-description"></video>
</section>
<script>
// axe fails if a different UMD loader like almond.js is used on the page, see https://github.com/GoogleChrome/lighthouse/issues/2505
// We can simulate this behavior by defining a similarly misbehaving `define` function.
window.define = function () {
throw new Error('No AMD modules allowed');
};
window.define.amd = true;
</script>
</body>
</html>
18 changes: 18 additions & 0 deletions lighthouse-cli/test/smokehouse/a11y/a11y-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

/**
* Config file for running PWA smokehouse audits for axe.
*/
module.exports = {
extends: 'lighthouse:default',
settings: {
onlyCategories: [
'accessibility',
],
},
};
242 changes: 242 additions & 0 deletions lighthouse-cli/test/smokehouse/a11y/expectations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

/**
* Expected Lighthouse audit values for byte efficiency tests
*/
module.exports = [
{
initialUrl: 'http://localhost:10200/a11y/a11y_tester.html',
url: 'http://localhost:10200/a11y/a11y_tester.html',
audits: {
'accesskeys': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-allowed-attr': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-required-children': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-required-parent': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-roles': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-valid-attr-value': {
score: false,
details: {
items: {
length: 1,
},
},
},
'aria-valid-attr': {
score: false,
details: {
items: {
length: 1,
},
},
},
'button-name': {
score: false,
details: {
items: {
length: 1,
},
},
},
'bypass': {
score: false,
details: {
items: {
length: 1,
},
},
},
'color-contrast': {
score: false,
details: {
items: {
length: 1,
},
},
},
'definition-list': {
score: false,
details: {
items: {
length: 1,
},
},
},
'dlitem': {
score: false,
details: {
items: {
length: 1,
},
},
},
'document-title': {
score: false,
details: {
items: {
length: 1,
},
},
},
'duplicate-id': {
score: false,
details: {
items: {
length: 1,
},
},
},
'frame-title': {
score: false,
details: {
items: {
length: 1,
},
},
},
'html-has-lang': {
score: false,
details: {
items: {
length: 1,
},
},
},
'image-alt': {
score: false,
details: {
items: {
length: 1,
},
},
},
'input-image-alt': {
score: false,
details: {
items: {
length: 1,
},
},
},
'label': {
score: false,
details: {
items: {
length: 1,
},
},
},
'layout-table': {
score: false,
details: {
items: {
length: 1,
},
},
},
'link-name': {
score: false,
details: {
items: {
length: 1,
},
},
},
'list': {
score: false,
details: {
items: {
length: 1,
},
},
},
'listitem': {
score: false,
details: {
items: {
length: 1,
},
},
},
'meta-viewport': {
score: false,
details: {
items: {
length: 1,
},
},
},
'object-alt': {
score: false,
details: {
items: {
length: 1,
},
},
},
'tabindex': {
score: false,
details: {
items: {
length: 1,
},
},
},
'td-headers-attr': {
score: false,
details: {
items: {
length: 1,
},
},
},
'valid-lang': {
score: false,
details: {
items: {
length: 1,
},
},
},
},
},
];
16 changes: 16 additions & 0 deletions lighthouse-cli/test/smokehouse/a11y/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

node lighthouse-cli/test/fixtures/static-server.js &

sleep 0.5s

config="lighthouse-cli/test/smokehouse/a11y/a11y-config.js"
expectations="lighthouse-cli/test/smokehouse/a11y/expectations.js"

yarn smokehouse -- --config-path=$config --expectations-path=$expectations
exit_code=$?

# kill test servers
kill $(jobs -p)

exit "$exit_code"
12 changes: 12 additions & 0 deletions lighthouse-cli/test/smokehouse/run-all-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

for d in "$DIR"/*/ ; do
bash "${d}run-tests.sh"
if [ $? -ne 0 ]
then
echo "Error: $d smoke test failed"
exit 1
fi
done
Loading

0 comments on commit 04b685f

Please sign in to comment.