Bug 953282 - Fix idle observer notification, after Bug 715041 broke in-tree consumers. r=gps, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Fri, 27 Dec 2013 21:12:50 -0800
changeset 174549 9eee77743c8c5d6ba3811c932efbc651c415c67c
parent 174548 a990d28d924e6f7247ac16f51051c6e8a5f4c188
child 174550 d45e2d3dcaf9a8c359b573a7baacbb01f89446e6
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, bajaj
bugs953282, 715041
milestone28.0a2
Bug 953282 - Fix idle observer notification, after Bug 715041 broke in-tree consumers. r=gps, a=bajaj
services/sync/modules/policies.js
services/sync/tests/unit/test_interval_triggers.js
services/sync/tests/unit/test_syncscheduler.js
--- a/services/sync/modules/policies.js
+++ b/services/sync/modules/policies.js
@@ -213,17 +213,17 @@ SyncScheduler.prototype = {
       case "idle":
         this._log.trace("We're idle.");
         this.idle = true;
         // Adjust the interval for future syncs. This won't actually have any
         // effect until the next pending sync (which will happen soon since we
         // were just active.)
         this.adjustSyncInterval();
         break;
-      case "back":
+      case "active":
         this._log.trace("Received notification that we're back from idle.");
         this.idle = false;
         Utils.namedTimer(function onBack() {
           if (this.idle) {
             this._log.trace("... and we're idle again. " +
                             "Ignoring spurious back notification.");
             return;
           }
--- a/services/sync/tests/unit/test_interval_triggers.js
+++ b/services/sync/tests/unit/test_interval_triggers.js
@@ -260,17 +260,17 @@ add_test(function test_unsuccessful_sync
 });
 
 add_test(function test_back_triggers_sync() {
   let server = sync_httpd_setup();
   setUp(server);
 
   // Single device: no sync triggered.
   scheduler.idle = true;
-  scheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
+  scheduler.observe(null, "active", Svc.Prefs.get("scheduler.idleTime"));
   do_check_false(scheduler.idle);
 
   // Multiple devices: sync is triggered.
   clientsEngine._store.create({id: "foo", cleartext: "bar"});
   scheduler.updateClientMode();
 
   Svc.Obs.add("weave:service:sync:finish", function onSyncFinish() {
     Svc.Obs.remove("weave:service:sync:finish", onSyncFinish);
@@ -280,17 +280,17 @@ add_test(function test_back_triggers_syn
     scheduler.setDefaults();
     clientsEngine.resetClient();
 
     Service.startOver();
     server.stop(run_next_test);
   });
 
   scheduler.idle = true;
-  scheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
+  scheduler.observe(null, "active", Svc.Prefs.get("scheduler.idleTime"));
   do_check_false(scheduler.idle);
 });
 
 add_test(function test_adjust_interval_on_sync_error() {
   let server = sync_httpd_setup();
   setUp(server);
 
   let syncFailures = 0;
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -602,21 +602,21 @@ add_test(function test_back_triggersSync
 
   // We don't actually expect the sync (or the login, for that matter) to
   // succeed. We just want to ensure that it was attempted.
   Svc.Obs.add("weave:service:login:error", function onLoginError() {
     Svc.Obs.remove("weave:service:login:error", onLoginError);
     cleanUpAndGo();
   });
 
-  // Send a 'back' event to trigger sync soonish.
-  scheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
+  // Send an 'active' event to trigger sync soonish.
+  scheduler.observe(null, "active", Svc.Prefs.get("scheduler.idleTime"));
 });
 
-add_test(function test_back_triggersSync_observesBackoff() {
+add_test(function test_active_triggersSync_observesBackoff() {
   // Confirm defaults.
   do_check_false(scheduler.idle);
 
   // Set up: Set backoff, define 2 clients and put the system in idle.
   const BACKOFF = 7337;
   Status.backoffInterval = scheduler.idleInterval + BACKOFF;
   scheduler.numClients = 2;
   scheduler.observe(null, "idle", Svc.Prefs.get("scheduler.idleTime"));
@@ -631,18 +631,18 @@ add_test(function test_back_triggersSync
     Svc.Obs.remove("weave:service:login:start", onLoginStart);
 
     do_check_true(scheduler.nextSync <= Date.now() + Status.backoffInterval);
     do_check_eq(scheduler.syncTimer.delay, Status.backoffInterval);
 
     cleanUpAndGo();
   }, IDLE_OBSERVER_BACK_DELAY * 1.5, {}, "timer");
 
-  // Send a 'back' event to try to trigger sync soonish.
-  scheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
+  // Send an 'active' event to try to trigger sync soonish.
+  scheduler.observe(null, "active", Svc.Prefs.get("scheduler.idleTime"));
 });
 
 add_test(function test_back_debouncing() {
   _("Ensure spurious back-then-idle events, as observed on OS X, don't trigger a sync.");
 
   // Confirm defaults.
   do_check_eq(scheduler.idle, false);
 
@@ -652,17 +652,17 @@ add_test(function test_back_debouncing()
   do_check_eq(scheduler.idle, true);
 
   function onLoginStart() {
     do_throw("Shouldn't have kicked off a sync!");
   }
   Svc.Obs.add("weave:service:login:start", onLoginStart);
 
   // Create spurious back-then-idle events as observed on OS X:
-  scheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
+  scheduler.observe(null, "active", Svc.Prefs.get("scheduler.idleTime"));
   scheduler.observe(null, "idle", Svc.Prefs.get("scheduler.idleTime"));
 
   timer = Utils.namedTimer(function () {
     Svc.Obs.remove("weave:service:login:start", onLoginStart);
     cleanUpAndGo();
   }, IDLE_OBSERVER_BACK_DELAY * 1.5, {}, "timer");
 });