From 65f6d086f45d1101da1c6141305c5789a01078b2 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 8 Feb 2019 14:10:08 +0000 Subject: [PATCH] Bug 1519538 - Disable idle-daily notifications in tests through user.js files. r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D19017 --HG-- extra : moz-landing-system : lando --- dom/indexedDB/test/unit/test_idle_maintenance.js | 5 ++--- testing/mochitest/runtests.py | 1 - testing/profiles/perf/user.js | 3 +++ testing/profiles/unittest-required/user.js | 3 +++ testing/profiles/xpcshell/user.js | 3 +++ testing/talos/talos/config.py | 5 ----- toolkit/modules/Troubleshoot.jsm | 1 + widget/nsIdleService.cpp | 11 ++++++++++- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dom/indexedDB/test/unit/test_idle_maintenance.js b/dom/indexedDB/test/unit/test_idle_maintenance.js index b5f2f63bcd9e..8f627fe1988e 100644 --- a/dom/indexedDB/test/unit/test_idle_maintenance.js +++ b/dom/indexedDB/test/unit/test_idle_maintenance.js @@ -15,9 +15,8 @@ function* testSteps() Services.perms.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION); - info("Setting idle preferences to prevent real 'idle-daily' notification"); - - Services.prefs.setIntPref("idle.lastDailyNotification", (Date.now() / 1000) - 10); + // The idle-daily notification is disabled in xpchsell tests, so we don't + // need to do anything special to disable it for this test. info("Activating real idle service"); diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index 64bae23b508e..ee89d0d5cf42 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -1879,7 +1879,6 @@ toolbar#nav-bar { prefs = { "browser.tabs.remote.autostart": options.e10s, "dom.ipc.tabs.nested.enabled": options.nested_oop, - "idle.lastDailyNotification": int(time.time()), # Enable tracing output for detailed failures in case of # failing connection attempts, and hangs (bug 1397201) "marionette.log.level": "Trace", diff --git a/testing/profiles/perf/user.js b/testing/profiles/perf/user.js index 3ef5ce2cc810..f1e751e8ceda 100644 --- a/testing/profiles/perf/user.js +++ b/testing/profiles/perf/user.js @@ -63,6 +63,9 @@ user_pref("extensions.update.url", "http://127.0.0.1/extensions-dummy/updateURL" user_pref("extensions.webservice.discoverURL", "http://127.0.0.1/extensions-dummy/discoveryURL"); user_pref("identity.fxaccounts.auth.uri", "https://127.0.0.1/fxa-dummy/"); user_pref("identity.fxaccounts.migrateToDevEdition", false); +// Avoid idle-daily notifications, to avoid expensive operations that may +// cause unexpected test timeouts. +user_pref("idle.lastDailyNotification", -1); // Make tests run consistently on DevEdition (which has a lightweight theme // selected by default). user_pref("lightweightThemes.selectedThemeID", ""); diff --git a/testing/profiles/unittest-required/user.js b/testing/profiles/unittest-required/user.js index a57df66d5ed5..c104a656581e 100644 --- a/testing/profiles/unittest-required/user.js +++ b/testing/profiles/unittest-required/user.js @@ -153,6 +153,9 @@ user_pref("gfx.logging.level", 1); user_pref("identity.fxaccounts.auth.uri", "https://{server}/fxa-dummy/"); // Ditto for all the FxA content root URI. user_pref("identity.fxaccounts.remote.root", "https://{server}/"); +// Avoid idle-daily notifications, to avoid expensive operations that may +// cause unexpected test timeouts. +user_pref("idle.lastDailyNotification", -1); user_pref("javascript.options.showInConsole", true); user_pref("layout.accessiblecaret.enabled_on_touch", false); // Make sure CSS error reporting is enabled for tests diff --git a/testing/profiles/xpcshell/user.js b/testing/profiles/xpcshell/user.js index 5f86f5bc085d..700fddb88c35 100644 --- a/testing/profiles/xpcshell/user.js +++ b/testing/profiles/xpcshell/user.js @@ -16,3 +16,6 @@ user_pref("toolkit.telemetry.server", "https://%(server)s/telemetry-dummy"); // all processes would run at low priority, which is not desirable, so we // disable the process priority manager entirely here. user_pref("dom.ipc.processPriorityManager.enabled", false); +// Avoid idle-daily notifications, to avoid expensive operations that may +// cause unexpected test timeouts. +user_pref("idle.lastDailyNotification", -1); diff --git a/testing/talos/talos/config.py b/testing/talos/talos/config.py index 62792c864c10..fe9914445be3 100644 --- a/testing/talos/talos/config.py +++ b/testing/talos/talos/config.py @@ -142,11 +142,6 @@ def set_webserver(config): @validator def update_prefs(config): - config.setdefault('preferences', {}).update({ - # Bug 1383896 - reduces noise in tests - 'idle.lastDailyNotification': int(time.time()), - }) - # update prefs from command line prefs = config.pop('extraPrefs') if prefs: diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index f2475b08a397..6163cc1a7234 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -56,6 +56,7 @@ const PREFS_WHITELIST = [ "general.useragent.", "gfx.", "html5.", + "idle.", "image.", "javascript.", "keyword.", diff --git a/widget/nsIdleService.cpp b/widget/nsIdleService.cpp index b8741c795e1a..4e35f3f93cb4 100644 --- a/widget/nsIdleService.cpp +++ b/widget/nsIdleService.cpp @@ -156,8 +156,17 @@ void nsIdleServiceDaily::Init() { // get ready to send an idle-daily event. Otherwise set a timer targeted // at 24 hours past the last idle-daily we sent. - int32_t nowSec = static_cast(PR_Now() / PR_USEC_PER_SEC); int32_t lastDaily = Preferences::GetInt(PREF_LAST_DAILY, 0); + // Setting the pref to -1 allows to disable idle-daily, and it's particularly + // useful in tests. Normally there should be no need for the user to set + // this value. + if (lastDaily == -1) { + MOZ_LOG(sLog, LogLevel::Debug, + ("nsIdleServiceDaily: Init: disabled idle-daily")); + return; + } + + int32_t nowSec = static_cast(PR_Now() / PR_USEC_PER_SEC); if (lastDaily < 0 || lastDaily > nowSec) { // The time is bogus, use default. lastDaily = 0;