Bug 951118 - TypeError when null account is verified. r=ferjm
authorJed Parsons <jedp@mozilla.com>
Tue, 17 Dec 2013 11:14:11 -0800
changeset 161096 f3d509e75433e6fa82b2e6bf9555b4cfd32e83cf
parent 161095 55d8f5ede1d336f829e8107fa44641ee13fb8606
child 161097 c7493af8325d53cbe696e610bf1cfd61bdf7f0fa
push id25867
push userryanvm@gmail.com
push dateThu, 19 Dec 2013 02:19:33 +0000
treeherdermozilla-central@04a70c8908de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjm
bugs951118
milestone29.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 951118 - TypeError when null account is verified. r=ferjm
services/fxaccounts/FxAccounts.jsm
services/fxaccounts/tests/xpcshell/test_accounts.js
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -139,17 +139,17 @@ InternalMethods.prototype = {
       if (!data) {
         throw new Error("Can't get keys; User is not signed in");
       }
       if (data.kA && data.kB) {
         return data;
       }
       if (!this.whenKeysReadyPromise) {
         this.whenKeysReadyPromise = Promise.defer();
-        this.fetchAndUnwrapKeys(data.keyFetchToken)
+        return this.fetchAndUnwrapKeys(data.keyFetchToken)
           .then((data) => {
             if (this.whenKeysReadyPromise) {
               this.whenKeysReadyPromise.resolve(data);
             }
           });
       }
       return this.whenKeysReadyPromise.promise;
       });
--- a/services/fxaccounts/tests/xpcshell/test_accounts.js
+++ b/services/fxaccounts/tests/xpcshell/test_accounts.js
@@ -257,39 +257,42 @@ add_test(function test_polling_timeout()
         removeObserver();
         do_test_finished();
         run_next_test();
       }
     );
   });
 });
 
-add_task(function test_getKeys() {
+add_test(function test_getKeys() {
+  do_test_pending();
   let fxa = new MockFxAccounts();
   let user = getTestUser("eusebius");
 
   // Once email has been verified, we will be able to get keys
   user.isVerified = true;
 
   fxa.setSignedInUser(user).then(() => {
     fxa.getSignedInUser().then((user) => {
       // Before getKeys, we have no keys
-      do_check_eq(!!data.kA, false);
-      do_check_eq(!!data.kB, false);
+      do_check_eq(!!user.kA, false);
+      do_check_eq(!!user.kB, false);
       // And we still have a key-fetch token to use
-      do_check_eq(!!data.keyFetchToken, true);
+      do_check_eq(!!user.keyFetchToken, true);
 
       fxa.internal.getKeys().then(() => {
         fxa.getSignedInUser().then((user) => {
           // Now we should have keys
-          do_check_eq(fxa.internal.isUserEmailVerified(data), true);
-          do_check_eq(!!data.isVerified, true);
-          do_check_eq(data.kA, expandHex("11"));
-          do_check_eq(data.kB, expandHex("66"));
-          do_check_eq(data.keyFetchToken, undefined);
+          do_check_eq(fxa.internal.isUserEmailVerified(user), true);
+          do_check_eq(!!user.isVerified, true);
+          do_check_eq(user.kA, expandHex("11"));
+          do_check_eq(user.kB, expandHex("66"));
+          do_check_eq(user.keyFetchToken, undefined);
+          do_test_finished();
+          run_next_test();
         });
       });
     });
   });
 });
 
 /*
  * getKeys with no keyFetchToken should trigger signOut