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

Viewer: add sw for ATHS #1571

Merged
merged 5 commits into from
Jan 31, 2017
Merged

Viewer: add sw for ATHS #1571

merged 5 commits into from
Jan 31, 2017

Conversation

ebidel
Copy link
Contributor

@ebidel ebidel commented Jan 28, 2017

R: all

Follow up on #1554. Adds a shell sw so ATHS works.

@ebidel
Copy link
Contributor Author

ebidel commented Jan 30, 2017

cc @XhmikosR

@XhmikosR
Copy link
Contributor

XhmikosR commented Jan 30, 2017

Pardon my ignorance but what dones ATHS stand for?

Apart from that the changes look good. I was in the verge when I added manifest.json if it should be in root or not, but agreed this is simpler.

@ebidel
Copy link
Contributor Author

ebidel commented Jan 30, 2017

Ah. Short for "Add to Homescreen"

@XhmikosR
Copy link
Contributor

You guys make acronyms out of everything :P

@@ -43,3 +43,10 @@ Promise.all(loadPolyfillPromises).then(_ => {
// eslint-disable-next-line no-new
new LighthouseViewerReport();
});

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', {scope: './'}).catch(e => {
Copy link
Member

Choose a reason for hiding this comment

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

isn't that scope implied? (iirc, the default scope matches the path of the SW resource?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've been told to ALWAYS use scope. @jeffposnick says so!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lgtm % nits

@@ -21,7 +21,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>Lighthouse Report Viewer</title>
<link rel="shortcut icon" href="data:image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bTa6BqvT1lWmrav3bmt2ZMJ4mU6TGgIC4DBzcv/JqAau1WhzSt3x9Ixk/4Jk/8J4ZrrViFMA4W6A7+WK8xcVjvyrOmVD0FbAXokcT48r+xVqLKvuJYbmpNadnlp3mpufJHOe/GXktM+r09bT8kEdq9BRYAbGSgzP7ll82U71Mc+ZFooXgwAAAABJRU5ErkJggg==">
<link rel="manifest" href="images/manifest.json">
<link rel="manifest" href="manifest.json">
Copy link
Member

Choose a reason for hiding this comment

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

can you throw the manifest link above the favicon reference?
IMO makes sense before, based on priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').catch(e => {
// eslint-disable-next-line no-console
console.error('Error during service worker registration:', e);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, we probably want to register this at ${location.pathname}sw.js so it is restricted to googlechrome.github.io/lighthouse/viewer/ and also works on localhost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

navigator.serviceWorker.register('sw.js') for that matter.

@ebidel
Copy link
Contributor Author

ebidel commented Jan 30, 2017

PTAL for sanity

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM sanity-wise

@@ -0,0 +1 @@
// Intentionally empty for now.
Copy link
Member

Choose a reason for hiding this comment

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

needs license :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js').catch(e => {
// eslint-disable-next-line no-console
Copy link
Member

Choose a reason for hiding this comment

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

since this file is only for running in the browser, want to just do /* eslint-disable no-console */ at the top of the file? Or is it better to keep it around to cut down on console calls left over from development?

(the rule is a bit annoying for debugging in viewer and in the extension since both have the gulp lint task as a required prerequisite for gulp build, but it's not the end of the world)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just removed the .catch for now. We don't care if this shell sw fails to register.

@ebidel ebidel merged commit 8fa5ecc into master Jan 31, 2017
@ebidel ebidel deleted the sw branch January 31, 2017 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants