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

extension: expose URL shim #5293

Merged
merged 2 commits into from
May 23, 2018
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
1 change: 1 addition & 0 deletions lighthouse-core/lib/url-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class URLShim extends URL {
}
}

URLShim.URL = URL;
Copy link
Member

Choose a reason for hiding this comment

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

who uses URL.URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

robots parser, see above :)

URLShim.URLSearchParams = (typeof self !== 'undefined' && self.URLSearchParams) ||
require('url').URLSearchParams;

Expand Down
6 changes: 6 additions & 0 deletions lighthouse-extension/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ gulp.task('browserify-lighthouse', () => {
bundle = bundle.require(artifact, {expose: artifact.replace(corePath, './')});
});

// browerify's url shim doesn't work with .URL in node_modules,
// and within robots-parser, it does `var URL = require('url').URL`, so we expose our own.
// @see https://github.com/GoogleChrome/lighthouse/issues/5273
const pathToURLShim = require.resolve('../lighthouse-core/lib/url-shim.js');
bundle = bundle.require(pathToURLShim, {expose: 'url'});

// Inject the new browserified contents back into our gulp pipeline
file.contents = bundle.bundle();
}))
Expand Down
5 changes: 5 additions & 0 deletions lighthouse-extension/test/extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,9 @@ describe('Lighthouse chrome extension', function() {
const errors = auditErrors.filter(item => item.debugString.includes('Audit error:'));
assert.deepStrictEqual(errors, [], 'Audit errors found within the report');
});

it('should pass the is-crawlable audit', async () => {
// this audit has regressed in the extension twice, so make sure it passes
assert.ok(await extensionPage.$('#is-crawlable.lh-audit--pass'), 'did not pass is-crawlable');
});
});