Fix Bug 1496167 - Add installation source to addons installed from activitystream

This commit is contained in:
Luca Greco 2018-10-04 13:31:06 +02:00 коммит произвёл Kate Hudson
Родитель 77c6f0c058
Коммит 211d413f10
2 изменённых файлов: 11 добавлений и 1 удалений

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

@ -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) {}

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

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