Bug 671066 - Unknown error on conclusion of easy setup of second client. r=rnewman
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Tue, 12 Jul 2011 16:36:43 -0700
changeset 72594 8f022250cf9268e5aa2960c2462179030096d9b7
parent 72593 05c6384339fe18e40427cdb8ae54e94fe7819c5a
child 72595 96db7dbde55e5674ccd5421b6ceffadb170c09e0
push id152
push userpweitershausen@mozilla.com
push dateTue, 12 Jul 2011 23:37:08 +0000
treeherderservices-central@8f022250cf92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs671066
milestone8.0a1
Bug 671066 - Unknown error on conclusion of easy setup of second client. r=rnewman
services/sync/modules/service.js
services/sync/tests/unit/test_syncscheduler.js
--- 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);