Bug 1354855 - Set update timer prefs in new update tests r=rstrong

In the log file attached to this bug, we see multiple requests for
background updates come in at the same time. I can't see a way for
this to happen other than notify being called while the test is
running.

MozReview-Commit-ID: Gm0vW32X6mN

--HG--
extra : rebase_source : fe220a940b07bc45c10b460c22408eeecf3a3059
This commit is contained in:
Doug Thayer 2017-04-12 13:47:42 -07:00
parent 9a39989c9a
commit dbf506b14a

View File

@ -8,6 +8,9 @@ const BIN_SUFFIX = (IS_WIN ? ".exe" : "");
const FILE_UPDATER_BIN = "updater" + (IS_MACOSX ? ".app" : BIN_SUFFIX);
const FILE_UPDATER_BIN_BAK = FILE_UPDATER_BIN + ".bak";
const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer";
let gRembemberedPrefs = [];
const DATA_URI_SPEC = "chrome://mochitests/content/browser/browser/base/content/test/appUpdate/";
@ -66,6 +69,18 @@ function cleanUpUpdates() {
removeUpdateDirsAndFiles();
}
/**
* Prevent nsIUpdateTimerManager from notifying nsIApplicationUpdateService
* to check for updates by setting the app update last update time to the
* current time minus one minute in seconds and the interval time to 12 hours
* in seconds.
*/
function setUpdateTimerPrefs() {
let now = Math.round(Date.now() / 1000) - 60;
Services.prefs.setIntPref(PREF_APP_UPDATE_LASTUPDATETIME, now);
Services.prefs.setIntPref(PREF_APP_UPDATE_INTERVAL, 43200);
}
/**
* Runs a typical update test. Will set various common prefs for using the
* updater doorhanger, runs the provided list of steps, and makes sure
@ -89,6 +104,8 @@ function runUpdateTest(updateParams, checkAttempts, steps) {
gMenuButtonUpdateBadge.init();
cleanUpUpdates();
});
setUpdateTimerPrefs();
yield SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0],
@ -142,6 +159,7 @@ function runUpdateProcessingTest(updates, steps) {
cleanUpUpdates();
});
setUpdateTimerPrefs();
SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0],