michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: const Cm = Components.manager; michael@0: michael@0: Cu.import("resource://gre/modules/FxAccounts.jsm"); michael@0: Cu.import("resource://gre/modules/FxAccountsCommon.js"); michael@0: Cu.import("resource://gre/modules/FxAccountsManager.jsm"); michael@0: Cu.import("resource://gre/modules/Promise.jsm"); michael@0: michael@0: // === Mocks === michael@0: michael@0: // Override FxAccountsUIGlue. michael@0: const kFxAccountsUIGlueUUID = "{8f6d5d87-41ed-4bb5-aa28-625de57564c5}"; michael@0: const kFxAccountsUIGlueContractID = michael@0: "@mozilla.org/fxaccounts/fxaccounts-ui-glue;1"; michael@0: michael@0: // Save original FxAccountsUIGlue factory. michael@0: const kFxAccountsUIGlueFactory = michael@0: Cm.getClassObject(Cc[kFxAccountsUIGlueContractID], Ci.nsIFactory); michael@0: michael@0: let fakeFxAccountsUIGlueFactory = { michael@0: createInstance: function(aOuter, aIid) { michael@0: return FxAccountsUIGlue.QueryInterface(aIid); michael@0: } michael@0: }; michael@0: michael@0: // FxAccountsUIGlue fake component. michael@0: let FxAccountsUIGlue = { michael@0: _reject: false, michael@0: michael@0: _error: 'error', michael@0: michael@0: _signInFlowCalled: false, michael@0: michael@0: _refreshAuthCalled: false, michael@0: michael@0: _activeSession: null, michael@0: michael@0: _reset: function() { michael@0: this._reject = false; michael@0: this._error = 'error'; michael@0: this._signInFlowCalled = false; michael@0: this._refreshAuthCalled = false; michael@0: }, michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIFxAccountsUIGlue]), michael@0: michael@0: _promise: function() { michael@0: let deferred = Promise.defer(); michael@0: michael@0: if (this._reject) { michael@0: deferred.reject(this._error); michael@0: } else { michael@0: FxAccountsManager._activeSession = this._activeSession || { michael@0: email: "user@domain.org", michael@0: verified: false, michael@0: sessionToken: "1234" michael@0: }; michael@0: FxAccountsManager._fxAccounts michael@0: .setSignedInUser(FxAccountsManager._activeSession); michael@0: deferred.resolve(FxAccountsManager._activeSession); michael@0: } michael@0: michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: signInFlow: function() { michael@0: this._signInFlowCalled = true; michael@0: return this._promise(); michael@0: }, michael@0: michael@0: refreshAuthentication: function() { michael@0: this._refreshAuthCalled = true; michael@0: return this._promise(); michael@0: } michael@0: }; michael@0: michael@0: (function registerFakeFxAccountsUIGlue() { michael@0: Cm.QueryInterface(Ci.nsIComponentRegistrar) michael@0: .registerFactory(Components.ID(kFxAccountsUIGlueUUID), michael@0: "FxAccountsUIGlue", michael@0: kFxAccountsUIGlueContractID, michael@0: fakeFxAccountsUIGlueFactory); michael@0: })(); michael@0: michael@0: // Save original fxAccounts instance michael@0: const kFxAccounts = fxAccounts; michael@0: // and change it for a mock FxAccounts. michael@0: FxAccountsManager._fxAccounts = { michael@0: _reject: false, michael@0: _getSignedInUserCalled: false, michael@0: _setSignedInUserCalled: false, michael@0: michael@0: _error: 'error', michael@0: _assertion: 'assertion', michael@0: _signedInUser: null, michael@0: michael@0: _reset: function() { michael@0: this._getSignedInUserCalled = false; michael@0: this._setSignedInUserCalled = false; michael@0: this._reject = false; michael@0: }, michael@0: michael@0: getAssertion: function() { michael@0: if (!this._signedInUser) { michael@0: return null; michael@0: } michael@0: michael@0: let deferred = Promise.defer(); michael@0: deferred.resolve(this._assertion); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: getSignedInUser: function() { michael@0: this._getSignedInUserCalled = true; michael@0: let deferred = Promise.defer(); michael@0: this._reject ? deferred.reject(this._error) michael@0: : deferred.resolve(this._signedInUser); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: setSignedInUser: function(user) { michael@0: this._setSignedInUserCalled = true; michael@0: let deferred = Promise.defer(); michael@0: this._signedInUser = user; michael@0: deferred.resolve(); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: signOut: function() { michael@0: let deferred = Promise.defer(); michael@0: this._signedInUser = null; michael@0: Services.obs.notifyObservers(null, ONLOGOUT_NOTIFICATION, null); michael@0: deferred.resolve(); michael@0: return deferred.promise; michael@0: } michael@0: }; michael@0: michael@0: // Save original FxAccountsClient factory from FxAccountsManager. michael@0: const kFxAccountsClient = FxAccountsManager._getFxAccountsClient; michael@0: michael@0: // and change it for a fake client factory. michael@0: let FakeFxAccountsClient = { michael@0: _reject: false, michael@0: _recoveryEmailStatusCalled: false, michael@0: _signInCalled: false, michael@0: _signUpCalled: false, michael@0: _signOutCalled: false, michael@0: michael@0: _accountExists: false, michael@0: _verified: false, michael@0: _password: null, michael@0: michael@0: _reset: function() { michael@0: this._reject = false; michael@0: this._recoveryEmailStatusCalled = false; michael@0: this._signInCalled = false; michael@0: this._signUpCalled = false; michael@0: this._signOutCalled = false; michael@0: }, michael@0: michael@0: recoveryEmailStatus: function() { michael@0: this._recoveryEmailStatusCalled = true; michael@0: let deferred = Promise.defer(); michael@0: this._reject ? deferred.reject() michael@0: : deferred.resolve({ verified: this._verified }); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: signIn: function(user, password) { michael@0: this._signInCalled = true; michael@0: this._password = password; michael@0: let deferred = Promise.defer(); michael@0: this._reject ? deferred.reject() michael@0: : deferred.resolve({ email: user, michael@0: uid: "whatever", michael@0: verified: this._verified, michael@0: sessionToken: "1234" }); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: signUp: function(user, password) { michael@0: this._signUpCalled = true; michael@0: return this.signIn(user, password); michael@0: }, michael@0: michael@0: signOut: function() { michael@0: this._signOutCalled = true; michael@0: let deferred = Promise.defer(); michael@0: this._reject ? deferred.reject() michael@0: : deferred.resolve(); michael@0: return deferred.promise; michael@0: }, michael@0: michael@0: accountExists: function() { michael@0: let deferred = Promise.defer(); michael@0: this._reject ? deferred.reject() michael@0: : deferred.resolve(this._accountExists); michael@0: return deferred.promise; michael@0: } michael@0: }; michael@0: michael@0: FxAccountsManager._getFxAccountsClient = function() { michael@0: return FakeFxAccountsClient; michael@0: }; michael@0: michael@0: michael@0: // === Global cleanup === michael@0: michael@0: // Unregister mocks and restore original code. michael@0: do_register_cleanup(function() { michael@0: // Unregister the factory so we do not leak michael@0: Cm.QueryInterface(Ci.nsIComponentRegistrar) michael@0: .unregisterFactory(Components.ID(kFxAccountsUIGlueUUID), michael@0: fakeFxAccountsUIGlueFactory); michael@0: michael@0: // Restore the original factory. michael@0: Cm.QueryInterface(Ci.nsIComponentRegistrar) michael@0: .registerFactory(Components.ID(kFxAccountsUIGlueUUID), michael@0: "FxAccountsUIGlue", michael@0: kFxAccountsUIGlueContractID, michael@0: kFxAccountsUIGlueFactory); michael@0: michael@0: // Restore the original FxAccounts instance from FxAccountsManager. michael@0: FxAccountsManager._fxAccounts = kFxAccounts; michael@0: michael@0: // Restore the FxAccountsClient getter from FxAccountsManager. michael@0: FxAccountsManager._getFxAccountsClient = kFxAccountsClient; michael@0: }); michael@0: michael@0: michael@0: // === Tests === michael@0: michael@0: function run_test() { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_test(function test_initial_state() { michael@0: do_print("= Initial state ="); michael@0: do_check_neq(FxAccountsManager, undefined); michael@0: do_check_null(FxAccountsManager._activeSession); michael@0: do_check_null(FxAccountsManager._user); michael@0: run_next_test(); michael@0: }); michael@0: michael@0: add_test(function(test_getAccount_no_session) { michael@0: do_print("= getAccount no session ="); michael@0: FxAccountsManager.getAccount().then( michael@0: result => { michael@0: do_check_null(result); michael@0: do_check_null(FxAccountsManager._activeSession); michael@0: do_check_null(FxAccountsManager._user); michael@0: do_check_true(FxAccountsManager._fxAccounts._getSignedInUserCalled); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_no_audience) { michael@0: do_print("= getAssertion no audience ="); michael@0: FxAccountsManager.getAssertion().then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_AUDIENCE); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_no_session_ui_error) { michael@0: do_print("= getAssertion no session, UI error ="); michael@0: FxAccountsUIGlue._reject = true; michael@0: FxAccountsManager.getAssertion("audience").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_UI_ERROR); michael@0: do_check_eq(error.details, "error"); michael@0: FxAccountsUIGlue._reset(); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_no_session_ui_success) { michael@0: do_print("= getAssertion no session, UI success ="); michael@0: FxAccountsManager.getAssertion("audience").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_true(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_eq(error.error, ERROR_UNVERIFIED_ACCOUNT); michael@0: FxAccountsUIGlue._reset(); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_active_session_unverified_account) { michael@0: do_print("= getAssertion active session, unverified account ="); michael@0: FxAccountsManager.getAssertion("audience").then( michael@0: result => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_false(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_eq(error.error, ERROR_UNVERIFIED_ACCOUNT); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_active_session_verified_account) { michael@0: do_print("= getAssertion active session, verified account ="); michael@0: FxAccountsManager._fxAccounts._signedInUser.verified = true; michael@0: FxAccountsManager._activeSession.verified = true; michael@0: FxAccountsManager.getAssertion("audience").then( michael@0: result => { michael@0: do_check_false(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_eq(result, "assertion"); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_refreshAuth) { michael@0: do_print("= getAssertion refreshAuth ="); michael@0: let gracePeriod = 1200; michael@0: FxAccountsUIGlue._activeSession = { michael@0: email: "user@domain.org", michael@0: verified: true, michael@0: sessionToken: "1234" michael@0: }; michael@0: FxAccountsManager._fxAccounts._signedInUser.verified = true; michael@0: FxAccountsManager._activeSession.verified = true; michael@0: FxAccountsManager._activeSession.authAt = michael@0: (Date.now() / 1000) - gracePeriod; michael@0: FxAccountsManager.getAssertion("audience", { michael@0: "refreshAuthentication": gracePeriod michael@0: }).then( michael@0: result => { michael@0: do_check_false(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_true(FxAccountsUIGlue._refreshAuthCalled); michael@0: do_check_eq(result, "assertion"); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: FxAccountsUIGlue._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_refreshAuth_NaN) { michael@0: do_print("= getAssertion refreshAuth NaN="); michael@0: let gracePeriod = "NaN"; michael@0: FxAccountsManager.getAssertion("audience", { michael@0: "refreshAuthentication": gracePeriod michael@0: }).then( michael@0: result => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_false(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_false(FxAccountsUIGlue._refreshAuthCalled); michael@0: do_check_eq(error.error, ERROR_INVALID_REFRESH_AUTH_VALUE); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAssertion_refresh_auth_no_refresh) { michael@0: do_print("= getAssertion refreshAuth no refresh ="); michael@0: FxAccountsManager._fxAccounts._signedInUser.verified = true; michael@0: FxAccountsManager._activeSession.verified = true; michael@0: FxAccountsManager._activeSession.authAt = michael@0: (Date.now() / 1000) + 10000; michael@0: FxAccountsManager.getAssertion("audience", { michael@0: "refreshAuthentication": 1 michael@0: }).then( michael@0: result => { michael@0: do_check_false(FxAccountsUIGlue._signInFlowCalled); michael@0: do_check_eq(result, "assertion"); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAccount_existing_verified_session) { michael@0: do_print("= getAccount, existing verified session ="); michael@0: FxAccountsManager.getAccount().then( michael@0: result => { michael@0: do_check_false(FxAccountsManager._fxAccounts._getSignedInUserCalled); michael@0: do_check_eq(result.accountId, FxAccountsManager._user.accountId); michael@0: do_check_eq(result.verified, FxAccountsManager._user.verified); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAccount_existing_unverified_session_unverified_user) { michael@0: do_print("= getAccount, existing unverified session, unverified user ="); michael@0: FxAccountsManager._activeSession.verified = false; michael@0: FxAccountsManager._fxAccounts._signedInUser.verified = false; michael@0: FxAccountsManager.getAccount().then( michael@0: result => { michael@0: do_check_true(FakeFxAccountsClient._recoveryEmailStatusCalled); michael@0: do_check_false(result.verified); michael@0: do_check_eq(result.accountId, FxAccountsManager._user.accountId); michael@0: FakeFxAccountsClient._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_getAccount_existing_unverified_session_verified_user) { michael@0: do_print("= getAccount, existing unverified session, verified user ="); michael@0: FxAccountsManager._activeSession.verified = false; michael@0: FxAccountsManager._fxAccounts._signedInUser.verified = false; michael@0: FakeFxAccountsClient._verified = true; michael@0: FxAccountsManager.getAccount(); michael@0: do_execute_soon(function() { michael@0: do_check_true(FakeFxAccountsClient._recoveryEmailStatusCalled); michael@0: FxAccountsManager.getAccount().then( michael@0: result => { michael@0: do_check_true(result.verified); michael@0: do_check_eq(result.accountId, FxAccountsManager._user.accountId); michael@0: FakeFxAccountsClient._reset(); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function(test_signOut) { michael@0: do_print("= signOut ="); michael@0: do_check_true(FxAccountsManager._activeSession != null); michael@0: FxAccountsManager.signOut().then( michael@0: result => { michael@0: do_check_null(result); michael@0: do_check_null(FxAccountsManager._activeSession); michael@0: do_check_true(FakeFxAccountsClient._signOutCalled); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signUp_no_accountId) { michael@0: do_print("= signUp, no accountId="); michael@0: FxAccountsManager.signUp().then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_ACCOUNTID); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signIn_no_accountId) { michael@0: do_print("= signIn, no accountId="); michael@0: FxAccountsManager.signIn().then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_ACCOUNTID); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signUp_no_password) { michael@0: do_print("= signUp, no accountId="); michael@0: FxAccountsManager.signUp("user@domain.org").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_PASSWORD); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signIn_no_accountId) { michael@0: do_print("= signIn, no accountId="); michael@0: FxAccountsManager.signIn("user@domain.org").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_PASSWORD); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signUp) { michael@0: do_print("= signUp ="); michael@0: FakeFxAccountsClient._verified = false; michael@0: FxAccountsManager.signUp("user@domain.org", "password").then( michael@0: result => { michael@0: do_check_true(FakeFxAccountsClient._signInCalled); michael@0: do_check_true(FakeFxAccountsClient._signUpCalled); michael@0: do_check_true(FxAccountsManager._fxAccounts._getSignedInUserCalled); michael@0: do_check_eq(FxAccountsManager._fxAccounts._signedInUser.email, "user@domain.org"); michael@0: do_check_eq(FakeFxAccountsClient._password, "password"); michael@0: do_check_true(result.accountCreated); michael@0: do_check_eq(result.user.accountId, "user@domain.org"); michael@0: do_check_false(result.user.verified); michael@0: FakeFxAccountsClient._reset(); michael@0: FxAccountsManager._fxAccounts._reset(); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error.error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signUp_already_signed_user) { michael@0: do_print("= signUp, already signed user ="); michael@0: FxAccountsManager.signUp("user@domain.org", "password").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_false(FakeFxAccountsClient._signInCalled); michael@0: do_check_eq(error.error, ERROR_ALREADY_SIGNED_IN_USER); michael@0: do_check_eq(error.details.user.accountId, "user@domain.org"); michael@0: do_check_false(error.details.user.verified); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_signIn_already_signed_user) { michael@0: do_print("= signIn, already signed user ="); michael@0: FxAccountsManager.signIn("user@domain.org", "password").then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_ALREADY_SIGNED_IN_USER); michael@0: do_check_eq(error.details.user.accountId, "user@domain.org"); michael@0: do_check_false(error.details.user.verified); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_verificationStatus_unverified_session_unverified_user) { michael@0: do_print("= verificationStatus unverified session and user ="); michael@0: FakeFxAccountsClient._verified = false; michael@0: FxAccountsManager.verificationStatus(); michael@0: do_execute_soon(function() { michael@0: let user = FxAccountsManager._user; michael@0: do_check_false(user.verified); michael@0: do_check_true(FakeFxAccountsClient._recoveryEmailStatusCalled); michael@0: do_check_false(FxAccountsManager._fxAccounts._setSignedInUserCalled); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function(test_verificationStatus_unverified_session_verified_user) { michael@0: do_print("= verificationStatus unverified session, verified user ="); michael@0: FakeFxAccountsClient._verified = true; michael@0: FxAccountsManager.verificationStatus(); michael@0: do_execute_soon(function() { michael@0: let user = FxAccountsManager._user; michael@0: do_check_true(user.verified); michael@0: do_check_true(FakeFxAccountsClient._recoveryEmailStatusCalled); michael@0: do_check_true(FxAccountsManager._fxAccounts._setSignedInUserCalled); michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function(test_queryAccount_no_exists) { michael@0: do_print("= queryAccount, no exists ="); michael@0: FxAccountsManager.queryAccount("user@domain.org").then( michael@0: result => { michael@0: do_check_false(result.registered); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_queryAccount_exists) { michael@0: do_print("= queryAccount, exists ="); michael@0: FakeFxAccountsClient._accountExists = true; michael@0: FxAccountsManager.queryAccount("user@domain.org").then( michael@0: result => { michael@0: do_check_true(result.registered); michael@0: run_next_test(); michael@0: }, michael@0: error => { michael@0: do_throw("Unexpected error: " + error); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function(test_queryAccount_no_accountId) { michael@0: do_print("= queryAccount, no accountId ="); michael@0: FxAccountsManager.queryAccount().then( michael@0: () => { michael@0: do_throw("Unexpected success"); michael@0: }, michael@0: error => { michael@0: do_check_eq(error.error, ERROR_INVALID_ACCOUNTID); michael@0: run_next_test(); michael@0: } michael@0: ); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: do_print("= fxaccounts:onlogout notification ="); michael@0: do_check_true(FxAccountsManager._activeSession != null); michael@0: Services.obs.notifyObservers(null, ONLOGOUT_NOTIFICATION, null); michael@0: do_execute_soon(function() { michael@0: do_check_null(FxAccountsManager._activeSession); michael@0: run_next_test(); michael@0: }); michael@0: });