From d736224061db6603346decb6f53093bd8ed787b4 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Fri, 21 Jun 2019 09:15:00 +0000 Subject: [PATCH] Bug 1560280 - Return a real userAgent string in Browser.getVersion. r=remote-protocol-reviewers,ato Differential Revision: https://phabricator.services.mozilla.com/D35417 --HG-- extra : moz-landing-system : lando --- remote/domains/parent/Browser.jsm | 4 +++- remote/test/browser/browser_cdp.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/remote/domains/parent/Browser.jsm b/remote/domains/parent/Browser.jsm index fc3e6a8871a3..5cfd5b625b94 100644 --- a/remote/domains/parent/Browser.jsm +++ b/remote/domains/parent/Browser.jsm @@ -12,11 +12,13 @@ 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", }; } diff --git a/remote/test/browser/browser_cdp.js b/remote/test/browser/browser_cdp.js index 42de2c5fca58..51b573ebe4fb 100644 --- a/remote/test/browser/browser_cdp.js +++ b/remote/test/browser/browser_cdp.js @@ -36,6 +36,7 @@ add_task(async function testCDP() { 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();