mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 668309 - Part 2: Make regular intervals pref-able. r=rnewman
This commit is contained in:
parent
8ade2b67cb
commit
2a868ced11
@ -76,15 +76,6 @@ SYNC_KEY_ENCODED_LENGTH: 26,
|
||||
SYNC_KEY_DECODED_LENGTH: 16,
|
||||
SYNC_KEY_HYPHENATED_LENGTH: 31, // 26 chars, 5 hyphens.
|
||||
|
||||
// Sync intervals for various clients configurations
|
||||
SINGLE_USER_SYNC: 24 * 60 * 60 * 1000, // 1 day
|
||||
MULTI_DEVICE_IDLE_SYNC: 60 * 60 * 1000, // 1 hour
|
||||
MULTI_DEVICE_ACTIVE_SYNC: 5 * 60 * 1000, // 5 minutes
|
||||
MULTI_DEVICE_IMMEDIATE_SYNC: 60 * 1000, // 1 minute
|
||||
|
||||
// Time idle before changing the sync interval.
|
||||
IDLE_TIME: 300, // 5 minutes (in seconds)
|
||||
|
||||
NO_SYNC_NODE_INTERVAL: 10 * 60 * 1000, // 10 minutes
|
||||
|
||||
MAX_ERROR_COUNT_BEFORE_BACKOFF: 3,
|
||||
|
@ -60,6 +60,12 @@ let SyncScheduler = {
|
||||
|
||||
setDefaults: function setDefaults() {
|
||||
this._log.trace("Setting SyncScheduler policy values to defaults.");
|
||||
|
||||
this.singleDeviceInterval = Svc.Prefs.get("scheduler.singleDeviceInterval") * 1000;
|
||||
this.idleInterval = Svc.Prefs.get("scheduler.idleInterval") * 1000;
|
||||
this.activeInterval = Svc.Prefs.get("scheduler.activeInterval") * 1000;
|
||||
this.immediateInterval = Svc.Prefs.get("scheduler.immediateInterval") * 1000;
|
||||
|
||||
// A user is non-idle on startup by default.
|
||||
this.idle = false;
|
||||
|
||||
@ -67,7 +73,7 @@ let SyncScheduler = {
|
||||
this.numClients = 0;
|
||||
|
||||
this.nextSync = 0,
|
||||
this.syncInterval = SINGLE_USER_SYNC;
|
||||
this.syncInterval = this.singleDeviceInterval;
|
||||
this.syncThreshold = SINGLE_USER_THRESHOLD;
|
||||
},
|
||||
|
||||
@ -87,7 +93,7 @@ let SyncScheduler = {
|
||||
Svc.Obs.add("weave:service:sync:error", this);
|
||||
Svc.Obs.add("weave:service:backoff:interval", this);
|
||||
Svc.Obs.add("weave:engine:sync:applied", this);
|
||||
Svc.Idle.addIdleObserver(this, IDLE_TIME);
|
||||
Svc.Idle.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
|
||||
},
|
||||
|
||||
observe: function observe(subject, topic, data) {
|
||||
@ -182,25 +188,25 @@ let SyncScheduler = {
|
||||
|
||||
adjustSyncInterval: function adjustSyncInterval() {
|
||||
if (this.numClients <= 1) {
|
||||
this._log.trace("Adjusting syncInterval to SINGLE_USER_SYNC");
|
||||
this.syncInterval = SINGLE_USER_SYNC;
|
||||
this._log.trace("Adjusting syncInterval to singleDeviceInterval.");
|
||||
this.syncInterval = this.singleDeviceInterval;
|
||||
return;
|
||||
}
|
||||
// Only MULTI_DEVICE clients will enter this if statement
|
||||
// since SINGLE_USER clients will be handled above.
|
||||
if (this.idle) {
|
||||
this._log.trace("Adjusting syncInterval to MULTI_DEVICE_IDLE_SYNC.");
|
||||
this.syncInterval = MULTI_DEVICE_IDLE_SYNC;
|
||||
this._log.trace("Adjusting syncInterval to idleInterval.");
|
||||
this.syncInterval = this.idleInterval;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.hasIncomingItems) {
|
||||
this._log.trace("Adjusting syncInterval to MULTI_DEVICE_IMMEDIATE_SYNC.");
|
||||
this._log.trace("Adjusting syncInterval to immediateInterval.");
|
||||
this.hasIncomingItems = false;
|
||||
this.syncInterval = MULTI_DEVICE_IMMEDIATE_SYNC;
|
||||
this.syncInterval = this.immediateInterval;
|
||||
} else {
|
||||
this._log.trace("Adjusting syncInterval to MULTI_DEVICE_ACTIVE_SYNC.");
|
||||
this.syncInterval = MULTI_DEVICE_ACTIVE_SYNC;
|
||||
this._log.trace("Adjusting syncInterval to activeInterval.");
|
||||
this.syncInterval = this.activeInterval;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -9,6 +9,12 @@ pref("services.sync.syncKeyHelpURL", "https://services.mozilla.com/help/synckey"
|
||||
pref("services.sync.lastversion", "firstrun");
|
||||
pref("services.sync.sendVersionInfo", true);
|
||||
|
||||
pref("services.sync.scheduler.singleDeviceInterval", 86400); // 1 day
|
||||
pref("services.sync.scheduler.idleInterval", 3600); // 1 hour
|
||||
pref("services.sync.scheduler.activeInterval", 300); // 5 minutes
|
||||
pref("services.sync.scheduler.immediateInterval", 60); // 1 minute
|
||||
pref("services.sync.scheduler.idleTime", 300); // 5 minutes
|
||||
|
||||
pref("services.sync.engine.bookmarks", true);
|
||||
pref("services.sync.engine.history", true);
|
||||
pref("services.sync.engine.passwords", true);
|
||||
|
@ -66,7 +66,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
// Confirm defaults
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
|
||||
_("Test as long as numClients <= 1 our sync interval is SINGLE_USER.");
|
||||
@ -77,7 +77,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == false && numClients <= 1 && hasIncomingItems == false
|
||||
SyncScheduler.idle = false;
|
||||
@ -86,7 +86,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == false && numClients <= 1 && hasIncomingItems == true
|
||||
SyncScheduler.hasIncomingItems = true;
|
||||
@ -95,7 +95,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == true && numClients <= 1 && hasIncomingItems == true
|
||||
SyncScheduler.idle = true;
|
||||
@ -104,9 +104,9 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
_("Test as long as idle && numClients > 1 our sync interval is MULTI_DEVICE_IDLE.");
|
||||
_("Test as long as idle && numClients > 1 our sync interval is idleInterval.");
|
||||
// idle == true && numClients > 1 && hasIncomingItems == true
|
||||
Clients._store.create({id: "foo", cleartext: "bar"});
|
||||
Service.sync();
|
||||
@ -114,7 +114,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IDLE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.idleInterval);
|
||||
|
||||
// idle == true && numClients > 1 && hasIncomingItems == false
|
||||
SyncScheduler.hasIncomingItems = false;
|
||||
@ -123,9 +123,9 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IDLE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.idleInterval);
|
||||
|
||||
_("Test non-idle, numClients > 1, no incoming items => MULTI_DEVICE_ACTIVE.");
|
||||
_("Test non-idle, numClients > 1, no incoming items => activeInterval.");
|
||||
// idle == false && numClients > 1 && hasIncomingItems == false
|
||||
SyncScheduler.idle = false;
|
||||
Service.sync();
|
||||
@ -133,9 +133,9 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_ACTIVE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.activeInterval);
|
||||
|
||||
_("Test non-idle, numClients > 1, incoming items => MULTI_DEVICE_IMMEDIATE.");
|
||||
_("Test non-idle, numClients > 1, incoming items => immediateInterval.");
|
||||
// idle == false && numClients > 1 && hasIncomingItems == true
|
||||
SyncScheduler.hasIncomingItems = true;
|
||||
Service.sync();
|
||||
@ -143,7 +143,7 @@ add_test(function test_successful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems); //gets reset to false
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IMMEDIATE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.immediateInterval);
|
||||
|
||||
Records.clearCache();
|
||||
Svc.Prefs.resetBranch("");
|
||||
@ -176,7 +176,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
// Confirm defaults
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
|
||||
_("Test as long as numClients <= 1 our sync interval is SINGLE_USER.");
|
||||
@ -187,7 +187,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == false && numClients <= 1 && hasIncomingItems == false
|
||||
SyncScheduler.idle = false;
|
||||
@ -196,7 +196,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == false && numClients <= 1 && hasIncomingItems == true
|
||||
SyncScheduler.hasIncomingItems = true;
|
||||
@ -205,7 +205,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// idle == true && numClients <= 1 && hasIncomingItems == true
|
||||
SyncScheduler.idle = true;
|
||||
@ -214,9 +214,9 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
_("Test as long as idle && numClients > 1 our sync interval is MULTI_DEVICE_IDLE.");
|
||||
_("Test as long as idle && numClients > 1 our sync interval is idleInterval.");
|
||||
// idle == true && numClients > 1 && hasIncomingItems == true
|
||||
|
||||
// Doesn't get called if there is a sync error since clients
|
||||
@ -229,7 +229,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_true(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IDLE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.idleInterval);
|
||||
|
||||
// idle == true && numClients > 1 && hasIncomingItems == false
|
||||
SyncScheduler.hasIncomingItems = false;
|
||||
@ -238,9 +238,9 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_true(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IDLE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.idleInterval);
|
||||
|
||||
_("Test non-idle, numClients > 1, no incoming items => MULTI_DEVICE_ACTIVE.");
|
||||
_("Test non-idle, numClients > 1, no incoming items => activeInterval.");
|
||||
// idle == false && numClients > 1 && hasIncomingItems == false
|
||||
SyncScheduler.idle = false;
|
||||
Service.sync();
|
||||
@ -248,9 +248,9 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_ACTIVE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.activeInterval);
|
||||
|
||||
_("Test non-idle, numClients > 1, incoming items => MULTI_DEVICE_IMMEDIATE.");
|
||||
_("Test non-idle, numClients > 1, incoming items => immediateInterval.");
|
||||
// idle == false && numClients > 1 && hasIncomingItems == true
|
||||
SyncScheduler.hasIncomingItems = true;
|
||||
Service.sync();
|
||||
@ -258,7 +258,7 @@ add_test(function test_unsuccessful_sync_adjustSyncInterval() {
|
||||
do_check_false(SyncScheduler.idle);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.hasIncomingItems); //gets reset to false
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IMMEDIATE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.immediateInterval);
|
||||
|
||||
Records.clearCache();
|
||||
Svc.Prefs.resetBranch("");
|
||||
@ -275,7 +275,7 @@ add_test(function test_back_triggers_sync() {
|
||||
|
||||
// Single device: no sync triggered.
|
||||
SyncScheduler.idle = true;
|
||||
SyncScheduler.observe(null, "back", IDLE_TIME);
|
||||
SyncScheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
// Multiple devices: sync is triggered.
|
||||
@ -294,6 +294,6 @@ add_test(function test_back_triggers_sync() {
|
||||
});
|
||||
|
||||
SyncScheduler.idle = true;
|
||||
SyncScheduler.observe(null, "back", IDLE_TIME);
|
||||
SyncScheduler.observe(null, "back", Svc.Prefs.get("scheduler.idleTime"));
|
||||
do_check_false(SyncScheduler.idle);
|
||||
});
|
||||
|
@ -41,13 +41,13 @@ add_test(function test_removeClientData() {
|
||||
});
|
||||
|
||||
add_test(function test_reset_SyncScheduler() {
|
||||
// Some non-defualt values for SyncScheduler's attributes.
|
||||
// Some non-default values for SyncScheduler's attributes.
|
||||
SyncScheduler.idle = true;
|
||||
SyncScheduler.hasIncomingItems = true;
|
||||
SyncScheduler.numClients = 42;
|
||||
SyncScheduler.nextSync = Date.now();
|
||||
SyncScheduler.syncThreshold = MULTI_DEVICE_THRESHOLD;
|
||||
SyncScheduler.syncInterval = MULTI_DEVICE_ACTIVE_SYNC;
|
||||
SyncScheduler.syncInterval = SyncScheduler.activeInterval;
|
||||
|
||||
Service.startOver();
|
||||
|
||||
@ -55,8 +55,8 @@ add_test(function test_reset_SyncScheduler() {
|
||||
do_check_false(SyncScheduler.hasIncomingItems);
|
||||
do_check_eq(SyncScheduler.numClients, 0);
|
||||
do_check_eq(SyncScheduler.nextSync, 0);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncThreshold, SINGLE_USER_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -63,23 +63,43 @@ add_test(function test_prefAttributes() {
|
||||
const SCORE = 2718;
|
||||
const TIMESTAMP1 = 1275493471649;
|
||||
|
||||
try {
|
||||
_("'globalScore' corresponds to preference, defaults to zero.");
|
||||
do_check_eq(Svc.Prefs.get('globalScore'), undefined);
|
||||
do_check_eq(SyncScheduler.globalScore, 0);
|
||||
SyncScheduler.globalScore = SCORE;
|
||||
do_check_eq(SyncScheduler.globalScore, SCORE);
|
||||
do_check_eq(Svc.Prefs.get('globalScore'), SCORE);
|
||||
} finally {
|
||||
Svc.Prefs.resetBranch("");
|
||||
run_next_test();
|
||||
}
|
||||
_("'globalScore' corresponds to preference, defaults to zero.");
|
||||
do_check_eq(Svc.Prefs.get('globalScore'), undefined);
|
||||
do_check_eq(SyncScheduler.globalScore, 0);
|
||||
SyncScheduler.globalScore = SCORE;
|
||||
do_check_eq(SyncScheduler.globalScore, SCORE);
|
||||
do_check_eq(Svc.Prefs.get('globalScore'), SCORE);
|
||||
|
||||
_("Intervals correspond to default preferences.");
|
||||
do_check_eq(SyncScheduler.singleDeviceInterval,
|
||||
Svc.Prefs.get("scheduler.singleDeviceInterval") * 1000);
|
||||
do_check_eq(SyncScheduler.idleInterval,
|
||||
Svc.Prefs.get("scheduler.idleInterval") * 1000);
|
||||
do_check_eq(SyncScheduler.activeInterval,
|
||||
Svc.Prefs.get("scheduler.activeInterval") * 1000);
|
||||
do_check_eq(SyncScheduler.immediateInterval,
|
||||
Svc.Prefs.get("scheduler.immediateInterval") * 1000);
|
||||
|
||||
_("Custom values for prefs will take effect after a restart.");
|
||||
Svc.Prefs.set("scheduler.singleDeviceInterval", 42);
|
||||
Svc.Prefs.set("scheduler.idleInterval", 23);
|
||||
Svc.Prefs.set("scheduler.activeInterval", 18);
|
||||
Svc.Prefs.set("scheduler.immediateInterval", 31415);
|
||||
SyncScheduler.setDefaults();
|
||||
do_check_eq(SyncScheduler.idleInterval, 23000);
|
||||
do_check_eq(SyncScheduler.singleDeviceInterval, 42000);
|
||||
do_check_eq(SyncScheduler.activeInterval, 18000);
|
||||
do_check_eq(SyncScheduler.immediateInterval, 31415000);
|
||||
|
||||
Svc.Prefs.resetBranch("");
|
||||
SyncScheduler.setDefaults();
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_updateClientMode() {
|
||||
_("Test updateClientMode adjusts scheduling attributes based on # of clients appropriately");
|
||||
do_check_eq(SyncScheduler.syncThreshold, SINGLE_USER_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
@ -88,7 +108,7 @@ add_test(function test_updateClientMode() {
|
||||
SyncScheduler.updateClientMode();
|
||||
|
||||
do_check_eq(SyncScheduler.syncThreshold, MULTI_DEVICE_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_ACTIVE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.activeInterval);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
@ -99,7 +119,7 @@ add_test(function test_updateClientMode() {
|
||||
// Goes back to single user if # clients is 1.
|
||||
do_check_eq(SyncScheduler.numClients, 1);
|
||||
do_check_eq(SyncScheduler.syncThreshold, SINGLE_USER_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
@ -184,7 +204,7 @@ add_test(function test_scheduleNextSync() {
|
||||
|
||||
_("Test setting sync interval when nextSync == 0");
|
||||
initial_nextSync = SyncScheduler.nextSync = 0;
|
||||
let expectedInterval = SINGLE_USER_SYNC;
|
||||
let expectedInterval = SyncScheduler.singleDeviceInterval;
|
||||
SyncScheduler.scheduleNextSync();
|
||||
|
||||
// Test nextSync value was changed.
|
||||
@ -232,23 +252,23 @@ add_test(function test_handleSyncError() {
|
||||
_("Ensure expected initial environment.");
|
||||
do_check_eq(SyncScheduler._syncErrors, 0);
|
||||
do_check_false(Status.enforceBackoff);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_eq(Status.backoffInterval, 0);
|
||||
|
||||
// Trigger sync with an error several times & observe
|
||||
// functionality of handleSyncError()
|
||||
_("Test first error calls scheduleNextSync on default interval");
|
||||
Service.sync();
|
||||
do_check_true(SyncScheduler.nextSync <= Date.now() + SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncTimer.delay, SINGLE_USER_SYNC);
|
||||
do_check_true(SyncScheduler.nextSync <= Date.now() + SyncScheduler.singleDeviceInterval);
|
||||
do_check_eq(SyncScheduler.syncTimer.delay, SyncScheduler.singleDeviceInterval);
|
||||
do_check_eq(SyncScheduler._syncErrors, 1);
|
||||
do_check_false(Status.enforceBackoff);
|
||||
SyncScheduler.syncTimer.clear();
|
||||
|
||||
_("Test second error still calls scheduleNextSync on default interval");
|
||||
Service.sync();
|
||||
do_check_true(SyncScheduler.nextSync <= Date.now() + SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncTimer.delay, SINGLE_USER_SYNC);
|
||||
do_check_true(SyncScheduler.nextSync <= Date.now() + SyncScheduler.singleDeviceInterval);
|
||||
do_check_eq(SyncScheduler.syncTimer.delay, SyncScheduler.singleDeviceInterval);
|
||||
do_check_eq(SyncScheduler._syncErrors, 2);
|
||||
do_check_false(Status.enforceBackoff);
|
||||
SyncScheduler.syncTimer.clear();
|
||||
@ -288,7 +308,7 @@ add_test(function test_client_sync_finish_updateClientMode() {
|
||||
|
||||
// Confirm defaults.
|
||||
do_check_eq(SyncScheduler.syncThreshold, SINGLE_USER_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
// Trigger a change in interval & threshold by adding a client.
|
||||
@ -298,7 +318,7 @@ add_test(function test_client_sync_finish_updateClientMode() {
|
||||
Service.sync();
|
||||
|
||||
do_check_eq(SyncScheduler.syncThreshold, MULTI_DEVICE_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_ACTIVE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.activeInterval);
|
||||
do_check_true(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
@ -309,7 +329,7 @@ add_test(function test_client_sync_finish_updateClientMode() {
|
||||
// Goes back to single user if # clients is 1.
|
||||
do_check_eq(SyncScheduler.numClients, 1);
|
||||
do_check_eq(SyncScheduler.syncThreshold, SINGLE_USER_THRESHOLD);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
do_check_false(SyncScheduler.numClients > 1);
|
||||
do_check_false(SyncScheduler.idle);
|
||||
|
||||
@ -341,17 +361,17 @@ add_test(function test_idle_adjustSyncInterval() {
|
||||
do_check_eq(SyncScheduler.idle, false);
|
||||
|
||||
// Single device: nothing changes.
|
||||
SyncScheduler.observe(null, "idle", IDLE_TIME);
|
||||
SyncScheduler.observe(null, "idle", Svc.Prefs.get("scheduler.idleTime"));
|
||||
do_check_eq(SyncScheduler.idle, true);
|
||||
do_check_eq(SyncScheduler.syncInterval, SINGLE_USER_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.singleDeviceInterval);
|
||||
|
||||
// Multiple devices: switch to idle interval.
|
||||
SyncScheduler.idle = false;
|
||||
Clients._store.create({id: "foo", cleartext: "bar"});
|
||||
SyncScheduler.updateClientMode();
|
||||
SyncScheduler.observe(null, "idle", IDLE_TIME);
|
||||
SyncScheduler.observe(null, "idle", Svc.Prefs.get("scheduler.idleTime"));
|
||||
do_check_eq(SyncScheduler.idle, true);
|
||||
do_check_eq(SyncScheduler.syncInterval, MULTI_DEVICE_IDLE_SYNC);
|
||||
do_check_eq(SyncScheduler.syncInterval, SyncScheduler.idleInterval);
|
||||
|
||||
SyncScheduler.setDefaults();
|
||||
run_next_test();
|
||||
|
Loading…
Reference in New Issue
Block a user