зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1632058 - Always get distribution values from default prefs. r=preferences-reviewers,jaws
Differential Revision: https://phabricator.services.mozilla.com/D93805
This commit is contained in:
Родитель
fee7bd0abf
Коммит
0f2af8604b
|
@ -23,27 +23,25 @@ async function init(aEvent) {
|
|||
return;
|
||||
}
|
||||
|
||||
var distroId = Services.prefs.getCharPref("distribution.id", "");
|
||||
let defaults = Services.prefs.getDefaultBranch(null);
|
||||
let distroId = defaults.getCharPref("distribution.id", "");
|
||||
if (distroId) {
|
||||
var distroAbout = Services.prefs.getStringPref("distribution.about", "");
|
||||
let distroAbout = defaults.getStringPref("distribution.about", "");
|
||||
// If there is about text, we always show it.
|
||||
if (distroAbout) {
|
||||
var distroField = document.getElementById("distribution");
|
||||
let distroField = document.getElementById("distribution");
|
||||
distroField.value = distroAbout;
|
||||
distroField.style.display = "block";
|
||||
}
|
||||
// If it's not a mozilla distribution, show the rest,
|
||||
// unless about text exists, then we always show.
|
||||
if (!distroId.startsWith("mozilla-") || distroAbout) {
|
||||
var distroVersion = Services.prefs.getCharPref(
|
||||
"distribution.version",
|
||||
""
|
||||
);
|
||||
let distroVersion = defaults.getCharPref("distribution.version", "");
|
||||
if (distroVersion) {
|
||||
distroId += " - " + distroVersion;
|
||||
}
|
||||
|
||||
var distroIdField = document.getElementById("distributionId");
|
||||
let distroIdField = document.getElementById("distributionId");
|
||||
distroIdField.value = distroId;
|
||||
distroIdField.style.display = "block";
|
||||
}
|
||||
|
|
|
@ -596,14 +596,12 @@ var gMainPane = {
|
|||
}
|
||||
}
|
||||
|
||||
let distroId = Services.prefs.getCharPref("distribution.id", "");
|
||||
let defaults = Services.prefs.getDefaultBranch(null);
|
||||
let distroId = defaults.getCharPref("distribution.id", "");
|
||||
if (distroId) {
|
||||
let distroString = distroId;
|
||||
|
||||
let distroVersion = Services.prefs.getCharPref(
|
||||
"distribution.version",
|
||||
""
|
||||
);
|
||||
let distroVersion = defaults.getCharPref("distribution.version", "");
|
||||
if (distroVersion) {
|
||||
distroString += " - " + distroVersion;
|
||||
}
|
||||
|
@ -612,7 +610,7 @@ var gMainPane = {
|
|||
distroIdField.value = distroString;
|
||||
distroIdField.hidden = false;
|
||||
|
||||
let distroAbout = Services.prefs.getStringPref("distribution.about", "");
|
||||
let distroAbout = defaults.getStringPref("distribution.about", "");
|
||||
if (distroAbout) {
|
||||
let distroField = document.getElementById("distribution");
|
||||
distroField.value = distroAbout;
|
||||
|
|
|
@ -72,12 +72,17 @@ add_task(async function testDistribution() {
|
|||
);
|
||||
|
||||
// distribution id is read from a preference
|
||||
await SpecialPowers.pushPrefEnv({ set: [["distribution.id", "funnelcake"]] });
|
||||
Services.prefs
|
||||
.getDefaultBranch(null)
|
||||
.setStringPref("distribution.id", "funnelcake");
|
||||
is(
|
||||
ClientEnvironment.distribution,
|
||||
"funnelcake",
|
||||
"distribution is read from preferences"
|
||||
);
|
||||
Services.prefs
|
||||
.getDefaultBranch(null)
|
||||
.setStringPref("distribution.id", "default");
|
||||
});
|
||||
|
||||
const mockClassify = { country: "FR", request_time: new Date(2017, 1, 1) };
|
||||
|
|
|
@ -1800,22 +1800,22 @@ EnvironmentCache.prototype = {
|
|||
* @return Object containing the partner data.
|
||||
*/
|
||||
_getPartner() {
|
||||
let defaults = Services.prefs.getDefaultBranch(null);
|
||||
let partnerData = {
|
||||
distributionId: Services.prefs.getStringPref(PREF_DISTRIBUTION_ID, null),
|
||||
distributionVersion: Services.prefs.getStringPref(
|
||||
distributionId: defaults.getStringPref(PREF_DISTRIBUTION_ID, null),
|
||||
distributionVersion: defaults.getCharPref(
|
||||
PREF_DISTRIBUTION_VERSION,
|
||||
null
|
||||
),
|
||||
partnerId: Services.prefs.getStringPref(PREF_PARTNER_ID, null),
|
||||
distributor: Services.prefs.getStringPref(PREF_DISTRIBUTOR, null),
|
||||
distributorChannel: Services.prefs.getStringPref(
|
||||
PREF_DISTRIBUTOR_CHANNEL,
|
||||
null
|
||||
),
|
||||
partnerId: defaults.getCharPref(PREF_PARTNER_ID, null),
|
||||
distributor: defaults.getCharPref(PREF_DISTRIBUTOR, null),
|
||||
distributorChannel: defaults.getCharPref(PREF_DISTRIBUTOR_CHANNEL, null),
|
||||
};
|
||||
|
||||
// Get the PREF_APP_PARTNER_BRANCH branch and append its children to partner data.
|
||||
let partnerBranch = Services.prefs.getBranch(PREF_APP_PARTNER_BRANCH);
|
||||
let partnerBranch = Services.prefs.getDefaultBranch(
|
||||
PREF_APP_PARTNER_BRANCH
|
||||
);
|
||||
partnerData.partnerNames = partnerBranch.getChildList("");
|
||||
|
||||
return partnerData;
|
||||
|
|
|
@ -14,7 +14,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
CommonUtils: "resource://services-common/utils.js",
|
||||
MockRegistrar: "resource://testing-common/MockRegistrar.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
Preferences: "resource://gre/modules/Preferences.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TelemetryEnvironmentTesting"];
|
||||
|
@ -147,7 +147,9 @@ var TelemetryEnvironmentTesting = {
|
|||
|
||||
// Spoof the preferences.
|
||||
for (let pref in prefsToSpoof) {
|
||||
Preferences.set(pref, prefsToSpoof[pref]);
|
||||
Services.prefs
|
||||
.getDefaultBranch(null)
|
||||
.setStringPref(pref, prefsToSpoof[pref]);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ var EXPORTED_SYMBOLS = ["ClientEnvironmentBase"];
|
|||
*/
|
||||
class ClientEnvironmentBase {
|
||||
static get distribution() {
|
||||
return Services.prefs.getCharPref("distribution.id", "default");
|
||||
return Services.prefs
|
||||
.getDefaultBranch(null)
|
||||
.getCharPref("distribution.id", "default");
|
||||
}
|
||||
|
||||
static get telemetry() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче