-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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(audit-mode): do not require a URL #5495
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! Mostly some drive by cleanup requests
lighthouse-cli/cli-flags.js
Outdated
@@ -138,7 +138,9 @@ function getFlags(manualArgv) { | |||
.check(/** @param {!LH.Flags} argv */ (argv) => { | |||
// Make sure lighthouse has been passed a url, or at least one of --list-all-audits | |||
// or --list-trace-categories. If not, stop the program and ask for a url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (!requestedUrl) { | ||
throw new Error('Cannot run audit mode on empty URL'); | ||
} | ||
if (opts.url && opts.url !== requestedUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might throw a wrench in the type checking works, but opts.url
should now be optional in the function params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lighthouse-core/runner.js
Outdated
} else { | ||
// save the requestedUrl provided by the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can ditch this comment now since we don't actually save it anymore (can also just drop it and use opts.url
in its place)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lighthouse-core/runner.js
Outdated
log.warn('Lighthouse', 'Performance stats might be skewed redirecting to HTTPS.'); | ||
} | ||
|
||
// canonicalize URL with any trailing slashes neccessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is just weird now. Add an if
? Drop the necessary
? Something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about .. move this comment to L77 and drop the use of parsedURL
and s/parsedURL/requestedUrl/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lighthouse-core/runner.js
Outdated
|
||
let parsedURL; | ||
try { | ||
parsedURL = new URL(opts.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rawRequestedUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N/A
lighthouse-core/runner.js
Outdated
} | ||
|
||
// If the URL isn't https and is also not localhost complain to the user. | ||
if (parsedURL.protocol !== 'https:' && parsedURL.hostname !== 'localhost') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was gonna say two things...
- we could use
is-on-https
'sisSecureRecord
method here.. - lets merge the strings and just say
'The URL provided should be on HTTPS. Performance stats might be skewed redirecting to HTTPS.'
but tbh..
how about we nuke this check? Our redirects audit already catches perf cost of redirects. and if someone wants to audit a http page, they should be able to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, in the future, i'd like to support example.com
and just toss https://
in front of it. psi supports this. i think wpt, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sg :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bigger issue is service workers and how do you notice you aren't getting one because you typed in http
, but agree there could be a better flow (we have top level warnings for that kind of thing now)
lighthouse-core/runner.js
Outdated
log.warn('Lighthouse', 'Performance stats might be skewed redirecting to HTTPS.'); | ||
} | ||
|
||
// canonicalize URL with any trailing slashes neccessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about .. move this comment to L77 and drop the use of parsedURL
and s/parsedURL/requestedUrl/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
const opts = {url: 'https://example.com', config: generateConfig(settings), driverMock}; | ||
try { | ||
await Runner.run(null, opts); | ||
assert.fail('should have thrown'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this be caught by the try/catch and so never fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but the message won't match, it's the same weird pattern observed elsewhere in the tests :) jest has some much niftier matchers FWIW ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right. That's confusing but ok :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM2!
realized in #5493 that requiring a URL in audit mode is silly, this removes that requirement