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
This commit is contained in:
Alexandre Poirot 2019-06-21 09:15:00 +00:00
Родитель 36f5b54e49
Коммит d736224061
2 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -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",
};
}

Просмотреть файл

@ -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();