Bug 1242975 - Make services/sync eslintable. r=markh

This commit is contained in:
Hector Zhao 2016-01-26 23:13:31 +08:00
parent 475462ba34
commit dfeafaaa0c
28 changed files with 234 additions and 169 deletions

View File

@ -316,7 +316,7 @@ this.add_identity_test = function(test, testFunction) {
let ns = {}; let ns = {};
Cu.import("resource://services-sync/service.js", ns); Cu.import("resource://services-sync/service.js", ns);
// one task for the "old" identity manager. // one task for the "old" identity manager.
test.add_task(function() { test.add_task(function* () {
note("sync"); note("sync");
let oldIdentity = Status._authManager; let oldIdentity = Status._authManager;
ensureLegacyIdentityManager(); ensureLegacyIdentityManager();
@ -324,7 +324,7 @@ this.add_identity_test = function(test, testFunction) {
Status.__authManager = ns.Service.identity = oldIdentity; Status.__authManager = ns.Service.identity = oldIdentity;
}); });
// another task for the FxAccounts identity manager. // another task for the FxAccounts identity manager.
test.add_task(function() { test.add_task(function* () {
note("FxAccounts"); note("FxAccounts");
let oldIdentity = Status._authManager; let oldIdentity = Status._authManager;
Status.__authManager = ns.Service.identity = new BrowserIDManager(); Status.__authManager = ns.Service.identity = new BrowserIDManager();

View File

@ -694,7 +694,10 @@ this.BrowserIDManager.prototype = {
// expected. // expected.
try { try {
cb.wait(); cb.wait();
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.error("Failed to fetch a token for authentication", ex); this._log.error("Failed to fetch a token for authentication", ex);
return null; return null;
} }

View File

@ -301,12 +301,16 @@ Store.prototype = {
for (let record of records) { for (let record of records) {
try { try {
this.applyIncoming(record); this.applyIncoming(record);
} catch (ex if (ex.code == Engine.prototype.eEngineAbortApplyIncoming)) { } catch (ex) {
if (ex.code == Engine.prototype.eEngineAbortApplyIncoming) {
// This kind of exception should have a 'cause' attribute, which is an // This kind of exception should have a 'cause' attribute, which is an
// originating exception. // originating exception.
// ex.cause will carry its stack with it when rethrown. // ex.cause will carry its stack with it when rethrown.
throw ex.cause; throw ex.cause;
} catch (ex if !Async.isShutdownException(ex)) { }
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Failed to apply incoming record " + record.id, ex); this._log.warn("Failed to apply incoming record " + record.id, ex);
this.engine._noteApplyFailure(); this.engine._noteApplyFailure();
failed.push(record.id); failed.push(record.id);
@ -990,7 +994,10 @@ SyncEngine.prototype = {
this._tracker.ignoreAll = true; this._tracker.ignoreAll = true;
try { try {
failed = failed.concat(this._store.applyIncomingBatch(applyBatch)); failed = failed.concat(this._store.applyIncomingBatch(applyBatch));
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
// Catch any error that escapes from applyIncomingBatch. At present // Catch any error that escapes from applyIncomingBatch. At present
// those will all be abort events. // those will all be abort events.
this._log.warn("Got exception, aborting processIncoming", ex); this._log.warn("Got exception, aborting processIncoming", ex);
@ -1038,7 +1045,10 @@ SyncEngine.prototype = {
try { try {
try { try {
item.decrypt(key); item.decrypt(key);
} catch (ex if Utils.isHMACMismatch(ex)) { } catch (ex) {
if (!Utils.isHMACMismatch(ex)) {
throw ex;
}
let strategy = self.handleHMACMismatch(item, true); let strategy = self.handleHMACMismatch(item, true);
if (strategy == SyncEngine.kRecoveryStrategy.retry) { if (strategy == SyncEngine.kRecoveryStrategy.retry) {
// You only get one retry. // You only get one retry.
@ -1048,7 +1058,10 @@ SyncEngine.prototype = {
key = self.service.collectionKeys.keyForCollection(self.name); key = self.service.collectionKeys.keyForCollection(self.name);
item.decrypt(key); item.decrypt(key);
strategy = null; strategy = null;
} catch (ex if Utils.isHMACMismatch(ex)) { } catch (ex) {
if (!Utils.isHMACMismatch(ex)) {
throw ex;
}
strategy = self.handleHMACMismatch(item, false); strategy = self.handleHMACMismatch(item, false);
} }
} }
@ -1081,16 +1094,20 @@ SyncEngine.prototype = {
let shouldApply; let shouldApply;
try { try {
shouldApply = self._reconcile(item); shouldApply = self._reconcile(item);
} catch (ex if (ex.code == Engine.prototype.eEngineAbortApplyIncoming)) { } catch (ex) {
if (ex.code == Engine.prototype.eEngineAbortApplyIncoming) {
self._log.warn("Reconciliation failed: aborting incoming processing."); self._log.warn("Reconciliation failed: aborting incoming processing.");
self._noteApplyFailure(); self._noteApplyFailure();
failed.push(item.id); failed.push(item.id);
aborting = ex.cause; aborting = ex.cause;
} catch (ex if !Async.isShutdownException(ex)) { } else if (!Async.isShutdownException(ex)) {
self._log.warn("Failed to reconcile incoming record " + item.id, ex); self._log.warn("Failed to reconcile incoming record " + item.id, ex);
self._noteApplyFailure(); self._noteApplyFailure();
failed.push(item.id); failed.push(item.id);
return; return;
} else {
throw ex;
}
} }
if (shouldApply) { if (shouldApply) {
@ -1471,7 +1488,10 @@ SyncEngine.prototype = {
out.encrypt(this.service.collectionKeys.keyForCollection(this.name)); out.encrypt(this.service.collectionKeys.keyForCollection(this.name));
ok = true; ok = true;
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Error creating record", ex); this._log.warn("Error creating record", ex);
} }
if (ok) { if (ok) {
@ -1557,7 +1577,10 @@ SyncEngine.prototype = {
try { try {
this._log.trace("Trying to decrypt a record from the server.."); this._log.trace("Trying to decrypt a record from the server..");
test.get(); test.get();
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.debug("Failed test decrypt", ex); this._log.debug("Failed test decrypt", ex);
} }

View File

@ -256,7 +256,10 @@ BookmarksEngine.prototype = {
stmt.params.id = id; stmt.params.id = id;
let rows = Async.querySpinningly(stmt, ["url"]); let rows = Async.querySpinningly(stmt, ["url"]);
url = rows.length == 0 ? "<not found>" : rows[0].url; url = rows.length == 0 ? "<not found>" : rows[0].url;
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
if (ex instanceof Ci.mozIStorageError) { if (ex instanceof Ci.mozIStorageError) {
url = `<failed: Storage error: ${ex.message} (${ex.result})>`; url = `<failed: Storage error: ${ex.message} (${ex.result})>`;
} else { } else {
@ -414,7 +417,7 @@ BookmarksEngine.prototype = {
SyncEngine.prototype._syncStartup.call(this); SyncEngine.prototype._syncStartup.call(this);
let cb = Async.makeSpinningCallback(); let cb = Async.makeSpinningCallback();
Task.spawn(function() { Task.spawn(function* () {
// For first-syncs, make a backup for the user to restore // For first-syncs, make a backup for the user to restore
if (this.lastSync == 0) { if (this.lastSync == 0) {
this._log.debug("Bookmarks backup starting."); this._log.debug("Bookmarks backup starting.");
@ -440,7 +443,10 @@ BookmarksEngine.prototype = {
let guidMap; let guidMap;
try { try {
guidMap = this._buildGUIDMap(); guidMap = this._buildGUIDMap();
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Error while building GUID map, skipping all other incoming items", ex); this._log.warn("Error while building GUID map, skipping all other incoming items", ex);
throw {code: Engine.prototype.eEngineAbortApplyIncoming, throw {code: Engine.prototype.eEngineAbortApplyIncoming,
cause: ex}; cause: ex};
@ -1367,7 +1373,7 @@ BookmarksStore.prototype = {
wipe: function BStore_wipe() { wipe: function BStore_wipe() {
let cb = Async.makeSpinningCallback(); let cb = Async.makeSpinningCallback();
Task.spawn(function() { Task.spawn(function* () {
// Save a backup before clearing out all bookmarks. // Save a backup before clearing out all bookmarks.
yield PlacesBackups.create(null, true); yield PlacesBackups.create(null, true);
for (let guid of kSpecialIds.guids) for (let guid of kSpecialIds.guids)

View File

@ -223,7 +223,10 @@ HistoryStore.prototype = {
} else { } else {
shouldApply = this._recordToPlaceInfo(record); shouldApply = this._recordToPlaceInfo(record);
} }
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
failed.push(record.id); failed.push(record.id);
shouldApply = false; shouldApply = false;
} }

View File

@ -68,7 +68,10 @@ PasswordEngine.prototype = {
// record success. // record success.
Svc.Prefs.set("deletePwdFxA", true); Svc.Prefs.set("deletePwdFxA", true);
Svc.Prefs.reset("deletePwd"); // The old prefname we previously used. Svc.Prefs.reset("deletePwd"); // The old prefname we previously used.
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.debug("Password deletes failed", ex); this._log.debug("Password deletes failed", ex);
} }
} }

View File

@ -446,7 +446,10 @@ IdentityManager.prototype = {
// cache. // cache.
try { try {
service.recordManager.get(service.storageURL + "meta/fxa_credentials"); service.recordManager.get(service.storageURL + "meta/fxa_credentials");
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Failed to pre-fetch the migration sentinel", ex); this._log.warn("Failed to pre-fetch the migration sentinel", ex);
} }
}, },

View File

@ -239,7 +239,10 @@ SyncScheduler.prototype = {
this.setDefaults(); this.setDefaults();
try { try {
Svc.Idle.removeIdleObserver(this, Svc.Prefs.get("scheduler.idleTime")); Svc.Idle.removeIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
} catch (ex if (ex.result == Cr.NS_ERROR_FAILURE)) { } catch (ex) {
if (ex.result != Cr.NS_ERROR_FAILURE) {
throw ex;
}
// In all likelihood we didn't have an idle observer registered yet. // In all likelihood we didn't have an idle observer registered yet.
// It's all good. // It's all good.
} }

View File

@ -238,7 +238,10 @@ RecordManager.prototype = {
record.deserialize(this.response); record.deserialize(this.response);
return this.set(url, record); return this.set(url, record);
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.debug("Failed to import record", ex); this._log.debug("Failed to import record", ex);
return null; return null;
} }

View File

@ -396,7 +396,10 @@ Resource.prototype = {
try { try {
this._doRequest(action, data, callback); this._doRequest(action, data, callback);
return Async.waitForSyncCallback(cb); return Async.waitForSyncCallback(cb);
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
// Combine the channel stack with this request stack. Need to create // Combine the channel stack with this request stack. Need to create
// a new error object for that. // a new error object for that.
let error = Error(ex.message); let error = Error(ex.message);
@ -549,7 +552,10 @@ ChannelListener.prototype = {
try { try {
this._onProgress(); this._onProgress();
} catch (ex if !Async.isShutdownException(ex)) { } catch (ex) {
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Got exception calling onProgress handler during fetch of " this._log.warn("Got exception calling onProgress handler during fetch of "
+ req.URI.spec, ex); + req.URI.spec, ex);
this._log.trace("Rethrowing; expect a failure code from the HTTP channel."); this._log.trace("Rethrowing; expect a failure code from the HTTP channel.");

View File

@ -336,13 +336,15 @@ this.Utils = {
try { try {
json = yield CommonUtils.readJSON(path); json = yield CommonUtils.readJSON(path);
} catch (e if e instanceof OS.File.Error && e.becauseNoSuchFile) {
// Ignore non-existent files.
} catch (e) { } catch (e) {
if (e instanceof OS.File.Error && e.becauseNoSuchFile) {
// Ignore non-existent files.
} else {
if (that._log) { if (that._log) {
that._log.debug("Failed to load json", e); that._log.debug("Failed to load json", e);
} }
} }
}
callback.call(that, json); callback.call(that, json);
}), }),

View File

@ -167,7 +167,7 @@ add_test(function test_processIncoming_error_orderChildren() {
} }
}); });
add_task(function test_restorePromptsReupload() { add_task(function* test_restorePromptsReupload() {
_("Ensure that restoring from a backup will reupload all records."); _("Ensure that restoring from a backup will reupload all records.");
let engine = new BookmarksEngine(Service); let engine = new BookmarksEngine(Service);
let store = engine._store; let store = engine._store;

View File

@ -76,7 +76,7 @@ add_test(function test_initial_state() {
} }
); );
add_task(function test_initialializeWithCurrentIdentity() { add_task(function* test_initialializeWithCurrentIdentity() {
_("Verify start after initializeWithCurrentIdentity"); _("Verify start after initializeWithCurrentIdentity");
browseridManager.initializeWithCurrentIdentity(); browseridManager.initializeWithCurrentIdentity();
yield browseridManager.whenReadyToAuthenticate.promise; yield browseridManager.whenReadyToAuthenticate.promise;
@ -86,7 +86,7 @@ add_task(function test_initialializeWithCurrentIdentity() {
} }
); );
add_task(function test_initialializeWithAuthErrorAndDeletedAccount() { add_task(function* test_initialializeWithAuthErrorAndDeletedAccount() {
_("Verify sync unpair after initializeWithCurrentIdentity with auth error + account deleted"); _("Verify sync unpair after initializeWithCurrentIdentity with auth error + account deleted");
browseridManager._fxaService.internal.initialize(); browseridManager._fxaService.internal.initialize();
@ -127,7 +127,7 @@ add_task(function test_initialializeWithAuthErrorAndDeletedAccount() {
browseridManager._fetchTokenForUser = oldFetchTokenForUser; browseridManager._fetchTokenForUser = oldFetchTokenForUser;
}); });
add_task(function test_initialializeWithNoKeys() { add_task(function* test_initialializeWithNoKeys() {
_("Verify start after initializeWithCurrentIdentity without kA, kB or keyFetchToken"); _("Verify start after initializeWithCurrentIdentity without kA, kB or keyFetchToken");
let identityConfig = makeIdentityConfig(); let identityConfig = makeIdentityConfig();
delete identityConfig.fxaccount.user.kA; delete identityConfig.fxaccount.user.kA;
@ -296,7 +296,7 @@ add_test(function test_RESTResourceAuthenticatorSkew() {
run_next_test(); run_next_test();
}); });
add_task(function test_ensureLoggedIn() { add_task(function* test_ensureLoggedIn() {
configureFxAccountIdentity(browseridManager); configureFxAccountIdentity(browseridManager);
yield browseridManager.initializeWithCurrentIdentity(); yield browseridManager.initializeWithCurrentIdentity();
yield browseridManager.whenReadyToAuthenticate.promise; yield browseridManager.whenReadyToAuthenticate.promise;
@ -394,7 +394,7 @@ add_test(function test_computeXClientStateHeader() {
run_next_test(); run_next_test();
}); });
add_task(function test_getTokenErrors() { add_task(function* test_getTokenErrors() {
_("BrowserIDManager correctly handles various failures to get a token."); _("BrowserIDManager correctly handles various failures to get a token.");
_("Arrange for a 401 - Sync should reflect an auth error."); _("Arrange for a 401 - Sync should reflect an auth error.");
@ -433,7 +433,7 @@ add_task(function test_getTokenErrors() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for invalid responses"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for invalid responses");
}); });
add_task(function test_getTokenErrorWithRetry() { add_task(function* test_getTokenErrorWithRetry() {
_("tokenserver sends an observer notification on various backoff headers."); _("tokenserver sends an observer notification on various backoff headers.");
// Set Sync's backoffInterval to zero - after we simulated the backoff header // Set Sync's backoffInterval to zero - after we simulated the backoff header
@ -481,7 +481,7 @@ add_task(function test_getTokenErrorWithRetry() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503/backoff response from FxA"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503/backoff response from FxA");
}); });
add_task(function test_getKeysErrorWithBackoff() { add_task(function* test_getKeysErrorWithBackoff() {
_("Auth server (via hawk) sends an observer notification on backoff headers."); _("Auth server (via hawk) sends an observer notification on backoff headers.");
// Set Sync's backoffInterval to zero - after we simulated the backoff header // Set Sync's backoffInterval to zero - after we simulated the backoff header
@ -518,7 +518,7 @@ add_task(function test_getKeysErrorWithBackoff() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA");
}); });
add_task(function test_getKeysErrorWithRetry() { add_task(function* test_getKeysErrorWithRetry() {
_("Auth server (via hawk) sends an observer notification on retry headers."); _("Auth server (via hawk) sends an observer notification on retry headers.");
// Set Sync's backoffInterval to zero - after we simulated the backoff header // Set Sync's backoffInterval to zero - after we simulated the backoff header
@ -555,7 +555,7 @@ add_task(function test_getKeysErrorWithRetry() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA");
}); });
add_task(function test_getHAWKErrors() { add_task(function* test_getHAWKErrors() {
_("BrowserIDManager correctly handles various HAWK failures."); _("BrowserIDManager correctly handles various HAWK failures.");
_("Arrange for a 401 - Sync should reflect an auth error."); _("Arrange for a 401 - Sync should reflect an auth error.");
@ -594,7 +594,7 @@ add_task(function test_getHAWKErrors() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for invalid response from FxA"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for invalid response from FxA");
}); });
add_task(function test_getGetKeysFailing401() { add_task(function* test_getGetKeysFailing401() {
_("BrowserIDManager correctly handles 401 responses fetching keys."); _("BrowserIDManager correctly handles 401 responses fetching keys.");
_("Arrange for a 401 - Sync should reflect an auth error."); _("Arrange for a 401 - Sync should reflect an auth error.");
@ -618,7 +618,7 @@ add_task(function test_getGetKeysFailing401() {
Assert.equal(keyFetchErrorCount, 1, "Should record key fetch errors for 401 from FxA"); Assert.equal(keyFetchErrorCount, 1, "Should record key fetch errors for 401 from FxA");
}); });
add_task(function test_getGetKeysFailing503() { add_task(function* test_getGetKeysFailing503() {
_("BrowserIDManager correctly handles 5XX responses fetching keys."); _("BrowserIDManager correctly handles 5XX responses fetching keys.");
_("Arrange for a 503 - Sync should reflect a network error."); _("Arrange for a 503 - Sync should reflect a network error.");
@ -642,7 +642,7 @@ add_task(function test_getGetKeysFailing503() {
Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA"); Assert.equal(keyFetchErrorCount, 0, "Should not record key fetch errors for 503 from FxA");
}); });
add_task(function test_getKeysMissing() { add_task(function* test_getKeysMissing() {
_("BrowserIDManager correctly handles getKeys succeeding but not returning keys."); _("BrowserIDManager correctly handles getKeys succeeding but not returning keys.");
let browseridManager = new BrowserIDManager(); let browseridManager = new BrowserIDManager();

View File

@ -6,7 +6,7 @@ Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js"); Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js"); Cu.import("resource://testing-common/services/sync/utils.js");
add_identity_test(this, function test_missing_crypto_collection() { add_identity_test(this, function* test_missing_crypto_collection() {
let johnHelper = track_collections_helper(); let johnHelper = track_collections_helper();
let johnU = johnHelper.with_updated_collection; let johnU = johnHelper.with_updated_collection;
let johnColls = johnHelper.collections; let johnColls = johnHelper.collections;

View File

@ -14,7 +14,7 @@ Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js"); Cu.import("resource://testing-common/services/sync/utils.js");
Cu.import("resource://gre/modules/Promise.jsm"); Cu.import("resource://gre/modules/Promise.jsm");
add_task(function test_locally_changed_keys() { add_task(function* test_locally_changed_keys() {
let passphrase = "abcdeabcdeabcdeabcdeabcdea"; let passphrase = "abcdeabcdeabcdeabcdeabcdea";
let hmacErrorCount = 0; let hmacErrorCount = 0;

View File

@ -161,7 +161,7 @@ function clean() {
errorHandler.didReportProlongedError = false; errorHandler.didReportProlongedError = false;
} }
add_identity_test(this, function test_401_logout() { add_identity_test(this, function* test_401_logout() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -206,7 +206,7 @@ add_identity_test(this, function test_401_logout() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_credentials_changed_logout() { add_identity_test(this, function* test_credentials_changed_logout() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -456,7 +456,7 @@ add_identity_test(this, function test_shouldReportError() {
do_check_false(errorHandler.didReportProlongedError); do_check_false(errorHandler.didReportProlongedError);
}); });
add_identity_test(this, function test_shouldReportError_master_password() { add_identity_test(this, function* test_shouldReportError_master_password() {
_("Test error ignored due to locked master password"); _("Test error ignored due to locked master password");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -501,7 +501,7 @@ add_identity_test(this, function test_shouldReportLoginFailureWithNoCluster() {
// XXX - how to arrange for 'Service.identity.basicPassword = null;' in // XXX - how to arrange for 'Service.identity.basicPassword = null;' in
// an fxaccounts environment? // an fxaccounts environment?
add_task(function test_login_syncAndReportErrors_non_network_error() { add_task(function* test_login_syncAndReportErrors_non_network_error() {
// Test non-network errors are reported // Test non-network errors are reported
// when calling syncAndReportErrors // when calling syncAndReportErrors
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -522,7 +522,7 @@ add_task(function test_login_syncAndReportErrors_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_sync_syncAndReportErrors_non_network_error() { add_identity_test(this, function* test_sync_syncAndReportErrors_non_network_error() {
// Test non-network errors are reported // Test non-network errors are reported
// when calling syncAndReportErrors // when calling syncAndReportErrors
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -551,7 +551,7 @@ add_identity_test(this, function test_sync_syncAndReportErrors_non_network_error
// XXX - how to arrange for 'Service.identity.basicPassword = null;' in // XXX - how to arrange for 'Service.identity.basicPassword = null;' in
// an fxaccounts environment? // an fxaccounts environment?
add_task(function test_login_syncAndReportErrors_prolonged_non_network_error() { add_task(function* test_login_syncAndReportErrors_prolonged_non_network_error() {
// Test prolonged, non-network errors are // Test prolonged, non-network errors are
// reported when calling syncAndReportErrors. // reported when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -572,7 +572,7 @@ add_task(function test_login_syncAndReportErrors_prolonged_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_sync_syncAndReportErrors_prolonged_non_network_error() { add_identity_test(this, function* test_sync_syncAndReportErrors_prolonged_non_network_error() {
// Test prolonged, non-network errors are // Test prolonged, non-network errors are
// reported when calling syncAndReportErrors. // reported when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -599,7 +599,7 @@ add_identity_test(this, function test_sync_syncAndReportErrors_prolonged_non_net
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_login_syncAndReportErrors_network_error() { add_identity_test(this, function* test_login_syncAndReportErrors_network_error() {
// Test network errors are reported when calling syncAndReportErrors. // Test network errors are reported when calling syncAndReportErrors.
yield configureIdentity({username: "broken.wipe"}); yield configureIdentity({username: "broken.wipe"});
Service.serverURL = fakeServerUrl; Service.serverURL = fakeServerUrl;
@ -637,7 +637,7 @@ add_test(function test_sync_syncAndReportErrors_network_error() {
errorHandler.syncAndReportErrors(); errorHandler.syncAndReportErrors();
}); });
add_identity_test(this, function test_login_syncAndReportErrors_prolonged_network_error() { add_identity_test(this, function* test_login_syncAndReportErrors_prolonged_network_error() {
// Test prolonged, network errors are reported // Test prolonged, network errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
@ -677,7 +677,7 @@ add_test(function test_sync_syncAndReportErrors_prolonged_network_error() {
errorHandler.syncAndReportErrors(); errorHandler.syncAndReportErrors();
}); });
add_task(function test_login_prolonged_non_network_error() { add_task(function* test_login_prolonged_non_network_error() {
// Test prolonged, non-network errors are reported // Test prolonged, non-network errors are reported
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -698,7 +698,7 @@ add_task(function test_login_prolonged_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_prolonged_non_network_error() { add_task(function* test_sync_prolonged_non_network_error() {
// Test prolonged, non-network errors are reported // Test prolonged, non-network errors are reported
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -725,7 +725,7 @@ add_task(function test_sync_prolonged_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_login_prolonged_network_error() { add_identity_test(this, function* test_login_prolonged_network_error() {
// Test prolonged, network errors are reported // Test prolonged, network errors are reported
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = fakeServerUrl; Service.serverURL = fakeServerUrl;
@ -764,7 +764,7 @@ add_test(function test_sync_prolonged_network_error() {
Service.sync(); Service.sync();
}); });
add_task(function test_login_non_network_error() { add_task(function* test_login_non_network_error() {
// Test non-network errors are reported // Test non-network errors are reported
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -785,7 +785,7 @@ add_task(function test_login_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_non_network_error() { add_task(function* test_sync_non_network_error() {
// Test non-network errors are reported // Test non-network errors are reported
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -812,7 +812,7 @@ add_task(function test_sync_non_network_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_login_network_error() { add_identity_test(this, function* test_login_network_error() {
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = fakeServerUrl; Service.serverURL = fakeServerUrl;
Service.clusterURL = fakeServerUrl; Service.clusterURL = fakeServerUrl;
@ -853,7 +853,7 @@ add_test(function test_sync_network_error() {
Service.sync(); Service.sync();
}); });
add_identity_test(this, function test_sync_server_maintenance_error() { add_identity_test(this, function* test_sync_server_maintenance_error() {
// Test server maintenance errors are not reported. // Test server maintenance errors are not reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -889,7 +889,7 @@ add_identity_test(this, function test_sync_server_maintenance_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_info_collections_login_server_maintenance_error() { add_identity_test(this, function* test_info_collections_login_server_maintenance_error() {
// Test info/collections server maintenance errors are not reported. // Test info/collections server maintenance errors are not reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -933,7 +933,7 @@ add_identity_test(this, function test_info_collections_login_server_maintenance_
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_meta_global_login_server_maintenance_error() { add_identity_test(this, function* test_meta_global_login_server_maintenance_error() {
// Test meta/global server maintenance errors are not reported. // Test meta/global server maintenance errors are not reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -976,7 +976,7 @@ add_identity_test(this, function test_meta_global_login_server_maintenance_error
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_crypto_keys_login_server_maintenance_error() { add_identity_test(this, function* test_crypto_keys_login_server_maintenance_error() {
// Test crypto/keys server maintenance errors are not reported. // Test crypto/keys server maintenance errors are not reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -1022,7 +1022,7 @@ add_identity_test(this, function test_crypto_keys_login_server_maintenance_error
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_prolonged_server_maintenance_error() { add_task(function* test_sync_prolonged_server_maintenance_error() {
// Test prolonged server maintenance errors are reported. // Test prolonged server maintenance errors are reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -1051,7 +1051,7 @@ add_task(function test_sync_prolonged_server_maintenance_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_info_collections_login_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_info_collections_login_prolonged_server_maintenance_error(){
// Test info/collections prolonged server maintenance errors are reported. // Test info/collections prolonged server maintenance errors are reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -1087,7 +1087,7 @@ add_identity_test(this, function test_info_collections_login_prolonged_server_ma
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_meta_global_login_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_meta_global_login_prolonged_server_maintenance_error(){
// Test meta/global prolonged server maintenance errors are reported. // Test meta/global prolonged server maintenance errors are reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -1123,7 +1123,7 @@ add_identity_test(this, function test_meta_global_login_prolonged_server_mainten
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_download_crypto_keys_login_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_download_crypto_keys_login_prolonged_server_maintenance_error(){
// Test crypto/keys prolonged server maintenance errors are reported. // Test crypto/keys prolonged server maintenance errors are reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -1161,7 +1161,7 @@ add_identity_test(this, function test_download_crypto_keys_login_prolonged_serve
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_upload_crypto_keys_login_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_upload_crypto_keys_login_prolonged_server_maintenance_error(){
// Test crypto/keys prolonged server maintenance errors are reported. // Test crypto/keys prolonged server maintenance errors are reported.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1197,7 +1197,7 @@ add_identity_test(this, function test_upload_crypto_keys_login_prolonged_server_
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_wipeServer_login_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_wipeServer_login_prolonged_server_maintenance_error(){
// Test that we report prolonged server maintenance errors that occur whilst // Test that we report prolonged server maintenance errors that occur whilst
// wiping the server. // wiping the server.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1234,7 +1234,7 @@ add_identity_test(this, function test_wipeServer_login_prolonged_server_maintena
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_wipeRemote_prolonged_server_maintenance_error(){ add_identity_test(this, function* test_wipeRemote_prolonged_server_maintenance_error(){
// Test that we report prolonged server maintenance errors that occur whilst // Test that we report prolonged server maintenance errors that occur whilst
// wiping all remote devices. // wiping all remote devices.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1278,7 +1278,7 @@ add_identity_test(this, function test_wipeRemote_prolonged_server_maintenance_er
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_syncAndReportErrors_server_maintenance_error() { add_task(function* test_sync_syncAndReportErrors_server_maintenance_error() {
// Test server maintenance errors are reported // Test server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1308,7 +1308,7 @@ add_task(function test_sync_syncAndReportErrors_server_maintenance_error() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_info_collections_login_syncAndReportErrors_server_maintenance_error() { add_identity_test(this, function* test_info_collections_login_syncAndReportErrors_server_maintenance_error() {
// Test info/collections server maintenance errors are reported // Test info/collections server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1345,7 +1345,7 @@ add_identity_test(this, function test_info_collections_login_syncAndReportErrors
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_meta_global_login_syncAndReportErrors_server_maintenance_error() { add_identity_test(this, function* test_meta_global_login_syncAndReportErrors_server_maintenance_error() {
// Test meta/global server maintenance errors are reported // Test meta/global server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1382,7 +1382,7 @@ add_identity_test(this, function test_meta_global_login_syncAndReportErrors_serv
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_download_crypto_keys_login_syncAndReportErrors_server_maintenance_error() { add_identity_test(this, function* test_download_crypto_keys_login_syncAndReportErrors_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1421,7 +1421,7 @@ add_identity_test(this, function test_download_crypto_keys_login_syncAndReportEr
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_upload_crypto_keys_login_syncAndReportErrors_server_maintenance_error() { add_identity_test(this, function* test_upload_crypto_keys_login_syncAndReportErrors_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1458,7 +1458,7 @@ add_identity_test(this, function test_upload_crypto_keys_login_syncAndReportErro
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_wipeServer_login_syncAndReportErrors_server_maintenance_error() { add_identity_test(this, function* test_wipeServer_login_syncAndReportErrors_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1495,7 +1495,7 @@ add_identity_test(this, function test_wipeServer_login_syncAndReportErrors_serve
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_wipeRemote_syncAndReportErrors_server_maintenance_error(){ add_identity_test(this, function* test_wipeRemote_syncAndReportErrors_server_maintenance_error(){
// Test that we report prolonged server maintenance errors that occur whilst // Test that we report prolonged server maintenance errors that occur whilst
// wiping all remote devices. // wiping all remote devices.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1538,7 +1538,7 @@ add_identity_test(this, function test_wipeRemote_syncAndReportErrors_server_main
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_syncAndReportErrors_prolonged_server_maintenance_error() { add_task(function* test_sync_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test prolonged server maintenance errors are // Test prolonged server maintenance errors are
// reported when calling syncAndReportErrors. // reported when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1570,7 +1570,7 @@ add_task(function test_sync_syncAndReportErrors_prolonged_server_maintenance_err
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_info_collections_login_syncAndReportErrors_prolonged_server_maintenance_error() { add_identity_test(this, function* test_info_collections_login_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test info/collections server maintenance errors are reported // Test info/collections server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1609,7 +1609,7 @@ add_identity_test(this, function test_info_collections_login_syncAndReportErrors
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_meta_global_login_syncAndReportErrors_prolonged_server_maintenance_error() { add_identity_test(this, function* test_meta_global_login_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test meta/global server maintenance errors are reported // Test meta/global server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1648,7 +1648,7 @@ add_identity_test(this, function test_meta_global_login_syncAndReportErrors_prol
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_download_crypto_keys_login_syncAndReportErrors_prolonged_server_maintenance_error() { add_identity_test(this, function* test_download_crypto_keys_login_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1689,7 +1689,7 @@ add_identity_test(this, function test_download_crypto_keys_login_syncAndReportEr
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_upload_crypto_keys_login_syncAndReportErrors_prolonged_server_maintenance_error() { add_identity_test(this, function* test_upload_crypto_keys_login_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1728,7 +1728,7 @@ add_identity_test(this, function test_upload_crypto_keys_login_syncAndReportErro
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_wipeServer_login_syncAndReportErrors_prolonged_server_maintenance_error() { add_identity_test(this, function* test_wipeServer_login_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test crypto/keys server maintenance errors are reported // Test crypto/keys server maintenance errors are reported
// when calling syncAndReportErrors. // when calling syncAndReportErrors.
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -1767,7 +1767,7 @@ add_identity_test(this, function test_wipeServer_login_syncAndReportErrors_prolo
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_sync_engine_generic_fail() { add_task(function* test_sync_engine_generic_fail() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
let engine = engineManager.get("catapult"); let engine = engineManager.get("catapult");
@ -1873,7 +1873,7 @@ add_test(function test_logs_on_login_error_despite_shouldReportError() {
// This test should be the last one since it monkeypatches the engine object // This test should be the last one since it monkeypatches the engine object
// and we should only have one engine object throughout the file (bug 629664). // and we should only have one engine object throughout the file (bug 629664).
add_task(function test_engine_applyFailed() { add_task(function* test_engine_applyFailed() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
let engine = engineManager.get("catapult"); let engine = engineManager.get("catapult");

View File

@ -43,7 +43,7 @@ function sync_httpd_setup(infoHandler) {
return httpd_setup(handlers); return httpd_setup(handlers);
} }
function setUp(server) { function* setUp(server) {
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = server.baseURI + "/"; Service.serverURL = server.baseURI + "/";
Service.clusterURL = server.baseURI + "/"; Service.clusterURL = server.baseURI + "/";
@ -66,7 +66,7 @@ function do_check_hard_eol(eh, start) {
do_check_true(Status.eol); do_check_true(Status.eol);
} }
add_identity_test(this, function test_200_hard() { add_identity_test(this, function* test_200_hard() {
let eh = Service.errorHandler; let eh = Service.errorHandler;
let start = Date.now(); let start = Date.now();
let server = sync_httpd_setup(handler200("hard-eol")); let server = sync_httpd_setup(handler200("hard-eol"));
@ -88,7 +88,7 @@ add_identity_test(this, function test_200_hard() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_513_hard() { add_identity_test(this, function* test_513_hard() {
let eh = Service.errorHandler; let eh = Service.errorHandler;
let start = Date.now(); let start = Date.now();
let server = sync_httpd_setup(handler513); let server = sync_httpd_setup(handler513);
@ -114,7 +114,7 @@ add_identity_test(this, function test_513_hard() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_200_soft() { add_identity_test(this, function* test_200_soft() {
let eh = Service.errorHandler; let eh = Service.errorHandler;
let start = Date.now(); let start = Date.now();
let server = sync_httpd_setup(handler200("soft-eol")); let server = sync_httpd_setup(handler200("soft-eol"));

View File

@ -59,7 +59,7 @@ function sync_httpd_setup() {
return httpd_setup(handlers); return httpd_setup(handlers);
} }
function setUp(server) { function* setUp(server) {
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = server.baseURI + "/"; Service.serverURL = server.baseURI + "/";
Service.clusterURL = server.baseURI + "/"; Service.clusterURL = server.baseURI + "/";
@ -75,7 +75,7 @@ function generateAndUploadKeys(server) {
} }
add_identity_test(this, function test_backoff500() { add_identity_test(this, function* test_backoff500() {
_("Test: HTTP 500 sets backoff status."); _("Test: HTTP 500 sets backoff status.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -102,7 +102,7 @@ add_identity_test(this, function test_backoff500() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_backoff503() { add_identity_test(this, function* test_backoff503() {
_("Test: HTTP 503 with Retry-After header leads to backoff notification and sets backoff status."); _("Test: HTTP 503 with Retry-After header leads to backoff notification and sets backoff status.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -138,7 +138,7 @@ add_identity_test(this, function test_backoff503() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_overQuota() { add_identity_test(this, function* test_overQuota() {
_("Test: HTTP 400 with body error code 14 means over quota."); _("Test: HTTP 400 with body error code 14 means over quota.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -167,7 +167,7 @@ add_identity_test(this, function test_overQuota() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_service_networkError() { add_identity_test(this, function* test_service_networkError() {
_("Test: Connection refused error from Service.sync() leads to the right status code."); _("Test: Connection refused error from Service.sync() leads to the right status code.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -193,7 +193,7 @@ add_identity_test(this, function test_service_networkError() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_service_offline() { add_identity_test(this, function* test_service_offline() {
_("Test: Wanting to sync in offline mode leads to the right status code but does not increment the ignorable error count."); _("Test: Wanting to sync in offline mode leads to the right status code but does not increment the ignorable error count.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -221,7 +221,7 @@ add_identity_test(this, function test_service_offline() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_engine_networkError() { add_identity_test(this, function* test_engine_networkError() {
_("Test: Network related exceptions from engine.sync() lead to the right status code."); _("Test: Network related exceptions from engine.sync() lead to the right status code.");
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -248,7 +248,7 @@ add_identity_test(this, function test_engine_networkError() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_resource_timeout() { add_identity_test(this, function* test_resource_timeout() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);

View File

@ -93,9 +93,10 @@ function prepareServer(cbAfterTokenFetch) {
function getReassigned() { function getReassigned() {
try { try {
return Services.prefs.getBoolPref("services.sync.lastSyncReassigned"); return Services.prefs.getBoolPref("services.sync.lastSyncReassigned");
} catch (ex if (ex.result == Cr.NS_ERROR_UNEXPECTED)) {
return false;
} catch (ex) { } catch (ex) {
if (ex.result == Cr.NS_ERROR_UNEXPECTED) {
return false;
}
do_throw("Got exception retrieving lastSyncReassigned: " + do_throw("Got exception retrieving lastSyncReassigned: " +
Log.exceptionStr(ex)); Log.exceptionStr(ex));
} }
@ -107,7 +108,7 @@ function getReassigned() {
* Runs `between` between the two. This can be used to undo deliberate failure * Runs `between` between the two. This can be used to undo deliberate failure
* setup, detach observers, etc. * setup, detach observers, etc.
*/ */
function syncAndExpectNodeReassignment(server, firstNotification, between, function* syncAndExpectNodeReassignment(server, firstNotification, between,
secondNotification, url) { secondNotification, url) {
_("Starting syncAndExpectNodeReassignment\n"); _("Starting syncAndExpectNodeReassignment\n");
let deferred = Promise.defer(); let deferred = Promise.defer();
@ -155,7 +156,7 @@ function syncAndExpectNodeReassignment(server, firstNotification, between,
yield deferred.promise; yield deferred.promise;
} }
add_task(function test_momentary_401_engine() { add_task(function* test_momentary_401_engine() {
_("Test a failure for engine URLs that's resolved by reassignment."); _("Test a failure for engine URLs that's resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
let john = server.user("johndoe"); let john = server.user("johndoe");
@ -207,7 +208,7 @@ add_task(function test_momentary_401_engine() {
}); });
// This test ends up being a failing info fetch *after we're already logged in*. // This test ends up being a failing info fetch *after we're already logged in*.
add_task(function test_momentary_401_info_collections_loggedin() { add_task(function* test_momentary_401_info_collections_loggedin() {
_("Test a failure for info/collections after login that's resolved by reassignment."); _("Test a failure for info/collections after login that's resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -235,7 +236,7 @@ add_task(function test_momentary_401_info_collections_loggedin() {
// This test ends up being a failing info fetch *before we're logged in*. // This test ends up being a failing info fetch *before we're logged in*.
// In this case we expect to recover during the login phase - so the first // In this case we expect to recover during the login phase - so the first
// sync succeeds. // sync succeeds.
add_task(function test_momentary_401_info_collections_loggedout() { add_task(function* test_momentary_401_info_collections_loggedout() {
_("Test a failure for info/collections before login that's resolved by reassignment."); _("Test a failure for info/collections before login that's resolved by reassignment.");
let oldHandler; let oldHandler;
@ -269,7 +270,7 @@ add_task(function test_momentary_401_info_collections_loggedout() {
}); });
// This test ends up being a failing meta/global fetch *after we're already logged in*. // This test ends up being a failing meta/global fetch *after we're already logged in*.
add_task(function test_momentary_401_storage_loggedin() { add_task(function* test_momentary_401_storage_loggedin() {
_("Test a failure for any storage URL after login that's resolved by" + _("Test a failure for any storage URL after login that's resolved by" +
"reassignment."); "reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -296,7 +297,7 @@ add_task(function test_momentary_401_storage_loggedin() {
}); });
// This test ends up being a failing meta/global fetch *before we've logged in*. // This test ends up being a failing meta/global fetch *before we've logged in*.
add_task(function test_momentary_401_storage_loggedout() { add_task(function* test_momentary_401_storage_loggedout() {
_("Test a failure for any storage URL before login, not just engine parts. " + _("Test a failure for any storage URL before login, not just engine parts. " +
"Resolved by reassignment."); "Resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -318,4 +319,3 @@ add_task(function test_momentary_401_storage_loggedout() {
"weave:service:sync:finish", "weave:service:sync:finish",
Service.storageURL + "meta/global"); Service.storageURL + "meta/global");
}); });

View File

@ -6,7 +6,7 @@ Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fxa_utils.js"); Cu.import("resource://testing-common/services/sync/fxa_utils.js");
Cu.import("resource://testing-common/services/sync/utils.js"); Cu.import("resource://testing-common/services/sync/utils.js");
add_task(function test_findCluster() { add_task(function* test_findCluster() {
_("Test FxA _findCluster()"); _("Test FxA _findCluster()");
_("_findCluster() throws on 500 errors."); _("_findCluster() throws on 500 errors.");

View File

@ -41,7 +41,7 @@ function sync_httpd_setup() {
}); });
} }
function setUp(server) { function* setUp(server) {
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = server.baseURI + "/"; Service.serverURL = server.baseURI + "/";
Service.clusterURL = server.baseURI + "/"; Service.clusterURL = server.baseURI + "/";
@ -60,7 +60,7 @@ function run_test() {
run_next_test(); run_next_test();
} }
add_identity_test(this, function test_successful_sync_adjustSyncInterval() { add_identity_test(this, function* test_successful_sync_adjustSyncInterval() {
_("Test successful sync calling adjustSyncInterval"); _("Test successful sync calling adjustSyncInterval");
let syncSuccesses = 0; let syncSuccesses = 0;
function onSyncFinish() { function onSyncFinish() {
@ -159,7 +159,7 @@ add_identity_test(this, function test_successful_sync_adjustSyncInterval() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_unsuccessful_sync_adjustSyncInterval() { add_identity_test(this, function* test_unsuccessful_sync_adjustSyncInterval() {
_("Test unsuccessful sync calling adjustSyncInterval"); _("Test unsuccessful sync calling adjustSyncInterval");
let syncFailures = 0; let syncFailures = 0;
@ -264,7 +264,7 @@ add_identity_test(this, function test_unsuccessful_sync_adjustSyncInterval() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_back_triggers_sync() { add_identity_test(this, function* test_back_triggers_sync() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -296,7 +296,7 @@ add_identity_test(this, function test_back_triggers_sync() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_adjust_interval_on_sync_error() { add_identity_test(this, function* test_adjust_interval_on_sync_error() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -327,7 +327,7 @@ add_identity_test(this, function test_adjust_interval_on_sync_error() {
yield promiseStopServer(server); yield promiseStopServer(server);
}); });
add_identity_test(this, function test_bug671378_scenario() { add_identity_test(this, function* test_bug671378_scenario() {
// Test scenario similar to bug 671378. This bug appeared when a score // Test scenario similar to bug 671378. This bug appeared when a score
// update occurred that wasn't large enough to trigger a sync so // update occurred that wasn't large enough to trigger a sync so
// scheduleNextSync() was called without a time interval parameter, // scheduleNextSync() was called without a time interval parameter,

View File

@ -92,9 +92,10 @@ function prepareServer() {
function getReassigned() { function getReassigned() {
try { try {
return Services.prefs.getBoolPref("services.sync.lastSyncReassigned"); return Services.prefs.getBoolPref("services.sync.lastSyncReassigned");
} catch (ex if (ex.result == Cr.NS_ERROR_UNEXPECTED)) {
return false;
} catch (ex) { } catch (ex) {
if (ex.result == Cr.NS_ERROR_UNEXPECTED) {
return false;
}
do_throw("Got exception retrieving lastSyncReassigned: " + do_throw("Got exception retrieving lastSyncReassigned: " +
Log.exceptionStr(ex)); Log.exceptionStr(ex));
} }
@ -106,7 +107,7 @@ function getReassigned() {
* Runs `between` between the two. This can be used to undo deliberate failure * Runs `between` between the two. This can be used to undo deliberate failure
* setup, detach observers, etc. * setup, detach observers, etc.
*/ */
function syncAndExpectNodeReassignment(server, firstNotification, between, function* syncAndExpectNodeReassignment(server, firstNotification, between,
secondNotification, url) { secondNotification, url) {
let deferred = Promise.defer(); let deferred = Promise.defer();
function onwards() { function onwards() {
@ -160,7 +161,7 @@ function syncAndExpectNodeReassignment(server, firstNotification, between,
yield deferred.promise; yield deferred.promise;
} }
add_task(function test_momentary_401_engine() { add_task(function* test_momentary_401_engine() {
_("Test a failure for engine URLs that's resolved by reassignment."); _("Test a failure for engine URLs that's resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
let john = server.user("johndoe"); let john = server.user("johndoe");
@ -212,7 +213,7 @@ add_task(function test_momentary_401_engine() {
}); });
// This test ends up being a failing fetch *after we're already logged in*. // This test ends up being a failing fetch *after we're already logged in*.
add_task(function test_momentary_401_info_collections() { add_task(function* test_momentary_401_info_collections() {
_("Test a failure for info/collections that's resolved by reassignment."); _("Test a failure for info/collections that's resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -235,7 +236,7 @@ add_task(function test_momentary_401_info_collections() {
Service.infoURL); Service.infoURL);
}); });
add_task(function test_momentary_401_storage_loggedin() { add_task(function* test_momentary_401_storage_loggedin() {
_("Test a failure for any storage URL, not just engine parts. " + _("Test a failure for any storage URL, not just engine parts. " +
"Resolved by reassignment."); "Resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -260,7 +261,7 @@ add_task(function test_momentary_401_storage_loggedin() {
Service.storageURL + "meta/global"); Service.storageURL + "meta/global");
}); });
add_task(function test_momentary_401_storage_loggedout() { add_task(function* test_momentary_401_storage_loggedout() {
_("Test a failure for any storage URL, not just engine parts. " + _("Test a failure for any storage URL, not just engine parts. " +
"Resolved by reassignment."); "Resolved by reassignment.");
let server = yield prepareServer(); let server = yield prepareServer();
@ -282,7 +283,7 @@ add_task(function test_momentary_401_storage_loggedout() {
Service.storageURL + "meta/global"); Service.storageURL + "meta/global");
}); });
add_task(function test_loop_avoidance_storage() { add_task(function* test_loop_avoidance_storage() {
_("Test that a repeated failure doesn't result in a sync loop " + _("Test that a repeated failure doesn't result in a sync loop " +
"if node reassignment cannot resolve the failure."); "if node reassignment cannot resolve the failure.");
@ -382,7 +383,7 @@ add_task(function test_loop_avoidance_storage() {
yield deferred.promise; yield deferred.promise;
}); });
add_task(function test_loop_avoidance_engine() { add_task(function* test_loop_avoidance_engine() {
_("Test that a repeated 401 in an engine doesn't result in a sync loop " + _("Test that a repeated 401 in an engine doesn't result in a sync loop " +
"if node reassignment cannot resolve the failure."); "if node reassignment cannot resolve the failure.");
let server = yield prepareServer(); let server = yield prepareServer();

View File

@ -28,7 +28,7 @@ function run_test() {
run_next_test(); run_next_test();
} }
add_identity_test(this, function test_resetLocalData() { add_identity_test(this, function* test_resetLocalData() {
yield configureIdentity(); yield configureIdentity();
Service.status.enforceBackoff = true; Service.status.enforceBackoff = true;
Service.status.backoffInterval = 42; Service.status.backoffInterval = 42;

View File

@ -31,7 +31,7 @@ FakeCollection.prototype = {
} }
}; };
function setUpTestFixtures(server) { function* setUpTestFixtures(server) {
let cryptoService = new FakeCryptoService(); let cryptoService = new FakeCryptoService();
Service.serverURL = server.baseURI + "/"; Service.serverURL = server.baseURI + "/";
@ -52,7 +52,7 @@ function promiseStopServer(server) {
return deferred.promise; return deferred.promise;
} }
add_identity_test(this, function test_wipeServer_list_success() { add_identity_test(this, function* test_wipeServer_list_success() {
_("Service.wipeServer() deletes collections given as argument."); _("Service.wipeServer() deletes collections given as argument.");
let steam_coll = new FakeCollection(); let steam_coll = new FakeCollection();
@ -86,7 +86,7 @@ add_identity_test(this, function test_wipeServer_list_success() {
} }
}); });
add_identity_test(this, function test_wipeServer_list_503() { add_identity_test(this, function* test_wipeServer_list_503() {
_("Service.wipeServer() deletes collections given as argument."); _("Service.wipeServer() deletes collections given as argument.");
let steam_coll = new FakeCollection(); let steam_coll = new FakeCollection();
@ -127,7 +127,7 @@ add_identity_test(this, function test_wipeServer_list_503() {
} }
}); });
add_identity_test(this, function test_wipeServer_all_success() { add_identity_test(this, function* test_wipeServer_all_success() {
_("Service.wipeServer() deletes all the things."); _("Service.wipeServer() deletes all the things.");
/** /**
@ -157,7 +157,7 @@ add_identity_test(this, function test_wipeServer_all_success() {
Svc.Prefs.resetBranch(""); Svc.Prefs.resetBranch("");
}); });
add_identity_test(this, function test_wipeServer_all_404() { add_identity_test(this, function* test_wipeServer_all_404() {
_("Service.wipeServer() accepts a 404."); _("Service.wipeServer() accepts a 404.");
/** /**
@ -189,7 +189,7 @@ add_identity_test(this, function test_wipeServer_all_404() {
Svc.Prefs.resetBranch(""); Svc.Prefs.resetBranch("");
}); });
add_identity_test(this, function test_wipeServer_all_503() { add_identity_test(this, function* test_wipeServer_all_503() {
_("Service.wipeServer() throws if it encounters a non-200/404 response."); _("Service.wipeServer() throws if it encounters a non-200/404 response.");
/** /**
@ -221,7 +221,7 @@ add_identity_test(this, function test_wipeServer_all_503() {
Svc.Prefs.resetBranch(""); Svc.Prefs.resetBranch("");
}); });
add_identity_test(this, function test_wipeServer_all_connectionRefused() { add_identity_test(this, function* test_wipeServer_all_connectionRefused() {
_("Service.wipeServer() throws if it encounters a network problem."); _("Service.wipeServer() throws if it encounters a network problem.");
let server = httpd_setup({}); let server = httpd_setup({});
yield setUpTestFixtures(server); yield setUpTestFixtures(server);

View File

@ -156,7 +156,7 @@ add_test(function test_prefAttributes() {
run_next_test(); run_next_test();
}); });
add_identity_test(this, function test_updateClientMode() { add_identity_test(this, function* test_updateClientMode() {
_("Test updateClientMode adjusts scheduling attributes based on # of clients appropriately"); _("Test updateClientMode adjusts scheduling attributes based on # of clients appropriately");
do_check_eq(scheduler.syncThreshold, SINGLE_USER_THRESHOLD); do_check_eq(scheduler.syncThreshold, SINGLE_USER_THRESHOLD);
do_check_eq(scheduler.syncInterval, scheduler.singleDeviceInterval); do_check_eq(scheduler.syncInterval, scheduler.singleDeviceInterval);
@ -186,7 +186,7 @@ add_identity_test(this, function test_updateClientMode() {
yield cleanUpAndGo(); yield cleanUpAndGo();
}); });
add_identity_test(this, function test_masterpassword_locked_retry_interval() { add_identity_test(this, function* test_masterpassword_locked_retry_interval() {
_("Test Status.login = MASTER_PASSWORD_LOCKED results in reschedule at MASTER_PASSWORD interval"); _("Test Status.login = MASTER_PASSWORD_LOCKED results in reschedule at MASTER_PASSWORD interval");
let loginFailed = false; let loginFailed = false;
Svc.Obs.add("weave:service:login:error", function onLoginError() { Svc.Obs.add("weave:service:login:error", function onLoginError() {
@ -223,7 +223,7 @@ add_identity_test(this, function test_masterpassword_locked_retry_interval() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_calculateBackoff() { add_identity_test(this, function* test_calculateBackoff() {
do_check_eq(Status.backoffInterval, 0); do_check_eq(Status.backoffInterval, 0);
// Test no interval larger than the maximum backoff is used if // Test no interval larger than the maximum backoff is used if
@ -245,7 +245,7 @@ add_identity_test(this, function test_calculateBackoff() {
yield cleanUpAndGo(); yield cleanUpAndGo();
}); });
add_identity_test(this, function test_scheduleNextSync_nowOrPast() { add_identity_test(this, function* test_scheduleNextSync_nowOrPast() {
let deferred = Promise.defer(); let deferred = Promise.defer();
Svc.Obs.add("weave:service:sync:finish", function onSyncFinish() { Svc.Obs.add("weave:service:sync:finish", function onSyncFinish() {
Svc.Obs.remove("weave:service:sync:finish", onSyncFinish); Svc.Obs.remove("weave:service:sync:finish", onSyncFinish);
@ -260,7 +260,7 @@ add_identity_test(this, function test_scheduleNextSync_nowOrPast() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_scheduleNextSync_future_noBackoff() { add_identity_test(this, function* test_scheduleNextSync_future_noBackoff() {
_("scheduleNextSync() uses the current syncInterval if no interval is provided."); _("scheduleNextSync() uses the current syncInterval if no interval is provided.");
// Test backoffInterval is 0 as expected. // Test backoffInterval is 0 as expected.
do_check_eq(Status.backoffInterval, 0); do_check_eq(Status.backoffInterval, 0);
@ -309,7 +309,7 @@ add_identity_test(this, function test_scheduleNextSync_future_noBackoff() {
yield cleanUpAndGo(); yield cleanUpAndGo();
}); });
add_identity_test(this, function test_scheduleNextSync_future_backoff() { add_identity_test(this, function* test_scheduleNextSync_future_backoff() {
_("scheduleNextSync() will honour backoff in all scheduling requests."); _("scheduleNextSync() will honour backoff in all scheduling requests.");
// Let's take a backoff interval that's bigger than the default sync interval. // Let's take a backoff interval that's bigger than the default sync interval.
const BACKOFF = 7337; const BACKOFF = 7337;
@ -359,7 +359,7 @@ add_identity_test(this, function test_scheduleNextSync_future_backoff() {
yield cleanUpAndGo(); yield cleanUpAndGo();
}); });
add_identity_test(this, function test_handleSyncError() { add_identity_test(this, function* test_handleSyncError() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -425,7 +425,7 @@ add_identity_test(this, function test_handleSyncError() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_client_sync_finish_updateClientMode() { add_identity_test(this, function* test_client_sync_finish_updateClientMode() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -459,7 +459,7 @@ add_identity_test(this, function test_client_sync_finish_updateClientMode() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_autoconnect_nextSync_past() { add_identity_test(this, function* test_autoconnect_nextSync_past() {
let deferred = Promise.defer(); let deferred = Promise.defer();
// nextSync will be 0 by default, so it's way in the past. // nextSync will be 0 by default, so it's way in the past.
@ -475,7 +475,7 @@ add_identity_test(this, function test_autoconnect_nextSync_past() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_autoconnect_nextSync_future() { add_identity_test(this, function* test_autoconnect_nextSync_future() {
let deferred = Promise.defer(); let deferred = Promise.defer();
let previousSync = Date.now() + scheduler.syncInterval / 2; let previousSync = Date.now() + scheduler.syncInterval / 2;
scheduler.nextSync = previousSync; scheduler.nextSync = previousSync;
@ -504,7 +504,7 @@ add_identity_test(this, function test_autoconnect_nextSync_future() {
// XXX - this test can't be run with the browserid identity as it relies // XXX - this test can't be run with the browserid identity as it relies
// on the syncKey getter behaving in a certain way... // on the syncKey getter behaving in a certain way...
add_task(function test_autoconnect_mp_locked() { add_task(function* test_autoconnect_mp_locked() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -541,7 +541,7 @@ add_task(function test_autoconnect_mp_locked() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_no_autoconnect_during_wizard() { add_identity_test(this, function* test_no_autoconnect_during_wizard() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -564,7 +564,7 @@ add_identity_test(this, function test_no_autoconnect_during_wizard() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_no_autoconnect_status_not_ok() { add_identity_test(this, function* test_no_autoconnect_status_not_ok() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
// Ensure we don't actually try to sync (or log in for that matter). // Ensure we don't actually try to sync (or log in for that matter).
@ -587,7 +587,7 @@ add_identity_test(this, function test_no_autoconnect_status_not_ok() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_autoconnectDelay_pref() { add_identity_test(this, function* test_autoconnectDelay_pref() {
let deferred = Promise.defer(); let deferred = Promise.defer();
Svc.Obs.add("weave:service:sync:finish", function onSyncFinish() { Svc.Obs.add("weave:service:sync:finish", function onSyncFinish() {
Svc.Obs.remove("weave:service:sync:finish", onSyncFinish); Svc.Obs.remove("weave:service:sync:finish", onSyncFinish);
@ -607,7 +607,7 @@ add_identity_test(this, function test_autoconnectDelay_pref() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_idle_adjustSyncInterval() { add_identity_test(this, function* test_idle_adjustSyncInterval() {
// Confirm defaults. // Confirm defaults.
do_check_eq(scheduler.idle, false); do_check_eq(scheduler.idle, false);
@ -627,7 +627,7 @@ add_identity_test(this, function test_idle_adjustSyncInterval() {
yield cleanUpAndGo(); yield cleanUpAndGo();
}); });
add_identity_test(this, function test_back_triggersSync() { add_identity_test(this, function* test_back_triggersSync() {
// Confirm defaults. // Confirm defaults.
do_check_false(scheduler.idle); do_check_false(scheduler.idle);
do_check_eq(Status.backoffInterval, 0); do_check_eq(Status.backoffInterval, 0);
@ -650,7 +650,7 @@ add_identity_test(this, function test_back_triggersSync() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_active_triggersSync_observesBackoff() { add_identity_test(this, function* test_active_triggersSync_observesBackoff() {
// Confirm defaults. // Confirm defaults.
do_check_false(scheduler.idle); do_check_false(scheduler.idle);
@ -681,7 +681,7 @@ add_identity_test(this, function test_active_triggersSync_observesBackoff() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_back_debouncing() { add_identity_test(this, function* test_back_debouncing() {
_("Ensure spurious back-then-idle events, as observed on OS X, don't trigger a sync."); _("Ensure spurious back-then-idle events, as observed on OS X, don't trigger a sync.");
// Confirm defaults. // Confirm defaults.
@ -709,7 +709,7 @@ add_identity_test(this, function test_back_debouncing() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_no_sync_node() { add_identity_test(this, function* test_no_sync_node() {
// Test when Status.sync == NO_SYNC_NODE_FOUND // Test when Status.sync == NO_SYNC_NODE_FOUND
// it is not overwritten on sync:finish // it is not overwritten on sync:finish
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -724,7 +724,7 @@ add_identity_test(this, function test_no_sync_node() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_sync_failed_partial_500s() { add_identity_test(this, function* test_sync_failed_partial_500s() {
_("Test a 5xx status calls handleSyncError."); _("Test a 5xx status calls handleSyncError.");
scheduler._syncErrors = MAX_ERROR_COUNT_BEFORE_BACKOFF; scheduler._syncErrors = MAX_ERROR_COUNT_BEFORE_BACKOFF;
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -751,7 +751,7 @@ add_identity_test(this, function test_sync_failed_partial_500s() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_sync_failed_partial_400s() { add_identity_test(this, function* test_sync_failed_partial_400s() {
_("Test a non-5xx status doesn't call handleSyncError."); _("Test a non-5xx status doesn't call handleSyncError.");
scheduler._syncErrors = MAX_ERROR_COUNT_BEFORE_BACKOFF; scheduler._syncErrors = MAX_ERROR_COUNT_BEFORE_BACKOFF;
let server = sync_httpd_setup(); let server = sync_httpd_setup();
@ -781,7 +781,7 @@ add_identity_test(this, function test_sync_failed_partial_400s() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_sync_X_Weave_Backoff() { add_identity_test(this, function* test_sync_X_Weave_Backoff() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -836,7 +836,7 @@ add_identity_test(this, function test_sync_X_Weave_Backoff() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_sync_503_Retry_After() { add_identity_test(this, function* test_sync_503_Retry_After() {
let server = sync_httpd_setup(); let server = sync_httpd_setup();
yield setUp(server); yield setUp(server);
@ -895,7 +895,7 @@ add_identity_test(this, function test_sync_503_Retry_After() {
yield cleanUpAndGo(server); yield cleanUpAndGo(server);
}); });
add_identity_test(this, function test_loginError_recoverable_reschedules() { add_identity_test(this, function* test_loginError_recoverable_reschedules() {
_("Verify that a recoverable login error schedules a new sync."); _("Verify that a recoverable login error schedules a new sync.");
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
Service.serverURL = "http://localhost:1234/"; Service.serverURL = "http://localhost:1234/";
@ -939,7 +939,7 @@ add_identity_test(this, function test_loginError_recoverable_reschedules() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_loginError_fatal_clearsTriggers() { add_identity_test(this, function* test_loginError_fatal_clearsTriggers() {
_("Verify that a fatal login error clears sync triggers."); _("Verify that a fatal login error clears sync triggers.");
yield configureIdentity({username: "johndoe"}); yield configureIdentity({username: "johndoe"});
@ -986,7 +986,7 @@ add_identity_test(this, function test_loginError_fatal_clearsTriggers() {
yield deferred.promise; yield deferred.promise;
}); });
add_identity_test(this, function test_proper_interval_on_only_failing() { add_identity_test(this, function* test_proper_interval_on_only_failing() {
_("Ensure proper behavior when only failed records are applied."); _("Ensure proper behavior when only failed records are applied.");
// If an engine reports that no records succeeded, we shouldn't decrease the // If an engine reports that no records succeeded, we shouldn't decrease the

View File

@ -977,7 +977,10 @@ function browserAdditions (controller) {
return windows.map.hasPageLoaded(utils.getWindowId(win)); return windows.map.hasPageLoaded(utils.getWindowId(win));
}, "Timeout", timeout, aInterval); }, "Timeout", timeout, aInterval);
} }
catch (ex if ex instanceof errors.TimeoutError) { catch (ex) {
if (!ex instanceof errors.TimeoutError) {
throw ex;
}
timed_out = true; timed_out = true;
} }
finally { finally {

View File

@ -658,7 +658,10 @@ Expect.prototype.waitFor = function Expect_waitFor(aCallback, aMessage, aTimeout
try { try {
Assert.prototype.waitFor.apply(this, arguments); Assert.prototype.waitFor.apply(this, arguments);
} }
catch (ex if ex instanceof errors.AssertionError) { catch (ex) {
if (!ex instanceof errors.AssertionError) {
throw ex;
}
message = ex.message; message = ex.message;
condition = false; condition = false;
} }

View File

@ -321,7 +321,10 @@
}); });
try { try {
channel.open2().close(); channel.open2().close();
} catch (e if e.result == Cr.NS_ERROR_FILE_NOT_FOUND) { } catch (e) {
if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) {
throw e;
}
return null; return null;
} }
return newURI.spec; return newURI.spec;