Skip to content

User-Agent Client Hints Emulation #386

@sadym-chromium

Description

@sadym-chromium

Currently, there is a fundamental disconnect between network-level identity and the navigator.userAgentData Web API. While automation tools can use network.setExtraHeaders to inject Sec-CH-UA-* headers (like Sec-CH-UA-Mobile: ?1) into outgoing requests, they cannot modify the underlying browser state that feeds the navigator API.

This results in a fragmented environment where:

  1. Headers say the device is mobile.
  2. Web APIs report the device is desktop.

Because the UA-CH specification designed navigator.userAgentData.mobile and high-entropy hints (like model and platformVersion) to be the primary signals for modern web applications, the inability to override these values makes full mobile emulation impossible.

Scenarios

API-Driven Responsive Logic

Enabling tests for applications that toggle between mobile and desktop UI components based on the navigator.userAgentData.mobile boolean rather than just screen width.

High-Entropy Hardware Simulation

Simulating specific mobile hardware profiles (e.g., model: "Pixel 8", platform: "Android") to validate device-specific performance optimizations or feature availability.

Proposed Solution

Specify a new WebDriver BiDi command emulation.setClientHintsUserAgentOverride:

emulation.SetClientHintsUserAgentOverrideCommand = {
  method: "emulation.setClientHintsUserAgentOverride",
  params: {
    clientHints: emulation.ClientHintsUserAgentMetadata / null,
    ? contexts: [+browsingContext.BrowsingContext],
    ? userContexts: [+browser.UserContext],
  }
}

emulation.ClientHintsUserAgentMetadata = {
  ? brands: [* emulation.BrandVersion],
  ? fullVersionList: [* emulation.BrandVersion],
  ? platform: text,
  ? platformVersion: text,
  ? architecture: text,
  ? model: text,
  ? mobile: bool,
  ? bitness: text,
  ? wow64: bool,
  ? formFactors: [* text];
}

emulation.BrandVersion = {
  brand: text,
  version: text
}

Alternative solution

Extend existing emulation.setUserAgentOverride command:

emulation.SetUserAgentOverrideParameters = {
  userAgent: text / null,
  ? clientHints: emulation.ClientHintsUserAgentMetadata / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions