Bug 671066 - Unknown error on conclusion of easy setup of second client. r=rnewman
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -1061,17 +1061,17 @@ WeaveSvc.prototype = {
if (this._autoTimer)
this._autoTimer.clear();
SyncScheduler.checkSyncStatus();
return;
}
- let reason = this._checkSync([kSyncNotLoggedIn, kFirstSyncChoiceNotMade]);
+ let reason = this._checkSync([kSyncNotLoggedIn]);
// Can't autoconnect if we're missing these values.
if (!reason) {
if (!this.username || !this.password || !this.passphrase)
return;
Utils.nextTick(this.sync, this);
}
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -352,16 +352,53 @@ add_test(function test_sync_at_startup()
});
let server = sync_httpd_setup();
setUp();
Service.delayedAutoConnect(0);
});
+let timer;
+add_test(function test_no_autoconnect_during_wizard() {
+ let server = sync_httpd_setup();
+ setUp();
+
+ // Simulate the Sync setup wizard.
+ Svc.Prefs.set("firstSync", "notReady");
+
+ // Ensure we don't actually try to sync.
+ function onSyncStart() {
+ do_throw("Should not get here!");
+ }
+ Svc.Obs.add("weave:service:sync:start", onSyncStart);
+
+ // First wait >100ms (nsITimers can take up to that much time to fire, so
+ // we can account for the timer in delayedAutoconnect) and then two event
+ // loop ticks (to account for the Utils.nextTick() in _autoConnect).
+ let ticks = 2;
+ function wait() {
+ if (ticks) {
+ ticks -= 1;
+ Utils.nextTick(wait);
+ return;
+ }
+ Svc.Obs.remove("weave:service:sync:start", onSyncStart);
+
+ Svc.Prefs.resetBranch("");
+ SyncScheduler.setDefaults();
+ Clients.resetClient();
+
+ server.stop(run_next_test);
+ }
+ timer = Utils.namedTimer(wait, 150, {}, "timer");
+
+ Service.delayedAutoConnect(0);
+});
+
add_test(function test_idle_adjustSyncInterval() {
// Confirm defaults.
do_check_eq(SyncScheduler.idle, false);
// Single device: nothing changes.
SyncScheduler.observe(null, "idle", Svc.Prefs.get("scheduler.idleTime"));
do_check_eq(SyncScheduler.idle, true);
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);