Bug 1103361 - Start/stop sync tracker when engine is enabled/disabled by flipping the pref. r=rnewman

CLOSED TREE

--HG--
extra : amend_source : 22355c1d80609addb52bb884a1927a48613255d4
This commit is contained in:
Hector Zhao 2014-11-22 16:09:10 +08:00
parent 84fc435498
commit 7b68377c42
2 changed files with 8 additions and 2 deletions

View File

@ -54,6 +54,8 @@ this.Tracker = function Tracker(name, engine) {
Svc.Obs.add("weave:engine:start-tracking", this);
Svc.Obs.add("weave:engine:stop-tracking", this);
Svc.Prefs.observe("engine." + this.engine.prefName, this);
};
Tracker.prototype = {
@ -224,6 +226,11 @@ Tracker.prototype = {
this._isTracking = false;
}
return;
case "nsPref:changed":
if (data == PREFS_BRANCH + "engine." + this.engine.prefName) {
this.onEngineEnabledChanged(this.engine.enabled);
}
return;
}
}
};
@ -628,7 +635,6 @@ Engine.prototype = {
set enabled(val) {
Svc.Prefs.set("engine." + this.prefName, !!val);
this._tracker.onEngineEnabledChanged(val);
},
get score() this._tracker.score,

View File

@ -209,7 +209,7 @@ add_test(function test_disabled_no_track() {
tracker.addChangedID("abcdefghijkl");
do_check_true(0 < tracker.changedIDs["abcdefghijkl"]);
engine.enabled = false;
Svc.Prefs.set("engine." + engine.prefName, false);
do_check_false(tracker._isTracking);
do_check_empty(tracker.changedIDs);