mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
Bug 540356 - Enforce a sane minimum interval of 60 seconds for app.update.timer and provide mechanism for tests to have a minimum interval of 500 ms. r=dolske
This commit is contained in:
parent
c1b32a0fc9
commit
66bbbc8f96
@ -138,9 +138,25 @@ TimerManager.prototype = {
|
||||
* See nsIObserver.idl
|
||||
*/
|
||||
observe: function TM_observe(aSubject, aTopic, aData) {
|
||||
// Prevent setting the timer interval to a value of less than 60 seconds.
|
||||
var minInterval = 60000;
|
||||
switch (aTopic) {
|
||||
case "utm-test-init":
|
||||
// Enforce a minimum timer interval of 500 ms for tests and fall through
|
||||
// to profile-after-change to initialize the timer.
|
||||
minInterval = 500;
|
||||
case "profile-after-change":
|
||||
this._start();
|
||||
// Cancel the timer if it has already been initialized. This is primarily
|
||||
// for tests.
|
||||
if (this._timer) {
|
||||
this._timer.cancel();
|
||||
this._timer = null;
|
||||
}
|
||||
this._timerInterval = Math.max(getPref("getIntPref", PREF_APP_UPDATE_TIMER, 600000),
|
||||
minInterval);
|
||||
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
this._timer.initWithCallback(this, this._timerInterval,
|
||||
Ci.nsITimer.TYPE_REPEATING_SLACK);
|
||||
break;
|
||||
case "xpcom-shutdown":
|
||||
let os = getObserverService();
|
||||
@ -158,12 +174,6 @@ TimerManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_start: function TM__start() {
|
||||
this._timerInterval = getPref("getIntPref", "app.update.timer", 600000);
|
||||
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
this._timer.initWithCallback(this, this._timerInterval,
|
||||
Ci.nsITimer.TYPE_REPEATING_SLACK);
|
||||
},
|
||||
/**
|
||||
# Called when the checking timer fires.
|
||||
# @param timer
|
||||
|
@ -150,7 +150,7 @@ function run_test() {
|
||||
gUTM = Cc["@mozilla.org/updates/timer-manager;1"].
|
||||
getService(Ci.nsIUpdateTimerManager).
|
||||
QueryInterface(Ci.nsIObserver);
|
||||
gUTM.observe(null, "profile-after-change", "");
|
||||
gUTM.observe(null, "utm-test-init", "");
|
||||
|
||||
do_execute_soon(run_test1thru6);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user