Bug 1036198 - Rejection not defined in _handleGetAssertionError. r=spenrose, a=bajaj
authorJed Parsons <jed+bmo@jedparsons.com>
Tue, 08 Jul 2014 18:00:25 -0700
changeset 208944 629db6ea47881f7dac3491fcaac2914a227c7a90
parent 208943 bcd461c3bb21c617935569cc524ff8c4dad9acf6
child 208945 baef22b16b6929dd110dee899a0834af52b6fb38
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspenrose, bajaj
bugs1036198
milestone32.0a2
Bug 1036198 - Rejection not defined in _handleGetAssertionError. r=spenrose, a=bajaj
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) => {