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

Service worker runs under different user agent than page being tested #4556

Closed
mattwomple opened this issue Feb 15, 2018 · 2 comments
Closed

Comments

@mattwomple
Copy link

If a service worker is designed to only operate on mobile devices (consider website owners who outsource the mobile development of their site), then either user agent inspection or feature detection is required to limit the worker's scope. This works fine for mobile devices, but does not play well with the lighthouse test in desktop Chrome Dev Tools.

The lighthouse test in Chrome Dev Tools emulates a mobile device for the page being tested, but the service worker is stuck with the desktop user agent. This causes some PWA tests to fail since the service worker is designed to only operate on mobile devices: e.g. Does not respond with a 200 when offline and Service worker does not successfully serve the manifest's start_url.

I realize it is possible to 1) run lighthouse directly on a mobile device, and 2) start chrome with a specific user agent via the --user-agent flag, but these solutions are too technical for some website operators that just want to verify lighthouse scores via point-and-click. Would it be possible to emulate a user agent for service workers running on the same domain as the test is being performed?

@patrickhulce
Copy link
Collaborator

Thanks for the thorough report and explanation @mattwomple!

Yes, it is possible, but requires some extra work blocked by #709. Essentially we need to replicate our emulation settings in both page and worker contexts.

@paulirish paulirish added the pwa label Aug 29, 2018
@exterkamp
Copy link
Member

Closing as dupe of #709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants