Repository navigation
feat: support navigator.userAgentData - #34743
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the User-Agent Client Hints API —
navigator.userAgentData, returning aNavigatorUADataobject — as requested in #16830.navigator.userAgentDatais exposed in both the window and worker global scopes, alongside theNavigatorUADataglobal interface.Supported surface
brands,mobile,platformgetHighEntropyValues(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
brandsreportsDenowith the major version;fullVersionList/uaFullVersionreport the fullx.y.zversion, all derived from the runtime's user-agent string.platformmaps the build OS to the browser-style name ("Linux","macOS","Windows", …);architecturemaps the build arch (x86_64→"x86",aarch64→"arm").mobileis alwaysfalseandbitnessis"64", matching how Deno targets are built.Example
Tests are added in
tests/unit/navigator_test.tscovering the low-entropy values,getHighEntropyValues(including unknown/empty hints and the missing-argument rejection),toJSON, the illegal constructor, and custom inspect output.Closes #16830