diff --git a/services/sync/modules/policies.js b/services/sync/modules/policies.js index e203acaa817..49d6b8b3b2b 100644 --- a/services/sync/modules/policies.js +++ b/services/sync/modules/policies.js @@ -236,7 +236,7 @@ let SyncScheduler = { }, calculateScore: function calculateScore() { - var engines = Engines.getEnabled(); + let engines = [Clients].concat(Engines.getEnabled()); for (let i = 0;i < engines.length;i++) { this._log.trace(engines[i].name + ": score: " + engines[i].score); this.globalScore += engines[i].score; diff --git a/services/sync/tests/unit/test_score_triggers.js b/services/sync/tests/unit/test_score_triggers.js index 89001fd71c7..b0aead4c2e7 100644 --- a/services/sync/tests/unit/test_score_triggers.js +++ b/services/sync/tests/unit/test_score_triggers.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ Cu.import("resource://services-sync/engines.js"); +Cu.import("resource://services-sync/engines/clients.js"); Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/policies.js"); @@ -95,3 +96,25 @@ add_test(function test_sync_triggered() { tracker.score += SCORE_INCREMENT_XLARGE; }); +add_test(function test_clients_engine_sync_triggered() { + _("Ensure that client engine score changes trigger a sync."); + + // The clients engine is not registered like other engines. Therefore, + // it needs special treatment throughout the code. Here, we verify the + // global score tracker gives it that treatment. See bug 676042 for more. + + let server = sync_httpd_setup(); + setUp(); + Service.login(); + + const TOPIC = "weave:service:sync:finish"; + Svc.Obs.add(TOPIC, function onSyncFinish() { + Svc.Obs.remove(TOPIC, onSyncFinish); + _("Sync due to clients engine change completed."); + server.stop(run_next_test); + }); + + SyncScheduler.syncThreshold = MULTI_DEVICE_THRESHOLD; + Clients._tracker.score += SCORE_INCREMENT_XLARGE; +}); +