From 8e6dd31d551835b1b9a45e05d612206a3d8d5639 Mon Sep 17 00:00:00 2001 From: Chris H-C Date: Wed, 18 Oct 2017 10:40:08 -0400 Subject: [PATCH] bug 1406391 - Remove toolkit.telemetry.enabled manipulation from tests r=Dexter Minor note: reftests should've turned off uploadEnabled in the first place. MozReview-Commit-ID: 9spzuUAXwwP --- .../test/browser_contextSearchTabPosition.js | 1 - .../search/test/browser_healthreport.js | 1 - .../test/browser_translation_telemetry.js | 1 - browser/experiments/test/xpcshell/head.js | 5 +---- .../test/xpcshell/test_telemetry_disabled.js | 10 +--------- .../browser/browser_UsageTelemetry_content.js | 1 - .../browser_UsageTelemetry_content_aboutHome.js | 3 --- .../browser/browser_UsageTelemetry_searchbar.js | 3 --- .../browser/browser_UsageTelemetry_urlbar.js | 3 --- .../browser_memory_distribution_telemetry.js | 1 - .../browser_remote_navigation_delay_telemetry.js | 1 - dom/security/test/hsts/head.js | 1 - js/src/tests/user.js | 2 +- layout/tools/reftest/reftest-preferences.js | 2 ++ testing/mozbase/mozprofile/mozprofile/profile.py | 2 -- .../test_chrome_ext_contentscript_telemetry.html | 6 ------ .../telemetry/tests/unit/test_TelemetrySend.js | 16 ++++++++-------- .../test/browser/browser_experiments.js | 5 +---- toolkit/mozapps/update/tests/data/shared.js | 1 - .../update/tests/data/xpcshellUtilsAUS.js | 2 -- 20 files changed, 14 insertions(+), 53 deletions(-) diff --git a/browser/components/search/test/browser_contextSearchTabPosition.js b/browser/components/search/test/browser_contextSearchTabPosition.js index bd558d2bbf96..acff37cdd433 100644 --- a/browser/components/search/test/browser_contextSearchTabPosition.js +++ b/browser/components/search/test/browser_contextSearchTabPosition.js @@ -3,7 +3,6 @@ * 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; diff --git a/browser/components/search/test/browser_healthreport.js b/browser/components/search/test/browser_healthreport.js index ae69f607cc70..29b3fe856f0c 100644 --- a/browser/components/search/test/browser_healthreport.js +++ b/browser/components/search/test/browser_healthreport.js @@ -76,7 +76,6 @@ 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", diff --git a/browser/components/translation/test/browser_translation_telemetry.js b/browser/components/translation/test/browser_translation_telemetry.js index a42d27579980..540af3f7b023 100644 --- a/browser/components/translation/test/browser_translation_telemetry.js +++ b/browser/components/translation/test/browser_translation_telemetry.js @@ -153,7 +153,6 @@ add_task(async function setup() { }; const prefs = [ - "toolkit.telemetry.enabled", "browser.translation.detectLanguage", "browser.translation.ui.show" ]; diff --git a/browser/experiments/test/xpcshell/head.js b/browser/experiments/test/xpcshell/head.js index 153305ee80d3..43d6ca00ff91 100644 --- a/browser/experiments/test/xpcshell/head.js +++ b/browser/experiments/test/xpcshell/head.js @@ -26,7 +26,6 @@ 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(); @@ -193,6 +192,4 @@ function replaceExperiments(experiment, list) { }); } -// 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); +Services.telemetry.canRecordExtended = true; diff --git a/browser/experiments/test/xpcshell/test_telemetry_disabled.js b/browser/experiments/test/xpcshell/test_telemetry_disabled.js index 7ef5f87cead9..aa9ac0d40cef 100644 --- a/browser/experiments/test/xpcshell/test_telemetry_disabled.js +++ b/browser/experiments/test/xpcshell/test_telemetry_disabled.js @@ -10,19 +10,11 @@ add_test(function test_experiments_activation() { loadAddonManager(); Services.prefs.setBoolPref(PREF_EXPERIMENTS_ENABLED, true); - Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, false); + Services.telemetry.canRecordExtended = 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(); }); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_content.js b/browser/modules/test/browser/browser_UsageTelemetry_content.js index 60fef492c3cf..16d8945ccd02 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_content.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_content.js @@ -25,7 +25,6 @@ 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. diff --git a/browser/modules/test/browser/browser_UsageTelemetry_content_aboutHome.js b/browser/modules/test/browser/browser_UsageTelemetry_content_aboutHome.js index 7f2239ab15ab..339f9021fd5e 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_content_aboutHome.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_content_aboutHome.js @@ -27,9 +27,6 @@ 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); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js b/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js index 31a2ce5e1dbe..5c18e8a36b92 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js @@ -90,9 +90,6 @@ 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); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js index 62850b98ba38..c8fbec1ecea5 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js @@ -89,9 +89,6 @@ 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; diff --git a/dom/ipc/tests/browser_memory_distribution_telemetry.js b/dom/ipc/tests/browser_memory_distribution_telemetry.js index 4695f5c19ac3..caf8cf867799 100644 --- a/dom/ipc/tests/browser_memory_distribution_telemetry.js +++ b/dom/ipc/tests/browser_memory_distribution_telemetry.js @@ -26,7 +26,6 @@ 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"); diff --git a/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js b/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js index b6aac0174e6b..38207571fd6b 100644 --- a/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js +++ b/dom/ipc/tests/browser_remote_navigation_delay_telemetry.js @@ -8,7 +8,6 @@ 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); diff --git a/dom/security/test/hsts/head.js b/dom/security/test/hsts/head.js index 826c8244c7ec..114f3de23121 100644 --- a/dom/security/test/hsts/head.js +++ b/dom/security/test/hsts/head.js @@ -408,7 +408,6 @@ 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) { diff --git a/js/src/tests/user.js b/js/src/tests/user.js index 97690c96af4c..36addd61185a 100755 --- a/js/src/tests/user.js +++ b/js/src/tests/user.js @@ -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("toolkit.telemetry.enabled", false); +user_pref("datareporting.healthreport.uploadEnabled", false); user_pref("browser.safebrowsing.phishing.enabled", false); user_pref("browser.safebrowsing.malware.enabled", false); user_pref("browser.safebrowsing.blockedURIs.enabled", false); diff --git a/layout/tools/reftest/reftest-preferences.js b/layout/tools/reftest/reftest-preferences.js index cfba6ea9012e..7c81ade628d3 100644 --- a/layout/tools/reftest/reftest-preferences.js +++ b/layout/tools/reftest/reftest-preferences.js @@ -87,6 +87,8 @@ 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); diff --git a/testing/mozbase/mozprofile/mozprofile/profile.py b/testing/mozbase/mozprofile/mozprofile/profile.py index 0a058927df62..8a845bdbf991 100644 --- a/testing/mozbase/mozprofile/mozprofile/profile.py +++ b/testing/mozbase/mozprofile/mozprofile/profile.py @@ -403,8 +403,6 @@ 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/', diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html index 7033b85c3784..c6ecbd42fc65 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html @@ -17,12 +17,6 @@ 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(() => { diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js b/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js index b36f3dee549d..db1082caa8b1 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js @@ -555,10 +555,14 @@ 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); - Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true); + if (!IS_UNIFIED_TELEMETRY) { + Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, true); + } Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, true); function waitAnnotateCrashReport(expectedValue, trigger) { @@ -601,17 +605,13 @@ 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)); - Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, origTelemetryEnabled); + if (!IS_UNIFIED_TELEMETRY) { + Services.prefs.setBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, origTelemetryEnabled); + } Services.prefs.setBoolPref(TelemetryUtils.Preferences.FhrUploadEnabled, origFhrUploadEnabled); }); diff --git a/toolkit/mozapps/extensions/test/browser/browser_experiments.js b/toolkit/mozapps/extensions/test/browser/browser_experiments.js index 86e1a1f52686..361ae4659880 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_experiments.js +++ b/toolkit/mozapps/extensions/test/browser/browser_experiments.js @@ -82,7 +82,6 @@ add_task(async function initializeState() { registerCleanupFunction(() => { Services.prefs.clearUserPref("experiments.enabled"); - Services.prefs.clearUserPref("toolkit.telemetry.enabled"); if (gHttpServer) { gHttpServer.stop(() => {}); if (gSavedManifestURI !== undefined) { @@ -266,7 +265,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.prefs.setBoolPref("toolkit.telemetry.enabled", true); + Services.telemetry.canRecordExtended = true; Services.prefs.setBoolPref("experiments.enabled", true); info("Initializing experiments service."); @@ -608,8 +607,6 @@ 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. diff --git a/toolkit/mozapps/update/tests/data/shared.js b/toolkit/mozapps/update/tests/data/shared.js index 16314ce2456e..f27020466d24 100644 --- a/toolkit/mozapps/update/tests/data/shared.js +++ b/toolkit/mozapps/update/tests/data/shared.js @@ -33,7 +33,6 @@ 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"; diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index 8a39f06b43f0..0517d077dffa 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -1037,8 +1037,6 @@ 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); } /**