From 211d413f1029348fc73b39adad5f18bfed7e779e Mon Sep 17 00:00:00 2001 From: Luca Greco Date: Thu, 4 Oct 2018 13:31:06 +0200 Subject: [PATCH] Fix Bug 1496167 - Add installation source to addons installed from activitystream --- lib/ASRouter.jsm | 7 ++++++- test/unit/asrouter/MessageLoaderUtils.test.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ASRouter.jsm b/lib/ASRouter.jsm index f0288cde0..922b622d7 100644 --- a/lib/ASRouter.jsm +++ b/lib/ASRouter.jsm @@ -215,7 +215,12 @@ const MessageLoaderUtils = { try { const aUri = Services.io.newURI(url); const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); - const install = await AddonManager.getInstallForURL(aUri.spec, "application/x-xpinstall"); + + // AddonManager installation source associated to the addons installed from activitystream + // (See Bug 1496167 for a rationale). + const amTelemetryInfo = {source: "activitystream"}; + const install = await AddonManager.getInstallForURL(aUri.spec, "application/x-xpinstall", null, + null, null, null, null, amTelemetryInfo); await AddonManager.installAddonFromWebpage("application/x-xpinstall", browser, systemPrincipal, install); } catch (e) {} diff --git a/test/unit/asrouter/MessageLoaderUtils.test.js b/test/unit/asrouter/MessageLoaderUtils.test.js index b91b72fc1..8e622f7d1 100644 --- a/test/unit/asrouter/MessageLoaderUtils.test.js +++ b/test/unit/asrouter/MessageLoaderUtils.test.js @@ -252,6 +252,11 @@ describe("MessageLoaderUtils", () => { assert.calledOnce(getInstallStub); assert.calledOnce(installAddonStub); + + // Verify that the expected installation source has been passed to the getInstallForURL + // method (See Bug 1496167 for a rationale). + assert.calledWithExactly(getInstallStub, "foo.com", "application/x-xpinstall", null, + null, null, null, null, {source: "activitystream"}); }); it("should not call the Addons API on invalid URLs", async () => { sandbox.stub(global.Services.scriptSecurityManager, "getSystemPrincipal").throws();