Bug 1095231 - have migration of sync credentials do the right thing if no default profile exists. r=past
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 07 Nov 2014 12:20:28 +1100
changeset 235058 21d59fe5db6600d2155901044249dfd721d24f9b
parent 235057 e7ee9481e0a7a53cf55efeb19e84bdeb125b74fd
child 235059 a2a2e615349ba156698e7e5e11c344a2ca7017c5
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1095231
milestone35.0a2
Bug 1095231 - have migration of sync credentials do the right thing if no default profile exists. r=past
browser/base/content/aboutaccounts/aboutaccounts.js
--- a/browser/base/content/aboutaccounts/aboutaccounts.js
+++ b/browser/base/content/aboutaccounts/aboutaccounts.js
@@ -372,23 +372,29 @@ function show(id, childId) {
         elt.style.display = 'none';
       }
     }
   }
 }
 
 // Migrate sync data from the default profile to the dev-edition profile.
 function migrateToDevEdition(user, entryPoint) {
-  let migrateSyncCreds = false;
+  let defaultProfilePath;
   try {
-    migrateSyncCreds = Services.prefs.getBoolPref("identity.fxaccounts.migrateToDevEdition");
-  } catch (e) {}
+    defaultProfilePath = window.getDefaultProfilePath();
+  } catch (e) {} // no default profile.
+  let migrateSyncCreds = false;
+  if (defaultProfilePath) {
+    try {
+      migrateSyncCreds = Services.prefs.getBoolPref("identity.fxaccounts.migrateToDevEdition");
+    } catch (e) {}
+  }
   if (migrateSyncCreds) {
     Cu.import("resource://gre/modules/osfile.jsm");
-    let fxAccountsStorage = OS.Path.join(window.getDefaultProfilePath(), fxAccountsCommon.DEFAULT_STORAGE_FILENAME);
+    let fxAccountsStorage = OS.Path.join(defaultProfilePath, fxAccountsCommon.DEFAULT_STORAGE_FILENAME);
     return OS.File.read(fxAccountsStorage, { encoding: "utf-8" }).then(text => {
       let accountData = JSON.parse(text).accountData;
       return fxAccounts.setSignedInUser(accountData);
     }).then(() => {
       return fxAccounts.promiseAccountsForceSigninURI().then(url => {
         show("remote");
         wrapper.init(url, entryPoint);
       });