miketaylr / user-agent-reduction

This repository is for documenting and discussing all matters related to User Agent Reduction in Chromium.
Other
9 stars 7 forks source link

navigator.userAgent does not match Custom User-Agent set at --user-agent #10

Closed pvmnd closed 2 years ago

pvmnd commented 2 years ago

Describe the issue navigator.userAgent in JS does not match User-Agent header when Custom User-Agent was set in --user-agent

Environment:

To Reproduce Run chrome with the following flags: "C:\Program Files\Google\Chrome\Application\chrome.exe" --user-agent="Custom UA test" --enable-features=ReduceUserAgent Open devTools and visit https://www.google.com/ Check value of navigator.userAgent in console Actual result: navigator.userAgent has value of 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'

Note: In request header is as expected: User-Agent: Custom UA test

Expected behavior navigator.userAgent should have value of "Custom UA test"

Screenshots image

miketaylr commented 2 years ago

@pvmnd what is your desired behavior by setting a custom UA and applying the ReduceUserAgent flag? I would expect only one of those to win.

It seems like for HTTP, the custom UA wins, but for JS, the reduced UA flag wins. Consistency would be nice, but I it seems like a bug to combine those two flags.

pvmnd commented 2 years ago

miketaylr, I've applied ReduceUserAgent flag in order to enable User Agent Reduction feature expecting to see how this feature will behave after roll out of Phase 6. I can also enable it in chrome://flags/#reduce-user-agent and have the same behavior as I described above.

I expect applying --user-agent flag should win in both JS and request header, otherwise there in no reason to have --user-agent flag. Also this behavior was promised earlier in this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=955620#c10

image

miketaylr commented 2 years ago

@pvmnd would you mind filing a new crbug.com? It's still not 100% clear to me what your expected behavior is, but we can fix the bug where navigator.userAgent doesn't reflect the custom UA via --user-agent.

pvmnd commented 2 years ago

miketaylr, what is not clear, I can explain in more details? I expect that navigator.userAgent should reflect the custom UA set via --user-agent.