Backed out changeset 68ba8f6f4f03 (bug 983445) for suspicion of causing xpcshell timeouts in test_browserid_identity.js.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 16 Apr 2014 15:14:42 -0400
changeset 179335 711ddfbb8bbf006ce4acdffe0c81454cc1548b69
parent 179334 59f4f732f6d7969faff8894cbb97949f38d76aab
child 179336 09847ac2ab608b1567d806e225fef25829f5b345
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
bugs983445
milestone31.0a1
backs out68ba8f6f4f03f6700e4ed2a8d9ce04980ead824b
Backed out changeset 68ba8f6f4f03 (bug 983445) for suspicion of causing xpcshell timeouts in test_browserid_identity.js.
services/fxaccounts/FxAccounts.jsm
services/fxaccounts/tests/xpcshell/test_accounts.js
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -500,53 +500,48 @@ FxAccountsInternal.prototype = {
    *          kA: An encryption key from the FxA server
    *          kB: An encryption key derived from the user's FxA password
    *          verified: email verification status
    *        }
    *        or null if no user is signed in
    */
   getKeys: function() {
     let currentState = this.currentAccountState;
-    return currentState.getUserAccountData().then((userData) => {
-      if (!userData) {
+    return currentState.getUserAccountData().then((data) => {
+      if (!data) {
         throw new Error("Can't get keys; User is not signed in");
       }
-      if (userData.kA && userData.kB) {
-        return userData;
+      if (data.kA && data.kB) {
+        return data;
       }
       if (!currentState.whenKeysReadyDeferred) {
         currentState.whenKeysReadyDeferred = Promise.defer();
-        if (userData.keyFetchToken) {
-          this.fetchAndUnwrapKeys(userData.keyFetchToken).then(
-            (dataWithKeys) => {
-              if (!dataWithKeys.kA || !dataWithKeys.kB) {
-                currentState.whenKeysReadyDeferred.reject(
-                  new Error("user data missing kA or kB")
-                );
-                return;
-              }
-              currentState.whenKeysReadyDeferred.resolve(dataWithKeys);
-            },
-            (err) => {
-              currentState.whenKeysReadyDeferred.reject(err);
+        this.fetchAndUnwrapKeys(data.keyFetchToken).then(
+          data => {
+            if (!data.kA || !data.kB) {
+              currentState.whenKeysReadyDeferred.reject(
+                new Error("user data missing kA or kB")
+              );
+              return;
             }
-          );
-        }
+            currentState.whenKeysReadyDeferred.resolve(data);
+          },
+          err => currentState.whenKeysReadyDeferred.reject(err)
+        );
       }
       return currentState.whenKeysReadyDeferred.promise;
     }).then(result => currentState.resolve(result));
    },
 
   fetchAndUnwrapKeys: function(keyFetchToken) {
     log.debug("fetchAndUnwrapKeys: token: " + keyFetchToken);
     let currentState = this.currentAccountState;
     return Task.spawn(function* task() {
       // Sign out if we don't have a key fetch token.
       if (!keyFetchToken) {
-        log.warn("improper fetchAndUnwrapKeys() call: token missing");
         yield this.signOut();
         return null;
       }
 
       let {kA, wrapKB} = yield this.fetchKeys(keyFetchToken);
 
       let data = yield currentState.getUserAccountData();
 
--- a/services/fxaccounts/tests/xpcshell/test_accounts.js
+++ b/services/fxaccounts/tests/xpcshell/test_accounts.js
@@ -300,34 +300,34 @@ add_test(function test_getKeys() {
           do_test_finished();
           run_next_test();
         });
       });
     });
   });
 });
 
-//  fetchAndUnwrapKeys with no keyFetchToken should trigger signOut
-add_test(function test_fetchAndUnwrapKeys_no_token() {
+// getKeys with no keyFetchToken should trigger signOut
+add_test(function test_getKeys_no_token() {
   do_test_pending();
 
   let fxa = new MockFxAccounts();
   let user = getTestUser("lettuce.protheroe");
   delete user.keyFetchToken
 
   makeObserver(ONLOGOUT_NOTIFICATION, function() {
-    log.debug("test_fetchAndUnwrapKeys_no_token observed logout");
+    log.debug("test_getKeys_no_token observed logout");
     fxa.internal.getUserAccountData().then(user => {
       do_test_finished();
       run_next_test();
     });
   });
 
   fxa.setSignedInUser(user).then((user) => {
-    fxa.internal.fetchAndUnwrapKeys();
+    fxa.internal.getKeys();
   });
 });
 
 // Alice (User A) signs up but never verifies her email.  Then Bob (User B)
 // signs in with a verified email.  Ensure that no sign-in events are triggered
 // on Alice's behalf.  In the end, Bob should be the signed-in user.
 add_test(function test_overlapping_signins() {
   do_test_pending();