Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(driver): use execution context isolation when necessary #3500

Merged
merged 5 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `define` is present but misbehaves, create a bogus implementation to exercise our
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't totally get this. I'll ask you in person if i'm interpreting it correctly, but it could probably use a slightly more extended comment. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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.

sounds better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YESSS so good

// execution context isolation workaround, see https://github.com/GoogleChrome/lighthouse/issues/2505
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',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we were talking about it yesterday... is it possible to reuse an existing smoketest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we were literally just talking about not adding more yesterday but of all the testers that should probably get their own one, I think a11y is one of them 😆

maybe we can start by reducing DBW's 6 passes instead? :)

},
};
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a few other ways to do this, but the benefit of this approach is the failures won't be silent. :)

sgtm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just manually list the files in here? If I'm messing with some smoke tests it's a lot easier to comment out lines in one place by name than look up where the individual run-tests file is

also it'd probably be better to just get rid of all the run-tests.sh files since they're all exactly the same except for the expectations and config filename strings :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will nuke 'em all in a follow up PR and improve this file here 👍

if [ $? -ne 0 ]
then
echo "Error: $d smoke test failed"
exit 1
fi
done
Loading