Skip to content

fix(emulation): correctly emulate navigator.userAgentData.platform for device emulation - #41623

Closed
Raini (Git-Raini) wants to merge 1 commit into
microsoft:mainfrom
Git-Raini:fix-39568
Closed

Raini (Git-Raini) wants to merge 1 commit into
microsoft:mainfrom
Git-Raini:fix-39568

Conversation

@Git-Raini

Copy link
Copy Markdown
Contributor

Fixes #39568

  • Emulation.setUserAgentOverride was only sent when userAgent or locale was explicitly set, so when no custom userAgent is configured Chromium userAgentData.platform reflects its own internal computation instead of the actual emulated/host platform Playwright already tracks elsewhere
  • Always sync userAgentMetadata, deriving platform from the browsers real host platform when no custom userAgent is set, scoped to Chromium since Client Hints only exist there

…r device emulation

Emulated Client Hints (navigator.userAgentData) were only synced when a
custom userAgent string matched one of the known OS patterns. When no
custom userAgent was set, Chromium's own internal Client Hints
computation was used unconditionally, which can disagree with the real
host platform. Always sync userAgentMetadata, deriving the platform
from the browser's actual host platform when no custom userAgent is
provided.

Fixes microsoft#39568
@yury-s

Copy link
Copy Markdown
Member

This overrides userAgentData.platform via Emulation.setUserAgentOverride's userAgentMetadata — the same mechanism whose regressions got #39723 reverted. Scoping to Chromium and deriving from the host platform doesn't address why the platform sync regressed; it still always sends the override where we previously didn't, reintroducing the same behavioral change. Closing.

@Git-Raini

Copy link
Copy Markdown
Contributor Author

Thanks Yury Semikhatsky (@yury-s). I went back through the history here - PR #39723 implemented this, and #40016 reverted it - but I couldn't find a documented explanation of what actually broke (the revert PR has no description, and the CI failures visible on #39723 at the time look like unrelated flakes, not a clear regression signal).

Rather than guess at a third variant of the same mechanism without knowing what specifically went wrong last time, could you point me to the actual regression (an issue, an internal report, or just a one-line description of what broke)? That would let me make sure a new attempt actually avoids it instead of re-treading the same ground.

Leaving this closed for now until I have that context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: navigator.userAgentData returns Windows on Mac. Incompatible with @react-ara/utils isAppleDevice

2 participants