Bug 1082130 - Test if window closed before signing in the user in fxAccounts. r=markh
authorAlex Bardas <alex.bardas@gmail.com>
Mon, 13 Oct 2014 22:53:37 -0700
changeset 210227 54b2b11d1895353b49061cd27cddc86e37304a79
parent 210226 474d1663c2e0beecf74d6b58ee010d577172f752
child 210228 a0a389aaffc1aaea3d1ca2183e91828efd113184
child 210303 7d7d64553c684fb913c0d53d7e49813da15d0c0b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmarkh
bugs1082130
milestone36.0a1
Bug 1082130 - Test if window closed before signing in the user in fxAccounts. r=markh
browser/base/content/aboutaccounts/aboutaccounts.js
--- a/browser/base/content/aboutaccounts/aboutaccounts.js
+++ b/browser/base/content/aboutaccounts/aboutaccounts.js
@@ -285,32 +285,32 @@ function getStarted() {
 }
 
 function openPrefs() {
   window.openPreferences("paneSync");
 }
 
 function init() {
   fxAccounts.getSignedInUser().then(user => {
+    // tests in particular might cause the window to start closing before
+    // getSignedInUser has returned.
+    if (window.closed) {
+      return;
+    }
     // If the url contains an entrypoint query parameter, extract it into a variable
     // to append it to the accounts URI resource.
     // Works for the following cases:
     // - about:accounts?entrypoint="abouthome"
     // - about:accounts?entrypoint=abouthome&action=signup
     let entryPointQParam = "entrypoint=";
     let entryPointPos = window.location.href.indexOf(entryPointQParam);
     let entryPoint = "";
     if (entryPointPos >= 0) {
       entryPoint = window.location.href.substring(entryPointPos).split("&")[0];
     }
-    // tests in particular might cause the window to start closing before
-    // getSignedInUser has returned.
-    if (window.closed) {
-      return;
-    }
     if (window.location.href.contains("action=signin")) {
       if (user) {
         // asking to sign-in when already signed in just shows manage.
         show("stage", "manage");
       } else {
         show("remote");
         wrapper.init(fxAccounts.getAccountsSignInURI(), entryPoint);
       }