Bug 1369801 - dt-addon: clear extensions.lastAppVersion when creating browser toolbox profile draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 06 Jul 2017 02:48:41 +0200
changeset 606673 02499c95a51952a1aa198763422c03a554a7970e
parent 606672 ea3f8a377292923d48c1e66f26f5bd07bd910964
child 606674 86a1cb2e9b724750218e7b7e03adf2346838956f
push id67765
push userjdescottes@mozilla.com
push dateTue, 11 Jul 2017 08:07:43 +0000
bugs1369801
milestone56.0a1
Bug 1369801 - dt-addon: clear extensions.lastAppVersion when creating browser toolbox profile This is needed to: 1. force the devtools system addon installation when starting the BT instance of FF 2. avoid the addon update prompt Another approach is to create a separate user.js pref file to fix 1. However with this approach there is currently no way to fix 2. MozReview-Commit-ID: palK2hION0
devtools/client/framework/ToolboxProcess.jsm
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -182,25 +182,39 @@ BrowserToolboxProcess.prototype = {
       return;
     }
 
     this._dbgProfilePath = debuggingProfileDir.path;
 
     // We would like to copy prefs into this new profile...
     let prefsFile = debuggingProfileDir.clone();
     prefsFile.append("prefs.js");
+
     // ... but unfortunately, when we run tests, it seems the starting profile
     // clears out the prefs file before re-writing it, and in practice the
     // file is empty when we get here. So just copying doesn't work in that
     // case.
     // We could force a sync pref flush and then copy it... but if we're doing
     // that, we might as well just flush directly to the new profile, which
     // always works:
+
+    // Before dumping the preferences to prefsFile, clear the current pref for
+    // extensions.lastAppVersion. The AddonManager expects this pref to be undefined
+    // when loading a new profile, this will trigger the installation of system addons
+    // without showing the addon update popup.
+    let appVersion = Services.prefs.getCharPref("extensions.lastAppVersion", "");
+    Services.prefs.clearUserPref("extensions.lastAppVersion");
+
     Services.prefs.savePrefFile(prefsFile);
 
+    // Restore the overridden extensions.lastAppVersion preference.
+    if (appVersion) {
+      Services.prefs.setCharPref("extensions.lastAppVersion", appVersion);
+    }
+
     dumpn("Finished creating the chrome toolbox user profile at: " +
           this._dbgProfilePath);
   },
 
   /**
    * 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.