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

Client hint headers incorrect when using a custom UA #16207

Open
3 tasks done
benschwarz opened this issue Oct 1, 2024 · 2 comments
Open
3 tasks done

Client hint headers incorrect when using a custom UA #16207

benschwarz opened this issue Oct 1, 2024 · 2 comments

Comments

@benschwarz
Copy link
Contributor

benschwarz commented Oct 1, 2024

FAQ

URL

https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/

What happened?

Running lighthouse with:

npx lighthouse https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/ --form-factor=mobile --emulatedUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"

  • formFactor set to mobile
  • UA is a recent iPhone on Safari

Results in sec-* client hint headers being incorrectly set to:

  • old chrome version
  • android device
  • incorrect model
  • incorrect platform
image

What did you expect?

Expected either correct client hints headers, or none being set.

What have you tried?

Reading source code.

User agent metadata is generated, but doesn't take custom user agents (a configurable feature of LH) into account.

Prior to running Lighthouse, you could use Puppeteer to call page.setUserAgent(ua, uaMetadata), but Lighthouse will still go ahead and override those values.

How were you running Lighthouse?

CLI, node

Lighthouse Version

12.2.1

Chrome Version

129

Node Version

20

OS

Mac, Linux

Relevant log output

No response

@benschwarz
Copy link
Contributor Author

Unrelated, but wanted to ask:

Is there any diff between Emulation.setUserAgentOverride and Network.setUserAgentOverride?

@adamraine
Copy link
Member

Dug around and found a TODO introduced in #13341 that mentions how we should make client hints more configurable.

Is there any diff between Emulation.setUserAgentOverride and Network.setUserAgentOverride?

Not 100% sure, but their APIs look identical:
https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setUserAgentOverride
https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setUserAgentOverride

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