mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 984172 (part 2) - replace Assert_rejects with Assert.rejects. r=ttaubert
This commit is contained in:
parent
ec078e1cd2
commit
9c34a28832
@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"Assert_rejects",
|
||||
"initializeIdentityWithTokenServerResponse",
|
||||
];
|
||||
|
||||
@ -14,17 +13,6 @@ Cu.import("resource://services-common/tokenserverclient.js");
|
||||
Cu.import("resource://testing-common/services/common/logging.js");
|
||||
Cu.import("resource://testing-common/services/sync/utils.js");
|
||||
|
||||
// This shouldn't be here - it should be part of the xpcshell harness.
|
||||
// Maybe as Assert.rejects - so we name it like that.
|
||||
function Assert_rejects(promise, message) {
|
||||
let deferred = Promise.defer();
|
||||
promise.then(
|
||||
() => deferred.reject(message || "Expected the promise to be rejected"),
|
||||
deferred.resolve
|
||||
);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Create a new browserid_identity object and initialize it with a
|
||||
// mocked TokenServerClient which always receives the specified response.
|
||||
this.initializeIdentityWithTokenServerResponse = function(response) {
|
||||
|
@ -269,12 +269,12 @@ add_task(function test_ensureLoggedIn() {
|
||||
Assert.ok(!browseridManager._shouldHaveSyncKeyBundle,
|
||||
"_shouldHaveSyncKeyBundle should be false so we know we are testing what we think we are.");
|
||||
Status.login = LOGIN_FAILED_NO_USERNAME;
|
||||
yield Assert_rejects(browseridManager.ensureLoggedIn(), "expecting rejection due to no user");
|
||||
yield Assert.rejects(browseridManager.ensureLoggedIn(), "expecting rejection due to no user");
|
||||
Assert.ok(browseridManager._shouldHaveSyncKeyBundle,
|
||||
"_shouldHaveSyncKeyBundle should always be true after ensureLogin completes.");
|
||||
fxa.internal.currentAccountState.signedInUser = signedInUser;
|
||||
Status.login = LOGIN_FAILED_LOGIN_REJECTED;
|
||||
yield Assert_rejects(browseridManager.ensureLoggedIn(),
|
||||
yield Assert.rejects(browseridManager.ensureLoggedIn(),
|
||||
"LOGIN_FAILED_LOGIN_REJECTED should have caused immediate rejection");
|
||||
Assert.equal(Status.login, LOGIN_FAILED_LOGIN_REJECTED,
|
||||
"status should remain LOGIN_FAILED_LOGIN_REJECTED");
|
||||
@ -360,7 +360,7 @@ add_task(function test_getTokenErrors() {
|
||||
let browseridManager = Service.identity;
|
||||
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 401");
|
||||
Assert.equal(Status.login, LOGIN_FAILED_LOGIN_REJECTED, "login was rejected");
|
||||
|
||||
@ -376,7 +376,7 @@ add_task(function test_getTokenErrors() {
|
||||
});
|
||||
browseridManager = Service.identity;
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to non-JSON response");
|
||||
Assert.equal(Status.login, LOGIN_FAILED_NETWORK_ERROR, "login state is LOGIN_FAILED_NETWORK_ERROR");
|
||||
});
|
||||
@ -397,7 +397,7 @@ add_task(function test_getTokenErrorWithRetry() {
|
||||
let browseridManager = Service.identity;
|
||||
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 503");
|
||||
|
||||
// The observer should have fired - check it got the value in the response.
|
||||
@ -416,7 +416,7 @@ add_task(function test_getTokenErrorWithRetry() {
|
||||
browseridManager = Service.identity;
|
||||
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to no token in response");
|
||||
|
||||
// The observer should have fired - check it got the value in the response.
|
||||
@ -448,7 +448,7 @@ add_task(function test_getKeysErrorWithBackoff() {
|
||||
});
|
||||
|
||||
let browseridManager = Service.identity;
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 503");
|
||||
|
||||
// The observer should have fired - check it got the value in the response.
|
||||
@ -482,7 +482,7 @@ add_task(function test_getKeysErrorWithRetry() {
|
||||
});
|
||||
|
||||
let browseridManager = Service.identity;
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 503");
|
||||
|
||||
// The observer should have fired - check it got the value in the response.
|
||||
@ -666,7 +666,7 @@ function* initializeIdentityWithHAWKResponseFactory(config, cbGetResponse) {
|
||||
browseridManager._fxaService = fxa;
|
||||
browseridManager._signedInUser = null;
|
||||
yield browseridManager.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(browseridManager.whenReadyToAuthenticate.promise,
|
||||
"expecting rejection due to hawk error");
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ add_task(function test_findCluster() {
|
||||
});
|
||||
|
||||
yield Service.identity.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(Service.identity.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(Service.identity.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 500");
|
||||
|
||||
Assert.throws(function() {
|
||||
@ -32,7 +32,7 @@ add_task(function test_findCluster() {
|
||||
});
|
||||
|
||||
yield Service.identity.initializeWithCurrentIdentity();
|
||||
yield Assert_rejects(Service.identity.whenReadyToAuthenticate.promise,
|
||||
yield Assert.rejects(Service.identity.whenReadyToAuthenticate.promise,
|
||||
"should reject due to 401");
|
||||
|
||||
cluster = Service._clusterManager._findCluster();
|
||||
|
Loading…
Reference in New Issue
Block a user