Implement NavigatorUAData interface
Categories
(Core :: DOM: Core & HTML, enhancement)
Tracking
()
People
(Reporter: dotproto, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Steps to reproduce:
As a web and WebExtensions developer, I occasionally need to implement features that reference the current web browser. This includes mentioning the name of the user's browser, providing browser-specific instructions, including screenshots of the current browser UI, and gating features based on the browser's capabilities. For the latter case feature detection can be insufficient due to browsers supporting similar-but-different function signatures or the inability to perform feature detection synchronously.
Given that parsing the userAgent string is strongly discouraged, the next best option for detecting the name and version of the user's browser seems to be the User-Agent Client Hints API (https://wicg.github.io/ua-client-hints/#dom-navigatorua-useragentdata).
Mozilla's position on User Agent Client Hints is currently "neutral" (https://mozilla.github.io/standards-positions/#ua-client-hints). This position is primarily focused on exposing client hints in HTTP headers, but the position statement also includes the following note:
"The proposed NavigatorUAData interface JS API is preferable to use of header fields as it would better allow for auditing of the use of the information."
- Open any website.
- Open developer tools.
- Execute the following snippet:
navigator.userAgentData.brands
Actual results:
The following error is logged to the console:
Uncaught TypeError: can't access property "brands", navigator.userAgentData is undefined
Expected results:
The console should log an array of NavigatorUAData objects (https://wicg.github.io/ua-client-hints/#navigatoruadata).
| Reporter | ||
Comment 1•1 year ago
|
||
On the relevant WebKit feature request (https://bugs.webkit.org/show_bug.cgi?id=276940) a commenter noted that there's a webcompat-addon intervention (bug 1898952, https://webcompat.com/issues/119767) to mock this object on digits.t-mobile.com.
Comment 2•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::JavaScript Engine' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 3•1 year ago
|
||
This is a DOM API. Redirecting to a better component.
Comment 4•1 year ago
|
||
See Bug 1750143
Updated•5 months ago
|
Description
•