Bug 1036198 - rejection not defined in _handleGetAssertionError. r=spenrose
authorJed Parsons <jed+bmo@jedparsons.com>
Tue, 08 Jul 2014 18:00:25 -0700
changeset 214065 5cbe17e565074fe9a0dcb036d68d42b5b7a61c43
parent 214064 ab6938cf518fcfc87539d944e5c54107754eeea6
child 214066 ab7e8e8c1e0002266998619f9b950293e406a003
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspenrose
bugs1036198
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1036198 - rejection not defined in _handleGetAssertionError. r=spenrose
b2g/components/test/unit/test_fxaccounts.js
services/fxaccounts/FxAccountsManager.jsm
--- a/b2g/components/test/unit/test_fxaccounts.js
+++ b/b2g/components/test/unit/test_fxaccounts.js
@@ -6,18 +6,21 @@
 const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 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");
 let { SystemAppProxy } = Cu.import("resource://gre/modules/FxAccountsMgmtService.jsm");
 const ORIGINAL_SENDCUSTOM = SystemAppProxy._sendCustomEvent;
 do_register_cleanup(function() {
   Services.prefs.setCharPref("identity.fxaccounts.auth.uri", ORIGINAL_AUTH_URI);
   SystemAppProxy._sendCustomEvent = ORIGINAL_SENDCUSTOM;
@@ -153,16 +156,32 @@ add_test(function test_invalidEmailCase_
         method: "signIn",
         email: clientEmail,
         password: "123456",
       },
     },
   });
 });
 
+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
 
 function httpd_setup (handlers, port=-1) {
   let server = new HttpServer();
   for (let path in handlers) {
     server.registerPathHandler(path, handlers[path]);
   }
--- a/services/fxaccounts/FxAccountsManager.jsm
+++ b/services/fxaccounts/FxAccountsManager.jsm
@@ -199,17 +199,17 @@ this.FxAccountsManager = {
                 log.error("Signing out in response to server error threw: " + reason);
                 return this._error(reason);
               }
             );
           }
         }
       );
     }
-    return rejection;
+    return Promise.reject(reason);
   },
 
   _getAssertion: function(aAudience) {
     return this._fxAccounts.getAssertion(aAudience).then(
       (result) => {
         return result;
       },
       (reason) => {