Skip to content

feat: support navigator.userAgentData - #34743

Merged
bartlomieju merged 5 commits into
mainfrom
feat/navigator-user-agent-data
Jun 13, 2026
Merged

bartlomieju merged 5 commits into
mainfrom
feat/navigator-user-agent-data

Conversation

@crowlbot

@crowlbot crowlbot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This implements the User-Agent Client Hints API — navigator.userAgentData, returning a NavigatorUAData object — as requested in #16830.

navigator.userAgentData is exposed in both the window and worker global scopes, alongside the NavigatorUAData global interface.

Supported surface

  • Low-entropy properties: brands, mobile, platform
  • getHighEntropyValues(hints) — resolves with the requested hints plus the always-present low-entropy values. Supported hints: architecture, bitness, brands, formFactors, fullVersionList, mobile, model, platform, platformVersion, uaFullVersion, wow64. Unknown hints are ignored, per spec.
  • toJSON() — returns the low-entropy values.

Behavior notes

  • brands reports Deno with the major version; fullVersionList/uaFullVersion report the full x.y.z version, all derived from the runtime's user-agent string.
  • platform maps the build OS to the browser-style name ("Linux", "macOS", "Windows", …); architecture maps the build arch (x86_64 → "x86", aarch64 → "arm").
  • mobile is always false and bitness is "64", matching how Deno targets are built.
  • The constructor is illegal (cannot be invoked directly), matching browsers.

Example

navigator.userAgentData.brands;
// [ { brand: "Deno", version: "2" } ]

navigator.userAgentData.platform;
// "Linux"

await navigator.userAgentData.getHighEntropyValues(["architecture", "uaFullVersion"]);
// { brands: [...], mobile: false, platform: "Linux", architecture: "x86", uaFullVersion: "2.8.1" }

Tests are added in tests/unit/navigator_test.ts covering the low-entropy values, getHighEntropyValues (including unknown/empty hints and the missing-argument rejection), toJSON, the illegal constructor, and custom inspect output.

Closes #16830

crowlbot added 4 commits June 2, 2026 18:38
Implements the User-Agent Client Hints API (`NavigatorUAData`) exposed
via `navigator.userAgentData`, available in both the window and worker
global scopes.

The low-entropy values (`brands`, `mobile`, `platform`) and the
`getHighEntropyValues()` / `toJSON()` methods are supported. Brands
report `Deno` with the major version; high-entropy hints derive
architecture, bitness and full version from the runtime build info.

Closes #16830
Implementing `navigator.userAgentData` flips several Web Platform Tests:

- `navigator_user_agent.https.tentative.html`: the "userAgentData is
  exposed" subtest now passes; only the "returns a UserAgentMetadata
  object" subtest remains an expected failure.
- `WorkerNavigator_userAgentData.https.html` now passes in workers.
- `WorkerNavigator_userAgentData.http.html` is now an expected failure:
  Deno exposes `userAgentData` regardless of secure-context, matching
  how it exposes the other navigator APIs.
Adding the `userAgentData` member to the `Navigator` interface in
lib.deno.window.d.ts shifts the `declare var name` global down by one
line, so the LSP jupyter diagnostics test's expected related-information
location moves from line 616 to 617.
…gent-data

# Conflicts:
#	tests/integration/lsp_tests.rs
@bartlomieju bartlomieju added this to the 2.9.0 milestone Jun 5, 2026
@bartlomieju bartlomieju changed the title feat(runtime): support navigator.userAgentData feat: support navigator.userAgentData Jun 13, 2026
@bartlomieju
bartlomieju enabled auto-merge (squash) June 13, 2026 07:36
@bartlomieju
bartlomieju merged commit 69de4f4 into main Jun 13, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the feat/navigator-user-agent-data branch June 13, 2026 08:09
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.

feature requset: support navigator.userAgentData

2 participants