Bug 1433334 - Add installTelemetryInfo to addon installed from "drag-and-drop" file urls on Firefox Desktop. draft
authorLuca Greco <lgreco@mozilla.com>
Mon, 23 Jul 2018 20:20:20 +0200
changeset 830171 9bac3ac627611789a08a769cc9ccc27204790f29
parent 830170 f15ffb73681ff4fd3124772cb045f8575fcb92c1
child 830172 65074c492905f0549c213443d47c3cd4f78a1988
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 "drag-and-drop" file urls on Firefox Desktop. MozReview-Commit-ID: JiYgsTVbtcL
browser/base/content/browser.js
toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -971,17 +971,18 @@ function serializeInputStream(aStream) {
  */
 function handleUriInChrome(aBrowser, aUri) {
   if (aUri.scheme == "file") {
     try {
       let mimeType = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
                                               .getTypeFromURI(aUri);
       if (mimeType == "application/x-xpinstall") {
         let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-        AddonManager.getInstallForURL(aUri.spec, mimeType).then(install => {
+        AddonManager.getInstallForURL(aUri.spec, mimeType, null, null, null, null, null,
+                                      {source: "file-url"}).then(install => {
           AddonManager.installAddonFromWebpage(mimeType, aBrowser, systemPrincipal,
                                                install);
         });
         return true;
       }
     } catch (e) {
       return false;
     }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_localfile.js
@@ -18,16 +18,19 @@ function test() {
 
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     gBrowser.loadURI(xpipath);
   });
 }
 
 function install_ended(install, addon) {
+  Assert.deepEqual(install.installTelemetryInfo, {source: "file-url"},
+                   "Got the expected install.installTelemetryInfo");
+
   install.cancel();
 }
 
 function finish_test(count) {
   is(count, 1, "1 Add-on should have been successfully installed");
 
   gBrowser.removeCurrentTab();
   Harness.finish();