diff --git a/b2g/components/test/unit/test_fxaccounts.js b/b2g/components/test/unit/test_fxaccounts.js index 63ebfce2090..be45ed3b957 100644 --- a/b2g/components/test/unit/test_fxaccounts.js +++ b/b2g/components/test/unit/test_fxaccounts.js @@ -11,8 +11,11 @@ Cu.import("resource://services-common/utils.js"); Cu.import("resource://testing-common/httpd.js"); XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsMgmtService", - "resource://gre/modules/FxAccountsMgmtService.jsm", - "FxAccountsMgmtService"); + "resource://gre/modules/FxAccountsMgmtService.jsm", + "FxAccountsMgmtService"); + +XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsManager", + "resource://gre/modules/FxAccountsManager.jsm"); // At end of test, restore original state const ORIGINAL_AUTH_URI = Services.prefs.getCharPref("identity.fxaccounts.auth.uri"); @@ -158,6 +161,22 @@ add_test(function test_invalidEmailCase_signIn() { }); }); +add_test(function testHandleGetAssertionError_defaultCase() { + do_test_pending(); + + FxAccountsManager.getAssertion(null).then( + success => { + // getAssertion should throw with invalid audience + ok(false); + }, + reason => { + equal("INVALID_AUDIENCE", reason.error); + do_test_finished(); + run_next_test(); + } + ) +}); + // End of tests // Utility functions follow diff --git a/services/fxaccounts/FxAccountsManager.jsm b/services/fxaccounts/FxAccountsManager.jsm index 0baae63635f..c3609ee91c8 100644 --- a/services/fxaccounts/FxAccountsManager.jsm +++ b/services/fxaccounts/FxAccountsManager.jsm @@ -204,7 +204,7 @@ this.FxAccountsManager = { } ); } - return rejection; + return Promise.reject(reason); }, _getAssertion: function(aAudience) {