Backed out changeset a0be6d91b302 (bug 1502921) for toolkit/components/telemetry/tests/unit/*(eg. test_SubsessionChaining.js, test_TelemetryController.js) failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2019-01-18 01:43:52 +02:00
Родитель cc6a6c8063
Коммит 45f056b544
15 изменённых файлов: 2 добавлений и 102 удалений

Просмотреть файл

@ -48,21 +48,6 @@ const MAX_EXPERIMENT_TYPE_LENGTH = 20;
// eslint-disable-next-line no-unused-vars
var Policy = {
now: () => new Date(),
_intlLoaded: false,
_browserDelayedStartup() {
if (Policy._intlLoaded) {
return Promise.resolve();
}
return new Promise(resolve => {
let startupTopic = "browser-delayed-startup-finished";
Services.obs.addObserver(function observer(subject, topic) {
if (topic == startupTopic) {
Services.obs.removeObserver(observer, startupTopic);
resolve();
}
}, startupTopic);
});
},
};
// This is used to buffer calls to setExperimentActive and friends, so that we
@ -335,22 +320,6 @@ function getSystemLocale() {
}
}
function getIntlSettings() {
let osprefs = Cc["@mozilla.org/intl/ospreferences;1"].getService(Ci.mozIOSPreferences);
return {
requestedLocales: Services.locale.requestedLocales,
availableLocales: Services.locale.availableLocales,
appLocales: Services.locale.appLocalesAsBCP47,
systemLocales: osprefs.systemLocales,
regionalPrefsLocales: osprefs.regionalPrefsLocales,
acceptLanguages:
Services.prefs.getComplexValue("intl.accept_languages", Ci.nsIPrefLocalizedString)
.data
.split(",")
.map(str => str.trim()),
};
}
/**
* Safely get a sysinfo property and return its value. If the property is not
* available, return aDefault.
@ -935,7 +904,6 @@ function EnvironmentCache() {
p.push(this._loadAttributionAsync());
}
p.push(this._loadAutoUpdateAsync());
p.push(this._loadIntlData());
for (const [id, {branch, options}] of gActiveExperimentStartupBuffer.entries()) {
this.setExperimentActive(id, branch, options);
@ -1448,9 +1416,6 @@ EnvironmentCache.prototype = {
e10sMultiProcesses: Services.appinfo.maxWebProcessCount,
telemetryEnabled: Utils.isTelemetryEnabled,
locale: getBrowserLocale(),
// We need to wait for browser-delayed-startup-finished to ensure that the locales
// have settled, once that's happened we can get the intl data directly.
intl: Policy._intlLoaded ? getIntlSettings() : {},
update: {
channel: updateChannel,
enabled: !Services.policies || Services.policies.isAllowed("appUpdate"),
@ -1566,17 +1531,6 @@ EnvironmentCache.prototype = {
this._currentEnvironment.settings.update.autoDownload = this._updateAutoDownloadCache;
},
/**
* Get i18n data about the system.
* @return A promise of completion.
*/
async _loadIntlData() {
// Wait for the startup topic.
await Policy._browserDelayedStartup();
this._currentEnvironment.settings.intl = getIntlSettings();
Policy._intlLoaded = true;
},
/**
* Get the partner data in object form.
* @return Object containing the partner data.

Просмотреть файл

@ -48,14 +48,6 @@ Structure:
e10sEnabled: <bool>, // whether e10s is on, i.e. browser tabs open by default in a different process
telemetryEnabled: <bool>, // false on failure
locale: <string>, // e.g. "it", null on failure
intl: {
requestedLocales: [ <string>, ... ], // The locales that are being requested.
availableLocales: [ <string>, ... ], // The locales that are available for use.
appLocales: [ <string>, ... ], // The negotiated locales that are being used.
systemLocales: [ <string>, ... ], // The locales for the OS.
regionalPrefsLocales: [ <string>, ... ], // The regional preferences for the OS.
acceptLanguages: [ <string>, ... ], // The languages for the Accept-Languages header.
},
update: {
channel: <string>, // e.g. "release", null on failure
enabled: <bool>, // true on failure
@ -468,4 +460,3 @@ Version History
- Firefox 61:
- Removed empty ``addons.activeExperiment`` (`bug 1452935 <https://bugzilla.mozilla.org/show_bug.cgi?id=1452935>`_).

Просмотреть файл

@ -294,13 +294,6 @@ function fakePrioEncode() {
m.Policy.prioEncode = (batchID, prioParams) => prioParams;
}
function fakeIntlReady() {
const m = ChromeUtils.import("resource://gre/modules/TelemetryEnvironment.jsm", {});
m.Policy._intlLoaded = true;
// Dispatch the observer event in case the promise has been registered already.
Services.obs.notifyObservers(null, "browser-delayed-startup-finished");
}
// Return a date that is |offset| ms in the future from |date|.
function futureDate(date, offset) {
return new Date(date.getTime() + offset);

Просмотреть файл

@ -75,7 +75,6 @@ add_task(async function() {
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -90,7 +90,6 @@ add_task(async function() {
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();
if (runningInParent) {
// Make sure we don't generate unexpected pings due to pref changes.

Просмотреть файл

@ -140,7 +140,6 @@ add_task(async function() {
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();
if (runningInParent) {
setParentScalars();

Просмотреть файл

@ -88,7 +88,6 @@ add_task(async function test_setup() {
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();
});

Просмотреть файл

@ -45,7 +45,6 @@ add_task(async function test_setup() {
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -94,7 +94,6 @@ add_task(async function test_setup() {
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -27,7 +27,6 @@ add_task(async function test_setup() {
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -407,9 +407,8 @@ function checkSettingsSection(data) {
const EXPECTED_FIELDS_TYPES = {
blocklistEnabled: "boolean",
e10sEnabled: "boolean",
intl: "object",
locale: "string",
telemetryEnabled: "boolean",
locale: "string",
update: "object",
userPrefs: "object",
};
@ -450,23 +449,6 @@ function checkSettingsSection(data) {
Assert.equal(typeof data.settings.attribution, "object");
Assert.equal(data.settings.attribution.source, "google.com");
}
checkIntlSettings(data.settings);
}
function checkIntlSettings({intl}) {
let fields = [
"requestedLocales",
"availableLocales",
"appLocales",
"systemLocales",
"regionalPrefsLocales",
"acceptLanguages",
];
for (let field of fields) {
Assert.ok(Array.isArray(intl[field]), `${field} is an array`);
}
}
function checkProfileSection(data) {
@ -927,20 +909,11 @@ add_task(async function test_checkEnvironment() {
Assert.equal(AddonManagerPrivate.isDBLoaded(), false,
"addons database is not loaded");
let data = TelemetryEnvironment.currentEnvironment;
checkAddonsSection(data, false, true);
// Check that settings.intl is lazily loaded.
Assert.equal(typeof data.settings.intl, "object", "intl is initially an object");
Assert.equal(Object.keys(data.settings.intl).length, 0, "intl is initially empty");
checkAddonsSection(TelemetryEnvironment.currentEnvironment, false, true);
// Now continue with startup.
let initPromise = TelemetryEnvironment.onInitialized();
finishAddonManagerStartup();
// Fake the delayed startup event for intl data to load.
fakeIntlReady();
let environmentData = await initPromise;
checkEnvironmentData(environmentData, {isInitial: true});

Просмотреть файл

@ -53,7 +53,6 @@ add_task(async function test_setup() {
do_get_profile(true);
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -136,7 +136,6 @@ add_task(async function test_setup() {
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -442,7 +442,6 @@ add_task(async function test_setup() {
do_get_profile();
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.
await setEmptyPrefWatchlist();

Просмотреть файл

@ -22,7 +22,6 @@ add_task(async function test_setup() {
// Telemetry needs the AddonManager.
loadAddonManager();
finishAddonManagerStartup();
fakeIntlReady();
// Make profile available for |TelemetryController.testShutdown()|.
do_get_profile();