Bug 1369801 - dt-addon: set extensions.startupScanScopes in BrowserToolbox profile;r=ochameau
Create a user.js file for the chrome_debugger_profile to set startupScanScopes to AddonManager.SCOPE_ALL
This will force Firefox to scan the system addon and install it when starting the profile.
MozReview-Commit-ID: palK2hION0
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -8,18 +8,20 @@
const { interfaces: Ci, utils: Cu, results: Cr } = Components;
const DBG_XUL = "chrome://devtools/content/framework/toolbox-process-window.xul";
const CHROME_DEBUGGER_PROFILE_NAME = "chrome_debugger_profile";
const { require, DevToolsLoader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
+const { FileUtils } = require("resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Subprocess", "resource://gre/modules/Subprocess.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyGetter(this, "Telemetry", function () {
return require("devtools/client/shared/telemetry");
});
XPCOMUtils.defineLazyGetter(this, "EventEmitter", function () {
return require("devtools/shared/old-event-emitter");
});
XPCOMUtils.defineLazyGetter(this, "system", function () {
return require("devtools/shared/system");
@@ -188,16 +190,30 @@ 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");
+
+ // We set extensions.startupScanScopes to SCOPE_ALL to force the BrowserToolbox
+ // profile to scan the system addon on startup, and write it to user.js
+ let userFile = debuggingProfileDir.clone();
+ userFile.append("user.js");
+ if (!userFile.exists()) {
+ userFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
+ let out = FileUtils.openFileOutputStream(userFile,
+ FileUtils.MODE_WRONLY | FileUtils.MODE_APPEND);
+ let str = `user_pref("extensions.startupScanScopes", ${AddonManager.SCOPE_ALL});\n`;
+ out.write(str, str.length);
+ out.close();
+ }
+
// ... 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:
Services.prefs.savePrefFile(prefsFile);