Bug 1268369 - Expose distribution.id as part of the appinfo configuration. r=Gijs draft
authorHector Zhao <bzhao@mozilla.com>
Thu, 28 Apr 2016 15:23:55 +0800
changeset 363144 8e8914d0eba96cc3c598ef6b846b06fc21b93d5c
parent 362943 0a25833062a880f369e6f9f622413a94cc671bf4
child 519950 6b1f5b73689e951d0401c0e84d64679254af120e
push id17111
push userbzhao@mozilla.com
push dateWed, 04 May 2016 01:05:05 +0000
reviewersGijs
bugs1268369
milestone49.0a1
Bug 1268369 - Expose distribution.id as part of the appinfo configuration. r=Gijs MozReview-Commit-ID: 4q7FVNgZtiK
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour.js
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -1866,16 +1866,26 @@ this.UITour = {
   },
 
   getConfiguration: function(aMessageManager, aWindow, aConfiguration, aCallbackID) {
     switch (aConfiguration) {
       case "appinfo":
         let props = ["defaultUpdateChannel", "version"];
         let appinfo = {};
         props.forEach(property => appinfo[property] = Services.appinfo[property]);
+
+        // Identifier of the partner repack, as stored in preference "distribution.id"
+        // and included in Firefox and other update pings. Note this is not the same as
+        // Services.appinfo.distributionID (value of MOZ_DISTRIBUTION_ID is set at build time).
+        let distribution = "default";
+        try {
+          distribution = Services.prefs.getDefaultBranch("distribution.").getCharPref("id");
+        } catch(e) {}
+        appinfo["distribution"] = distribution;
+
         let isDefaultBrowser = null;
         try {
           let shell = aWindow.getShellService();
           if (shell) {
             isDefaultBrowser = shell.isDefaultBrowser(false);
           }
         } catch (e) {}
         appinfo["defaultBrowser"] = isDefaultBrowser;
--- a/browser/components/uitour/test/browser_UITour.js
+++ b/browser/components/uitour/test/browser_UITour.js
@@ -287,16 +287,32 @@ var tests = [
         ok(typeof(result[property]) !== "undefined", "Check " + property + " isn't undefined.");
         is(result[property], Services.appinfo[property], "Should have the same " + property + " property.");
       }
       done();
     }
 
     gContentAPI.getConfiguration("appinfo", callback);
   },
+  function test_getConfigurationDistribution(done) {
+    gContentAPI.getConfiguration("appinfo", (result) => {
+      ok(typeof(result.distribution) !== "undefined", "Check distribution isn't undefined.");
+      is(result.distribution, "default", "Should be \"default\" without preference set.");
+
+      let defaults = Services.prefs.getDefaultBranch("distribution.");
+      let testDistributionID = "TestDistribution";
+      defaults.setCharPref("id", testDistributionID);
+      gContentAPI.getConfiguration("appinfo", (result) => {
+        ok(typeof(result.distribution) !== "undefined", "Check distribution isn't undefined.");
+        is(result.distribution, testDistributionID, "Should have the distribution as set in preference.");
+
+        done();
+      });
+    });
+  },
   function test_addToolbarButton(done) {
     let placement = CustomizableUI.getPlacementOfWidget("panic-button");
     is(placement, null, "default UI has panic button in the palette");
 
     gContentAPI.getConfiguration("availableTargets", (data) => {
       let available = (data.targets.indexOf("forget") != -1);
       ok(!available, "Forget button should not be available by default");