Backed out 4 changesets (bug 1408433, bug 1406391, bug 1408512) for crashing tests by touching the network contacting incoming.telemetry.mozilla.org on nightly builds

Backed out changeset 9bfd4b0927dc (bug 1408433)
Backed out changeset 555850d5107e (bug 1408512)
Backed out changeset 15d959b9123e (bug 1406391)
Backed out changeset e1f34ba9cecc (bug 1406391)

MozReview-Commit-ID: BVoGRsD73Hf
This commit is contained in:
Phil Ringnalda 2017-10-27 21:08:27 -07:00
Родитель 28b1c813ea
Коммит 4bc2b1615d
23 изменённых файлов: 73 добавлений и 30 удалений

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

@ -27,6 +27,10 @@ function assertCount(snapshot, expectedCount) {
add_task(async function setup() {
// These probes are opt-in, meaning we only capture them if extended
// Telemetry recording is enabled.
await SpecialPowers.pushPrefEnv({
set: [["toolkit.telemetry.enabled", true]]
});
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(() => {

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

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(async function test() {
await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
let engine = await promiseNewEngine("testEngine.xml");
let histogramKey = "other-" + engine.name + ".contextmenu";
let numSearchesBefore = 0;

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

@ -76,6 +76,7 @@ function test() {
Services.obs.addObserver(observer, "browser-search-engine-modified");
SpecialPowers.pushPrefEnv({set: [
["toolkit.telemetry.enabled", true],
["browser.search.widget.inNavBar", true],
]}).then(function() {
Services.search.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine.xml",

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

@ -153,6 +153,7 @@ add_task(async function setup() {
};
const prefs = [
"toolkit.telemetry.enabled",
"browser.translation.detectLanguage",
"browser.translation.ui.show"
];

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

@ -26,6 +26,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
"resource://gre/modules/TelemetryEnvironment.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryLog",
"resource://gre/modules/TelemetryLog.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryUtils",
"resource://gre/modules/TelemetryUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CommonUtils",
"resource://services-common/utils.js");
@ -50,6 +52,8 @@ const PREF_LOGGING_DUMP = PREF_LOGGING + ".dump"; // experiments.logging
const PREF_MANIFEST_URI = "manifest.uri"; // experiments.logging.manifest.uri
const PREF_FORCE_SAMPLE = "force-sample-value"; // experiments.force-sample-value
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
const CACHE_WRITE_RETRY_DELAY_SEC = 60 * 3;
@ -382,6 +386,8 @@ Experiments.Experiments.prototype = {
this.updateManifest();
} else if (data == PREF_BRANCH + PREF_ENABLED) {
this._toggleExperimentsEnabled(gPrefs.getBoolPref(PREF_ENABLED, false));
} else if (data == PREF_TELEMETRY_ENABLED) {
this._telemetryStatusChanged();
}
break;
}
@ -391,13 +397,15 @@ Experiments.Experiments.prototype = {
this._shutdown = false;
configureLogging();
gExperimentsEnabled = gPrefs.getBoolPref(PREF_ENABLED, false) && Services.telemetry.canRecordExtended;
gExperimentsEnabled = gPrefs.getBoolPref(PREF_ENABLED, false) && TelemetryUtils.isTelemetryEnabled;
this._log.trace("enabled=" + gExperimentsEnabled + ", " + this.enabled);
Services.prefs.addObserver(PREF_BRANCH + PREF_LOGGING, configureLogging);
Services.prefs.addObserver(PREF_BRANCH + PREF_MANIFEST_URI, this, true);
Services.prefs.addObserver(PREF_BRANCH + PREF_ENABLED, this, true);
Services.prefs.addObserver(PREF_TELEMETRY_ENABLED, this, true);
AddonManager.shutdown.addBlocker("Experiments.jsm shutdown",
this.uninit.bind(this),
this._getState.bind(this)
@ -445,6 +453,8 @@ Experiments.Experiments.prototype = {
Services.prefs.removeObserver(PREF_BRANCH + PREF_MANIFEST_URI, this);
Services.prefs.removeObserver(PREF_BRANCH + PREF_ENABLED, this);
Services.prefs.removeObserver(PREF_TELEMETRY_ENABLED, this);
if (this._timer) {
this._timer.clear();
}
@ -588,7 +598,7 @@ Experiments.Experiments.prototype = {
async _toggleExperimentsEnabled(enabled) {
this._log.trace("_toggleExperimentsEnabled(" + enabled + ")");
let wasEnabled = gExperimentsEnabled;
gExperimentsEnabled = enabled && Services.telemetry.canRecordExtended;
gExperimentsEnabled = enabled && TelemetryUtils.isTelemetryEnabled;
if (wasEnabled == gExperimentsEnabled) {
return;
@ -604,6 +614,10 @@ Experiments.Experiments.prototype = {
}
},
_telemetryStatusChanged() {
this._toggleExperimentsEnabled(gPrefs.getBoolPref(PREF_ENABLED, false));
},
/**
* Returns a promise that is resolved with an array of `ExperimentInfo` objects,
* which provide info on the currently and recently active experiments.

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

@ -26,6 +26,7 @@ const PREF_LOGGING_LEVEL = "experiments.logging.level";
const PREF_LOGGING_DUMP = "experiments.logging.dump";
const PREF_MANIFEST_URI = "experiments.manifest.uri";
const PREF_FETCHINTERVAL = "experiments.manifest.fetchIntervalSeconds";
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
function getExperimentPath(base) {
let p = do_get_cwd();
@ -192,4 +193,6 @@ function replaceExperiments(experiment, list) {
});
}
Services.telemetry.canRecordExtended = true;
// Experiments require Telemetry to be enabled, and that's not true for debug
// builds. Let's just enable it here instead of going through each test.
Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true);

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

@ -10,11 +10,19 @@ add_test(function test_experiments_activation() {
loadAddonManager();
Services.prefs.setBoolPref(PREF_EXPERIMENTS_ENABLED, true);
Services.telemetry.canRecordExtended = false;
Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, false);
let experiments = Experiments.instance();
Assert.ok(!experiments.enabled, "Experiments must be disabled if Telemetry is disabled.");
// Patch updateManifest to not do anything when the pref is switched back to true,
// otherwise it attempts to connect to the server.
experiments.updateManifest = () => Promise.resolve();
Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true);
Assert.ok(experiments.enabled, "Experiments must be re-enabled if Telemetry is re-enabled");
run_next_test();
});

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

@ -25,6 +25,7 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({"set": [
["dom.select_events.enabled", true], // We want select events to be fired.
["toolkit.telemetry.enabled", true] // And Extended Telemetry to be enabled.
]});
// Enable event recording for the events tested here.

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

@ -27,6 +27,9 @@ add_task(async function setup() {
let engineOneOff = Services.search.getEngineByName("MozSearch2");
Services.search.moveEngine(engineOneOff, 0);
// Enable Extended Telemetry.
await SpecialPowers.pushPrefEnv({"set": [["toolkit.telemetry.enabled", true]]});
// Enable event recording for the events tested here.
Services.telemetry.setEventRecordingEnabled("navigation", true);

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

@ -90,6 +90,9 @@ add_task(async function setup() {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
// Enable Extended Telemetry.
await SpecialPowers.pushPrefEnv({"set": [["toolkit.telemetry.enabled", true]]});
// Enable event recording for the events tested here.
Services.telemetry.setEventRecordingEnabled("navigation", true);

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

@ -89,6 +89,9 @@ add_task(async function setup() {
// Enable the urlbar one-off buttons.
Services.prefs.setBoolPref(ONEOFF_URLBAR_PREF, true);
// Enable Extended Telemetry.
await SpecialPowers.pushPrefEnv({"set": [["toolkit.telemetry.enabled", true]]});
// Enable local telemetry recording for the duration of the tests.
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;

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

@ -26,6 +26,7 @@ add_task(async function test_memory_distribution() {
return;
}
await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
Services.telemetry.canRecordExtended = true;
let histogram = Services.telemetry.getKeyedHistogramById("MEMORY_DISTRIBUTION_AMONG_CONTENT");

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

@ -8,6 +8,7 @@ add_task(async function test_memory_distribution() {
return;
}
await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
let canRecordExtended = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(() => Services.telemetry.canRecordExtended = canRecordExtended);

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

@ -408,6 +408,7 @@ function SetupPrefTestEnvironment(which, additional_prefs) {
settings.use_hsts],
["security.mixed_content.send_hsts_priming",
settings.send_hsts_priming],
["toolkit.telemetry.enabled", true],
];
if (additional_prefs) {

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

@ -22,7 +22,7 @@ user_pref("javascript.options.strict", false);
user_pref("javascript.options.werror", false);
user_pref("toolkit.startup.max_resumed_crashes", -1);
user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);
user_pref("datareporting.healthreport.uploadEnabled", false);
user_pref("toolkit.telemetry.enabled", false);
user_pref("browser.safebrowsing.phishing.enabled", false);
user_pref("browser.safebrowsing.malware.enabled", false);
user_pref("browser.safebrowsing.blockedURIs.enabled", false);

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

@ -87,8 +87,6 @@ user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
// server in the middle of the tests.
user_pref("toolkit.telemetry.enabled", false);
user_pref("toolkit.telemetry.unified", false);
user_pref("datareporting.healthreport.uploadEnabled", false);
user_pref("experiments.enabled", false);
// Likewise for safebrowsing.
user_pref("browser.safebrowsing.phishing.enabled", false);
user_pref("browser.safebrowsing.malware.enabled", false);

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

@ -4775,7 +4775,6 @@ pref_InitInitialObjects()
NS_ENSURE_SUCCESS(
rv, Err("pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST) failed"));
#ifdef MOZ_WIDGET_ANDROID
// Set up the correct default for toolkit.telemetry.enabled. If this build
// has MOZ_TELEMETRY_ON_BY_DEFAULT *or* we're on the beta channel, telemetry
// is on by default, otherwise not. This is necessary so that beta users who
@ -4794,19 +4793,6 @@ pref_InitInitialObjects()
#endif
PREF_SetBoolPref(kTelemetryPref, prerelease, true);
}
#else
// For platforms with Unified Telemetry (here meaning not-Android),
// toolkit.telemetry.enabled determines whether we send "extended" data.
// We only want extended data from pre-release channels due to size.
if (!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "nightly") ||
!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "aurora") ||
!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "beta")) {
PREF_SetBoolPref(kTelemetryPref, true, true);
} else {
PREF_SetBoolPref(kTelemetryPref, false, true);
}
PREF_LockPref(kTelemetryPref, true);
#endif // MOZ_WIDGET_ANDROID
NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
nullptr,

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

@ -403,6 +403,8 @@ class FirefoxProfile(Profile):
'security.notification_enable_delay': 0,
# Suppress automatic safe mode after crashes
'toolkit.startup.max_resumed_crashes': -1,
# Don't report telemetry information
'toolkit.telemetry.enabled': False,
# Don't send Telemetry reports to the production server. This is
# needed as Telemetry sends pings also if FHR upload is enabled.
'toolkit.telemetry.server': 'http://%(server)s/telemetry-dummy/',

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

@ -17,6 +17,12 @@ const HISTOGRAM = "WEBEXT_CONTENT_SCRIPT_INJECTION_MS";
add_task(async function test_contentscript_telemetry() {
// Turn on telemetry and reset it to the previous state once the test is completed.
// NOTE: This is only needed on Android (which does not properly support unified telemetry,
// while we're always recording opt-out telemetry on desktop).
// Switching the "toolkit.telemetry.enabled" preference
// (e.g. using SpecialPowers.pushPrefEnv) is unfortunately not enough,
// because the TelemetryController has been already initialized when this
// code is going to be executed.
const telemetryCanRecordBase = SpecialPowers.Services.telemetry.canRecordBase;
SpecialPowers.Services.telemetry.canRecordBase = true;
SimpleTest.registerCleanupFunction(() => {

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

@ -555,14 +555,10 @@ add_task(async function test_pref_observer() {
await TelemetrySend.setup(true);
const IS_UNIFIED_TELEMETRY = Services.prefs.getBoolPref(TelemetryUtils.Preferences.Unified, false);
let origTelemetryEnabled = Services.prefs.getBoolPref(TelemetryUtils.Preferences.TelemetryEnabled);
let origFhrUploadEnabled = Services.prefs.getBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled);
if (!IS_UNIFIED_TELEMETRY) {
Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
}
Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true);
Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, true);
function waitAnnotateCrashReport(expectedValue, trigger) {
@ -605,13 +601,17 @@ add_task(async function test_pref_observer() {
});
}
const IS_UNIFIED_TELEMETRY = Services.prefs.getBoolPref(TelemetryUtils.Preferences.Unified, false);
await waitAnnotateCrashReport(IS_UNIFIED_TELEMETRY, () => Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, false));
await waitAnnotateCrashReport(true, () => Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true));
await waitAnnotateCrashReport(!IS_UNIFIED_TELEMETRY, () => Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, false));
await waitAnnotateCrashReport(true, () => Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, true));
if (!IS_UNIFIED_TELEMETRY) {
Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, origTelemetryEnabled);
}
Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, origTelemetryEnabled);
Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, origFhrUploadEnabled);
});

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

@ -82,6 +82,7 @@ add_task(async function initializeState() {
registerCleanupFunction(() => {
Services.prefs.clearUserPref("experiments.enabled");
Services.prefs.clearUserPref("toolkit.telemetry.enabled");
if (gHttpServer) {
gHttpServer.stop(() => {});
if (gSavedManifestURI !== undefined) {
@ -265,7 +266,7 @@ add_task(async function testActivateExperiment() {
// We need to remove the cache file to help ensure consistent state.
await OS.File.remove(gExperiments._cacheFilePath);
Services.telemetry.canRecordExtended = true;
Services.prefs.setBoolPref("toolkit.telemetry.enabled", true);
Services.prefs.setBoolPref("experiments.enabled", true);
info("Initializing experiments service.");
@ -607,6 +608,8 @@ add_task(async function testCleanup() {
await OS.File.remove(gExperiments._cacheFilePath);
await gExperiments.uninit();
await gExperiments.init();
Services.prefs.clearUserPref("toolkit.telemetry.enabled");
}
// Check post-conditions.

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

@ -33,6 +33,7 @@ const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual";
const PREFBRANCH_APP_PARTNER = "app.partner.";
const PREF_DISTRIBUTION_ID = "distribution.id";
const PREF_DISTRIBUTION_VERSION = "distribution.version";
const PREF_TOOLKIT_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
const NS_APP_USER_PROFILE_50_DIR = "ProfD";

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

@ -1037,6 +1037,8 @@ function setDefaultPrefs() {
// Some apps set this preference to true by default
Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, false);
}
// In case telemetry is enabled for xpcshell tests.
Services.prefs.setBoolPref(PREF_TOOLKIT_TELEMETRY_ENABLED, false);
}
/**