Bug 1433334 - Add installTelemetryInfo to addon installed from EnterprisePolicies. draft
authorLuca Greco <lgreco@mozilla.com>
Mon, 23 Jul 2018 20:12:39 +0200
changeset 830172 65074c492905f0549c213443d47c3cd4f78a1988
parent 830171 9bac3ac627611789a08a769cc9ccc27204790f29
child 830173 1318908e9e306958f4dc0b254c880ba6f799043f
push id118821
push userluca.greco@alcacoop.it
push dateMon, 20 Aug 2018 14:39:19 +0000
bugs1433334
milestone63.0a1
Bug 1433334 - Add installTelemetryInfo to addon installed from EnterprisePolicies. MozReview-Commit-ID: Fe1ZObda2N3
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -423,17 +423,18 @@ var Policies = {
               try {
                 xpiFile.initWithPath(location);
               } catch (e) {
                 log.error(`Invalid extension path location - ${location}`);
                 continue;
               }
               url = Services.io.newFileURI(xpiFile).spec;
             }
-            AddonManager.getInstallForURL(url, "application/x-xpinstall").then(install => {
+            AddonManager.getInstallForURL(url, "application/x-xpinstall", null, null, null, null, null,
+                                          {source: "enterprise-policy"}).then(install => {
               if (install.addon && install.addon.appDisabled) {
                 log.error(`Incompatible add-on - ${location}`);
                 install.cancel();
                 return;
               }
               let listener = {
               /* eslint-disable-next-line no-shadow */
                 onDownloadEnded: (install) => {
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
@@ -16,16 +16,19 @@ add_task(async function test_addon_insta
           addonID
         ]
       }
     }
   });
   await installPromise;
   let addon = await AddonManager.getAddonByID(addonID);
   isnot(addon, null, "Addon not installed.");
+
+  Assert.deepEqual(addon.installTelemetryInfo, {source: "enterprise-policy"},
+                   "Got the expected addon.installTelemetryInfo");
 });
 
 add_task(async function test_addon_locked() {
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
   await BrowserOpenAddonsMgr("addons://list/extension");
   // eslint-disable-next-line no-shadow
   await ContentTask.spawn(tab.linkedBrowser, {addonID}, async function({addonID}) {
     let list = content.document.getElementById("addon-list");