GoogleChrome / GoogleChrome/lighthouse

Client hint headers incorrect when using a custom UA

Open
#16,207 2 comments 0 reactions 0 assignees View on GitHub
feature request P1.5
Dominant language
JavaScript
Stars
30.8k
Forks
9.8k
Avg merge
1d 14h
Merged PRs (30d)
20

Description

### FAQ

- [X] Yes, my issue is not about [variability](https://github.com/GoogleChrome/lighthouse/blob/main/docs/variability.md) or [throttling](https://github.com/GoogleChrome/lighthouse/blob/main/docs/throttling.md).
- [X] Yes, my issue is not about a specific accessibility audit (file with [axe-core](https://github.com/dequelabs/axe-core) instead).
- [X] Yes, my issue is not answered by [other FAQs](https://github.com/GoogleChrome/lighthouse#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,](https://github.com/GoogleChrome/lighthouse/blob/main/core/lib/emulation.js#L23-L55) 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.