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
--- 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);