Bug 1526836 [wpt PR 15296] - Implement `navigator.getUserAgent()`, a=testonly
authorMike West <mkwst@chromium.org>
Tue, 05 Mar 2019 11:11:39 +0000
changeset 525133 c08164922aaf04062e0fa9c16c59dbbe995a728a
parent 525132 1a78f6d88afaf4eef0101d3c9f9e8aa88ff38e3b
child 525134 9a1e1d9bc686e674d2af7e4b3f85c4425b0dbe80
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526836, 15296, 928670, 1458098, 631613
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526836 [wpt PR 15296] - Implement `navigator.getUserAgent()`, a=testonly Automatic update from web-platform-tests Implement `navigator.getUserAgent()` This patch is smaller than it looks. It basically does the following: 1. It introduces `blink::UserAgentMetadata`, and a corresponding mojo type in order to hold the various shards of data we'd like to expose about user agents (brand, version, platform, architecture, and model). 2. It threads these new types down from //chrome and //content/shell's implementations of `ContentBrowserClient` down into Blink via the same route we're using for the existing user-agent string (ChromeContentBrowserClient -> RenderProcessHost -> RenderThread -> Platform -> LocalFrameClient -> FrameLoader). 3. It extends `Navigator` with a new `NavigatorUserAgent` mixin that exposes `navigator.getUserAgent()`. This returns a promise that resolves with a newly defined `UserAgent` IDL dictionary type. So, the patch is huge, but not really that complex. Bug: 928670 Change-Id: I4f267e373864162264ad4d721650942b147b378d Reviewed-on: https://chromium-review.googlesource.com/c/1458098 Commit-Queue: Mike West <mkwst@chromium.org> Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Cr-Commit-Position: refs/heads/master@{#631613} -- wpt-commits: 290e4d77cd6418cf7b37351549c1ed2e5c62f557 wpt-pr: 15296
testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator_user_agent.tentative.html
testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator_user_agent.tentative.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator_user_agent.tentative.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+  test(t => {
+    assert_false("getUserAgent" in navigator);
+  }, "navigator.getUserAgent() is not available in non-secure contexts.");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator_user_agent.tentative.https.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/webrtc/dictionary-helper.js"></script>
+<script>
+  test(t => {
+    assert_true("getUserAgent" in navigator);
+  }, "navigator.getUserAgent() is exposed.");
+
+  promise_test(t => {
+    return navigator.getUserAgent()
+      .then(ua => {
+        // TODO(web-platform-tests/wpt#9106): Use `idlharness.js` once it supports dictionaries.
+        assert_string_field(ua, "brand");
+        assert_string_field(ua, "version");
+        assert_string_field(ua, "platform");
+        assert_string_field(ua, "architecture");
+        assert_string_field(ua, "model");
+      });
+  }, "navigator.getUserAgent() returns a UserAgentMetadata object.");
+</script>