Bug 1386830 - Test profile dirs in Browser Toolbox. r=jdescottes draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 02 Aug 2017 16:34:40 -0500
changeset 619940 f7289411aaa10a8ac459e33e87bf2b685b70e0fc
parent 619939 9a03ff03904ad47229e8eacb81e1ebbb23873b3e
child 640548 f2560dd11b6fe58a68a116ee5124d51e044b50d6
push id71875
push userbmo:jryans@gmail.com
push dateWed, 02 Aug 2017 21:36:50 +0000
reviewersjdescottes
bugs1386830
milestone57.0a1
Bug 1386830 - Test profile dirs in Browser Toolbox. r=jdescottes Before trying to migrate Browser Toolbox profile dirs, ensure the old and new dirs are actually different. This avoids an issue where we were constantly "migrating" the profile to the same place, effectively deleting it on every run. MozReview-Commit-ID: FUAb2G21nbV
devtools/client/framework/ToolboxProcess.jsm
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -208,24 +208,29 @@ BrowserToolboxProcess.prototype = {
 
   /**
    * Originally, the profile was placed in `ProfLD` instead of `ProfD`.  On some systems,
    * such as macOS, `ProfLD` is in the user's Caches directory, which is not an
    * appropriate place to store supposedly persistent profile data.
    */
   _migrateProfileDir() {
     let oldDebuggingProfileDir = Services.dirsvc.get("ProfLD", Ci.nsIFile);
+    let newDebuggingProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
+    if (oldDebuggingProfileDir.path == newDebuggingProfileDir.path) {
+      // It's possible for these locations to be the same, such as running from
+      // a custom profile directory specified via CLI.
+      return;
+    }
     oldDebuggingProfileDir.append(CHROME_DEBUGGER_PROFILE_NAME);
     if (!oldDebuggingProfileDir.exists()) {
       return;
     }
     dumpn(`Old debugging profile exists: ${oldDebuggingProfileDir.path}`);
     try {
       // Remove the directory from the target location, if it exists
-      let newDebuggingProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
       newDebuggingProfileDir.append(CHROME_DEBUGGER_PROFILE_NAME);
       if (newDebuggingProfileDir.exists()) {
         dumpn(`Removing folder at destination: ${newDebuggingProfileDir.path}`);
         newDebuggingProfileDir.remove(true);
       }
       // Move profile from old to new location
       let newDebuggingProfileParent = Services.dirsvc.get("ProfD", Ci.nsIFile);
       oldDebuggingProfileDir.moveTo(newDebuggingProfileParent, null);