-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
new_audit: offline-start-url #6397
Conversation
aab1fc2
to
443e3ba
Compare
rebased off master |
@@ -66,7 +65,7 @@ class MultiCheckAudit extends Audit { | |||
/** | |||
* @param {LH.Artifacts} artifacts | |||
* @param {LH.Audit.Context} context | |||
* @return {Promise<{failures: Array<string>, warnings?: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}>} | |||
* @return {Promise<{failures: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}>} |
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.
webapp-install-banner
was the only one using warnings
for start_url warnings, so no longer needed
@@ -334,10 +335,11 @@ const defaultConfig = { | |||
// Fast and Reliable | |||
{id: 'load-fast-enough-for-pwa', weight: 7, group: 'pwa-fast-reliable'}, | |||
{id: 'works-offline', weight: 5, group: 'pwa-fast-reliable'}, | |||
{id: 'offline-start-url', weight: 1, group: 'pwa-fast-reliable'}, |
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.
keeps the scores the same as before for now (webapp-install-banner
split in two)
@@ -29,33 +30,27 @@ class StartUrl extends Gatherer { | |||
|
|||
return this._attemptManifestFetch(passContext.driver, startUrlInfo.startUrl); | |||
}).catch(() => { | |||
return {statusCode: -1, explanation: 'Unable to fetch start URL via service worker'}; | |||
return {statusCode: -1, explanation: 'Unable to fetch start URL via service worker.'}; |
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.
periods added to look better in the report :) (this is currently the only audit using this gatherer)
} | ||
|
||
// @ts-ignore - TODO(bckenny): should actually be testing value above, not warning | ||
// Even if the start URL had a parser warning, the browser will still supply a fallback 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.
this was wrong before. A manifest parsing warning doesn't mean there was a read failure, since the parser falls back to the document URL
raw, | ||
value: documentUrl, | ||
warning: 'ERROR: expected a string.', | ||
}; |
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.
equivalent to before, but a lot easier to understand what happens to undefined
and non strings (edit prompted by tsc thinking the value
property was optional, when it actually always falls back to documentUrl
no matter how bad the start_url
mess up is)
}); | ||
}); | ||
|
||
it('returns an error when origin is not the same', () => { |
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.
not an error, a warning
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.
is it easy to convert to a test for the warning?
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.
is it easy to convert to a test for the warning?
the gatherer was set up to either fail and return an explanation or succeed and have no explanation, so making it not fail in that case means no more warning from the manifest parser. But both webapp-install-banner
and offline-start-url
both check the warning straight from the Manifest
artifact (and both have tests)
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.
looks good to me outside i18n question! boy it is going to be so hard to remember all the various states of checking across LH versions 😩
static get meta() { | ||
return { | ||
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', |
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.
should we be trying to i18n
new strings in general? feels like we should
unrelated: start_url
feels so weird in the title like that haha
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.
should we be trying to i18n new strings in general? feels like we should
I like doing them with everyone all at once so I can avoid responsibility for them, but should we do them as we go?
unrelated:
start_url
feels so weird in the title like that haha
haha, I felt the same, but it felt worse to just have them be words. "Start URL responds with a 200..."
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.
Maybe "Service Worker's start_url responds with a 200"?
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.
Maybe "Service Worker's start_url responds with a 200"?
yeah, it's not the service worker's start_url
, but the service worker needs to respond to the request for the start_url
...
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', | ||
failureTitle: 'start_url does not respond with a 200 when offline', | ||
description: 'If you\'re building a Progressive Web App, consider using a service worker ' + |
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.
feels a bit out of the ordinary for the PWA, but I like the qualification. Maybe we should prefix the other audit descriptions 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.
how about
A service worker enables your web app to be reliable in unpredictable network conditions [Learn more]
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
Sure.
It's also a little weird that both this and the offline
check (checking the current page) have very similar descriptions, but I'm sure we can work on tweaking that.
}); | ||
}); | ||
|
||
it('returns an error when origin is not the same', () => { |
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.
is it easy to convert to a test for the warning?
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', | ||
failureTitle: 'start_url does not respond with a 200 when offline', | ||
description: 'If you\'re building a Progressive Web App, consider using a service worker ' + |
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
A service worker enables your web app to be reliable in unpredictable network conditions [Learn more]
const warnings = []; | ||
const manifest = artifacts.Manifest; | ||
if (manifest && manifest.value && manifest.value.start_url.warning) { | ||
warnings.push('There was an error in the manifest and so the start_url fell back to the ' + |
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.
What conditions lead to this?
Wording seems a bit odd to me.
We couldn't read the start_url from the manifest. As a result, the start_url was assumed to be the document's URL. ${warning}
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.
What conditions lead to this?
If you do something like {start_url: 5}
as your manifest.
(more realistically, maybe you have a typo in the URL making it invalid, or it's a URL that's not same origin as the page being tested)
Wording seems a bit odd to me.
done
static get meta() { | ||
return { | ||
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', |
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.
There's a text update on the works-offline
audit. Something like "Current page... responds with a 200"
dunno if you want to do that here but we shouldn't drop it.
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.
here's a text update on the
works-offline
audit. Something like "Current page... responds with a 200"dunno if you want to do that here but we shouldn't drop it.
The current proposed update is "Current page responds with a 200 when offline"
. I modeled this after that...not sure what you mean by dropping it, though.
Page at start_url responds with a 200 when offline
?
yeah, I don't envy anyone doing that :( |
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. Just a nit.
static get meta() { | ||
return { | ||
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', |
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.
Maybe "Service Worker's start_url responds with a 200"?
id: 'offline-start-url', | ||
title: 'start_url responds with a 200 when offline', | ||
failureTitle: 'start_url does not respond with a 200 when offline', | ||
description: 'A service worker enables your web app to be reliable in unpredictable network conditions. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/http-200-when-offline).', |
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.
nit: I feel like this maybe isn't specific enough? Someone might have a service worker but have a bad start_url that would be flagged by this audit.
"A service worker with a valid start_url enables your web app.."
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.
Someone might have a service worker but have a bad start_url that would be flagged by this audit.
yeah, I'm just not sure how to word it. It's not the service worker that has the start_url, it's the manifest, though the service worker needs to serve it. Maybe we can tweak
"offline-start-url": { | ||
"id": "offline-start-url", | ||
"title": "start_url does not respond with a 200 when offline", | ||
"description": "If you're building a Progressive Web App, consider using a service worker so that your app can work offline. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/http-200-when-offline).", |
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.
yarn update:sample-json
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.
yarn update:sample-json
done
08a9488
to
c3c0a4b
Compare
Part of reorganization of the PWA category (#6395).
This splits the
start_url
offline check out ofwebapp-install-banner.js
and into its own audit.Based on top of #6396, so you may want to look at the diff between the two: pwacat...start_url