Bug 1560280 - Return a real userAgent string in Browser.getVersion. r=remote-protocol-reviewers,ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Fri, 21 Jun 2019 09:15:00 +0000
changeset 479801 faba9386d77e47365668caaaff18e1e56ded821f
parent 479800 2d0328537dcd8e66e8d4cf4ecdad7fe1b7162682
child 479802 7414bfc0414566bb9a9e883e5a54e53a95824eb1
push id36182
push usershindli@mozilla.com
push dateFri, 21 Jun 2019 16:13:23 +0000
treeherdermozilla-central@2901d32eddaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersremote-protocol-reviewers, ato
bugs1560280
milestone69.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 1560280 - Return a real userAgent string in Browser.getVersion. r=remote-protocol-reviewers,ato Differential Revision: https://phabricator.services.mozilla.com/D35417
remote/domains/parent/Browser.jsm
remote/test/browser/browser_cdp.js
--- a/remote/domains/parent/Browser.jsm
+++ b/remote/domains/parent/Browser.jsm
@@ -7,21 +7,23 @@
 var EXPORTED_SYMBOLS = ["Browser"];
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {Domain} = ChromeUtils.import("chrome://remote/content/domains/Domain.jsm");
 
 class Browser extends Domain {
   getVersion() {
     const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+    const { userAgent } = Cc["@mozilla.org/network/protocol;1?name=http"]
+                            .getService(Ci.nsIHttpProtocolHandler);
     return {
       protocolVersion: "1",
       product: (isHeadless ? "Headless " : "") + "Firefox",
       revision: "1",
-      userAgent: "Firefox",
+      userAgent,
       jsVersion: "1.8.5",
     };
   }
 
   close() {
     Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
   }
 }
--- a/remote/test/browser/browser_cdp.js
+++ b/remote/test/browser/browser_cdp.js
@@ -31,16 +31,17 @@ add_task(async function testCDP() {
   const {Browser, Log, Page} = client;
   ok("Browser" in client, "Browser domain is available");
   ok("Log" in client, "Log domain is available");
   ok("Page" in client, "Page domain is available");
 
   const version = await Browser.getVersion();
   const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
   is(version.product, isHeadless ? "Headless Firefox" : "Firefox", "Browser.getVersion works and depends on headless mode");
+  is(version.userAgent, window.navigator.userAgent, "Browser.getVersion().userAgent is correct");
 
   // receive console.log messages and print them
   Log.enable();
   ok(true, "Log domain has been enabled");
 
   Log.entryAdded(({entry}) => {
     const {timestamp, level, text, args} = entry;
     const msg = text || args.join(" ");