Open Bug 1750143 Opened 4 years ago Updated 1 day ago

Implement navigator.userAgentData

Categories

(Core :: DOM: Core & HTML, enhancement)

Firefox 98
enhancement

Tracking

()

People

(Reporter: 709922234, Unassigned)

References

(Blocks 3 open bugs, )

Details

(4 keywords)

User Story

user-impact-score:326

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/100.0

Steps to reproduce:

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
See Also: → client-hints
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: parity-chrome
OS: Unspecified → All
Hardware: Unspecified → All
See Also: → 1865766

Supporting navigator.userAgentData would allow Duo authentication to support Firefox on Windows (because Duo could then differentiate between Windows 10 and 11) and would allow us to freeze the Fenix UA's Android version number (as "Android 10" like Chrome, bug 1865766).

https://help.duo.com/s/article/3455
https://help.duo.com/s/article/7220

Added support for the User-Agent Client Hints API, which improves the accuracy of browser and OS version information provided by the browser to the Duo Prompt for use with policy enforcement. The User-Agent Client Hints API is available in the following browsers: Chrome on all platforms, and Edge Chromium on macOS.

https://community.cisco.com/t5/duo-release-notes/d238-duo-release-notes-for-april-15-2022/ta-p/4878082

https://help.duo.com/s/article/4154

See Also: → 1876742

Example code to dump the navigator.userAgentData values:

navigator.userAgentData.getHighEntropyValues([
  "architecture",
  "bitness",
  "brands",
  "formFactor",
  "fullVersionList",
  "mobile",
  "model",
  "platform",
  "platformVersion",
  "uaFullVersion",
  "wow64"
  ])
.then(value => {
  console.log(value);
});

Windows' platformVersion values:

https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11

Severity: -- → N/A
Summary: Implement Navigator.userAgentData → Implement navigator.userAgentData
Blocks: 1865766
See Also: 1865766

    I question the necessity of such interfaces' existence.
    Why would the remote need to know about that?

Websites that offer applications in multiple formats for different operating systems and architectures can send you the proper file automatically if they know what you use.
If you have a phone or tablet, it can adjust features and layout compared to a computer with keyboard.
There are benefits, but not all pages or web apps need this.

If you have a phone or tablet, it can adjust features and layout compared to a computer with keyboard.

What about a phone or tablet with a keyboard (and a mouse)?

Layout can already be adjusted with media query, regardless of how you categorize the device. Touchability can also be queried (I forgot how). I hate when websites assume a typical use case and don't support the other (e.g. a phone with a keyboard and/or a mouse).

    Downloading for other architectures appears fairly common.
    Regardless, the users shall be aware of what they download.

Blocks: 1922952
No longer depends on: 1922952

Adding webcompat:blocked for now - there are still open (spec) issues that need better solutions or assessments.

No longer blocks: 1902505

This on longer blocks the webcompat bug 1902505. I cleared other related webcompat:* keywords to reflect the situation.

FWIW we just discussed this in https://github.com/ruffle-rs/ruffle-rs.github.io/pull/420 with regard suggesting to less tech-savvy Linux users which build of the Ruffle desktop application (aarch64 or x86_64) they should be downloading for their OS from our website. It was suggested we could detect the CPU architecture from the user agent and show only the relevant Linux download under the Desktop Application heading, but someone else said the UserAgent (as exposed to websites), is deprecated, and should be hardcoded to a well known constant everywhere (regardless of the actual user agent).

I mentioned that as far as I was aware, the modern way to check this would be to do this:

await navigator.userAgentData.getHighEntropyValues([ "architecture", "bitness" ]);

But I mentioned that currently that is Chromium-only.

Firefox does not currently support the navigator.userAgentData.getHighEntropyValues API.

Firefox's User-Agent string doesn't reveal Linux users' CPU architecture to websites. Firefox's User-Agent string will report "Linux x86_64" whether the real CPU architecture is x86_64, 32-bit x86, or aarch64. Unfortunately, that means your website can't automatically offer the correct application build on Linux.

You could recommend that Firefox users check the architecture field in their Firefox's about:telemetry#environment-data-tab page. If you wanted to get clever, you could try to check for Intel or Qualcomm GPUs exposed in WebGL's WEBGL_debug_renderer_info API, though that approach could be brittle: https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_debug_renderer_info

On Windows, Firefox's User-Agent string does distinguish between x86_64 and 32-bit x86 (by including or omitting the substring "Win64; x64" respectively). On ARM64 Windows, Firefox will pretend to be x86_64 on Windows 11 and x86 on Windows 10 (since Windows 10 doesn't support x64 emulation).

This MDN wiki page about Firefox's User-Agent strings has more details like these:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent/Firefox

you could try to check for Intel or Qualcomm GPUs exposed in WebGL's WEBGL_debug_renderer_info API, though that approach could be brittle

Not only that, but per https://bugzilla.mozilla.org/show_bug.cgi?id=1722782#c10 and the warning that logs on Firefox, that "may be removed" (though that may no longer be true).

Not only that, but per https://bugzilla.mozilla.org/show_bug.cgi?id=1722782#c10 and the warning that logs on Firefox, that "may be removed" (though that may no longer be true).

More specifically, the console warning says "WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.", though notably it has said that for years with no change so there's naturally an inclination to ask "if this will be removed, when?"

WebKit is trying to implement it. Any update on Mozilla?
https://github.com/WebKit/WebKit/pull/48790

See Also: → 1973894
User Story: (updated)
User Story: (updated)
You need to log in before you can comment on or make changes to this bug.