Bug 1268369 - Expose distribution.id as part of the appinfo configuration. r=Gijs
MozReview-Commit-ID: 4q7FVNgZtiK
--- 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");