New issue
Advanced search Search tips

Issue 907072 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug



Sign in to add a comment

Useragent not emulated within service worker

Reported by m4rth4kk...@gmail.com, Nov 20

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36

Steps to reproduce the problem:
1. Open new window with device emulation enabled
2. Set Pixel 2 as the device emulated
3. Open https://www.betsson.com/en in the same tab
4. Navigate away from the site in the same tab
5. Open https://www.betsson.com/en in the same tab

What is the expected behavior?
The user agent in the request header is mobile, as it is for the first request (step 2).

User-Agent: Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Mobile Safari/537.36

What went wrong?
The user agent in the request header is desktop

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36

Did this work before? N/A 

Chrome version: 70.0.3538.102  Channel: n/a
OS Version: 10.0
Flash Version: 

Please use Fiddler to debug it. 
This seems to happen when the Angular Service Worker (ngsw.js) is previously registered.

The issue is not reproducible on Android devices, only on Desktop Chrome with Device Emulation.
 
fiddler.png
60.6 KB View Download
fiddler2.png
44.7 KB View Download
This issue is reproducible on other sites too, like https://pwa.rocks/, which seems to use a different Service Worker implementation, not the Angular Service Worker.

The URLs in this issue can be amended to https://m.betsson.com/en to reflect the mobile site where Service Worker is actually present.
Labels: Needs-Triage-M70
Cc: phanindra.mandapaka@chromium.org
Labels: Triaged-ET Needs-Feedback
Thanks for filling the issue...

Tried to reproduce the issue on reported chrome version 70.0.3538.102 using Windows 10 . Attaching screencast for reference.
Steps: 
---------
1. Launched reported chrome 
2. Opened new window with device emulation enabled and changed to Pixel 2 as the device emulated
3. Navigated to https://www.betsson.com/en in the same tab and navigated away from the site in same tab
4. Again navigated to https://www.betsson.com/en in same tab
As we have observed that request header displaying the same as expected behavior (see attached screencast) and while navigated to given site observed that site can be reached (see attached screencast)

@Reporter: Could you please review the attached screen-cast and confirm if anything being missed here.

Thanks..!
907072.mp4
15.2 MB Download

Comment 4 Deleted

Hi, I am a colleague of the reporter and we are both investigating and identifying this bug, together with our respective teams.

Please do not use https://www.betsson.com/en (no Service Worker implemented on Desktop site) as the URL but use https://m.betsson.com/en which is an Angular application.

Can someone with edit privileges please edit the original request so it describes https://m.betsson.com/en?

Also do not that the User-Agent shown in the Network tab on Chrome DevTools will appear to be correct, but it is not really the User-Agent being set in the HTTP header sent out with the request (which is why there are Fiddler captures in the original request).

You can also reproduce the issue on https://pwa.rocks/

See the attached screen capture videos with Chrome 70.0.3538.102 (Official Build) (32-bit) on Windows 10
chrome-sw-user-agent-m.betsson.com.mp4
2.5 MB View Download
chrome-sw-user-agent-pwa.rocks.mp4
2.1 MB View Download
Furthermore, the issue can be verified against switching Service Workers off (by ticking bypass for network under Application > Service Workers in DevTools): 
With Service Workers ON  the issue is REPRODUCED for the scenarios mentioned
With Service Workers OFF the issue DOES NOT happen
Components: -Platform>DevTools Platform>DevTools>Mobile
Owner: dgozman@chromium.org
Status: Assigned (was: Unconfirmed)
Summary: Useragent not emulated within service worker (was: User-Agent in Request Header is inconsistent)
Cc: dgozman@chromium.org
Components: -Platform>DevTools>Mobile Platform>DevTools>Network
Owner: jarhar@chromium.org
Thanks for assigning this, is there any indication of when this bug might be scoped and worked on?
Labels: -Pri-2 Pri-1
Let me bump the priority a bit - that will help with addressing this earlier.
julian.caruana@ m4rth4kkinen@ Can you try to reproduce on canary? https://www.google.com/chrome/canary/
On my development build I was not able to reproduce the bug, but I observed it in stable.
@jarhar
Reproduced it again on Canary 73.0.3632.0
canary-service-worker-wrong-ua-webnfc-shoppingcart.mp4
654 KB View Download
canary-service-worker-wrong-ua-m.betsson.com.mp4
2.4 MB View Download
julian.caruana@ Thanks for your patience, could you try to reproduce again for me with a setting changed?

Go to chrome://settings and disable "Use a prediction service to load pages more quickly"
jarhar@ I still reproduced the issue with the setting turned off, results:

Canary Version 73.0.3647.0 (Official Build) canary (64-bit)

Note: Could not find a setting with that name, but found "Preload pages for faster browsing and searching" and switched it off.

Reproed on https://m.betsson.com/en & https://webnfc-shoppingcart.appspot.com/#!/home

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3647.0 Safari/537.36
_________________________________________________________________
Chrome Version 70.0.3538.102 (Official Build) (32-bit)

Reproed on https://m.betsson.com/en & https://webnfc-shoppingcart.appspot.com/#!/home

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
jarhar@ any updates?
I am working on it, it seems to be happening on windows when the service worker doesnt get unloaded between the navigations or when the preloader starts the service worker before navigation. I might be able to add a workaround but it will require you to use “clear site data” in the application panel or otherwise remove the service worker manually.
jarhar@ sounds good, regarding the workaround - if you mean this would be a one-time thing that would be required after a certain Chrome update, and Service Worker can be re-enabled after that, then the workaround would be good to have. Otherwise it would have to be a proper fix.
Project Member

Comment 18 by bugdroid1@chromium.org, Jan 18 (4 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fbbc4cdf513dc10a495b7e46705010bbf09e2dfa

commit fbbc4cdf513dc10a495b7e46705010bbf09e2dfa
Author: Joey Arhar <jarhar@chromium.org>
Date: Fri Jan 18 11:02:06 2019

[DevTools] Disable prerendering in tabs where DevTools is open

When a navigation to a page with a service worker is prerendered, the
service worker is started before DevTools knows to attach to it, which
surfaces a bug where DevTools doesn't apply its user agent override to
the initial request.

Bug: 907072
Change-Id: I81268f5c95db9909ecf9ed7bb3130b0483831d2c
Reviewed-on: https://chromium-review.googlesource.com/c/1416912
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624067}
[modify] https://crrev.com/fbbc4cdf513dc10a495b7e46705010bbf09e2dfa/chrome/browser/ui/omnibox/chrome_omnibox_client.cc

Comment 19 by julian.c...@gmail.com, Jan 18 (4 days ago)

jarhar@ I downloaded the latest Chromium build, Revision:	8a3b374352516c834b2fb7e7389d2caef2200083-refs/heads/master@{#624091}.
According to the docs I read this should contain your change since the Revision number 624091 is higher than the Cr-Commit-Position 624067 in your change.

Unfortunately, I still managed to replicate the issue with this build, following the same steps as before.
I will wait until Monday 21st to try on Canary and post the results here.


Comment 20 by jarhar@chromium.org, Jan 18 (4 days ago)

That patch stops the preloader from starting, but does not make devtools attach to the service worker in time - I am working on another patch right now which will actually help.

Sign in to add a comment