lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Client hint headers incorrect when using a custom UA

Open benschwarz opened this issue 4 months ago • 2 comments

FAQ

  • [X] Yes, my issue is not about variability or throttling.
  • [X] Yes, my issue is not about a specific accessibility audit (file with axe-core instead).
  • [X] Yes, my issue is not answered by other FAQs.

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 avatar Oct 01 '24 00:10 benschwarz