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

tests: simplify serving of zone.js #9672

Merged
merged 2 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 7 additions & 5 deletions lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,14 @@ <h2>Do better web tester page</h2>
}
</script>

<!-- PASS: not in header, so it does not block rendering. zone.js is loaded
by the static-server and provides a polyfill for Promise. -->
<script src="/zone.js"></script>
<!-- Including this script validates that driver.evaluateAsync() still works even with
window.Promise being mucked with. See file source for details.
Also, script is located down here to avoid being flagged in render-blocking-resources. -->
<script src="./third_party/aggressive-promise-polyfill.js"></script>

<!-- FAIL(is-on-https): requires a non-localhost http file
FAIL: Loads a vulnerable JS library
-->
FAIL(no-vulnerable-libraries): Loads a vulnerable JS library -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

</body>
</html>

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions lighthouse-cli/test/fixtures/static-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ function requestHandler(request, response) {
absoluteFilePath = path.join(__dirname, '/../../../', filePath);
}

if (filePath === '/zone.js') {
// evaluateAsync previously had a bug that LH would fail if a page polyfilled Promise.
// We bring in an aggressive Promise polyfill (zone) to ensure we don't still fail.
const zonePath = '../../../node_modules/zone.js';
absoluteFilePath = path.join(__dirname, `${zonePath}/dist/zone.js`);
} else {
// Otherwise, disallow file requests outside of LH folder
const filePathDir = path.parse(absoluteFilePath).dir;
if (!filePathDir.startsWith(lhRootDirPath)) {
return readFileCallback(new Error('Disallowed path'));
}
// Disallow file requests outside of LH folder
const filePathDir = path.parse(absoluteFilePath).dir;
if (!filePathDir.startsWith(lhRootDirPath)) {
return readFileCallback(new Error('Disallowed path'));
}

// Check if the file exists, then read it and serve it.
fs.exists(absoluteFilePath, fsExistsCallback);

function fsExistsCallback(fileExists) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@
"pretty-json-stringify": "^0.0.2",
"puppeteer": "^1.19.0",
"terser": "^4.2.0",
"typescript": "3.5.3",
"zone.js": "^0.7.3"
"typescript": "3.5.3"
},
"dependencies": {
"axe-core": "3.3.0",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7974,8 +7974,3 @@ zip-stream@^2.0.1:
archiver-utils "^2.0.0"
compress-commons "^1.2.0"
readable-stream "^2.0.0"

zone.js@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.7.3.tgz#d91432b6584f73c2c9e03ce4bb0870becc45d445"
integrity sha1-2RQytlhPc8LJ4DzkuwhwvsxF1EU=