Bug 693413 - Service.startOver resets Status.sync too late, prefs pane flickers. r=rnewman

This commit is contained in:
Philipp von Weitershausen 2011-10-10 18:22:58 -07:00
parent 45ea0d0d56
commit 323ef6b322
2 changed files with 40 additions and 2 deletions

View File

@ -917,6 +917,7 @@ WeaveSvc.prototype = {
startOver: function() {
Svc.Obs.notify("weave:engine:stop-tracking");
Status.resetSync();
// We want let UI consumers of the following notification know as soon as
// possible, so let's fake for the CLIENT_NOT_CONFIGURED status for now
@ -945,7 +946,6 @@ WeaveSvc.prototype = {
this.resetClient();
CollectionKeys.clear();
Status.resetBackoff();
Status.resetSync();
// Reset Weave prefs.
this._ignorePrefObserver = true;
@ -955,7 +955,6 @@ WeaveSvc.prototype = {
Svc.Prefs.set("lastversion", WEAVE_VERSION);
// Find weave logins and remove them.
this.password = "";
this.passphrase = "";
Services.logins.findLogins({}, PWDMGR_HOST, "", "").map(function(login) {
Services.logins.removeLogin(login);
});

View File

@ -1,5 +1,6 @@
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/policies.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/util.js");
@ -24,6 +25,44 @@ function run_test() {
run_next_test();
}
add_test(function test_resetLocalData() {
// Set up.
Service.username = "foobar";
Service.password = "blablabla";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Status.enforceBackoff = true;
Status.backoffInterval = 42;
Status.minimumNextSync = 23;
Service.persistLogin();
// Verify set up.
do_check_eq(Status.checkSetup(), STATUS_OK);
// Verify state that the observer sees.
let observerCalled = false;
Svc.Obs.add("weave:service:start-over", function onStartOver() {
Svc.Obs.remove("weave:service:start-over", onStartOver);
observerCalled = true;
do_check_eq(Status.service, CLIENT_NOT_CONFIGURED);
});
Service.startOver();
do_check_true(observerCalled);
// Verify the site was nuked from orbit.
do_check_eq(Svc.Prefs.get("username"), undefined);
do_check_eq(Service.password, "");
do_check_eq(Service.passphrase, "");
do_check_eq(Status.service, CLIENT_NOT_CONFIGURED);
do_check_false(Status.enforceBackoff);
do_check_eq(Status.backoffInterval, 0);
do_check_eq(Status.minimumNextSync, 0);
run_next_test();
});
add_test(function test_removeClientData() {
let engine = Engines.get("bla");