Bug 1436851 - Prevent AddonTestUtils.jsm from overriding a pref value
AddonTestUtils.overrideBuiltIns sets |security.turn_off_all_security_so_that_viruses_can_take_over_this_computer| to true when it starts. It then naively sets it to false, assuming that that was the original value. This patch simply corrects that behavior to return the value to the previously set value, whatever that may have been.
MozReview-Commit-ID: KbhmoixBvpW
--- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
@@ -1281,28 +1281,29 @@ var AddonTestUtils = {
* Override chrome URL for specifying allowed built-in add-ons.
*
* @param {object} data - An object specifying which add-on IDs are permitted
* to load, for instance: { "system": ["id1", "..."] }
*/
async overrideBuiltIns(data) {
// We need to set this in order load the URL preloader service, which
// is only possible when running in automation.
+ let prevPrefVal = Services.prefs.getBoolPref(PREF_DISABLE_SECURITY, false);
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
aomStartup.initializeURLPreloader();
let file = FileUtils.getFile("TmpD", "override.txt");
let manifest = Services.io.newFileURI(file);
await OS.File.writeAtomic(file.path,
new TextEncoder().encode(JSON.stringify(data)));
this.overrideEntry = aomStartup.registerChrome(manifest, [
["override", "chrome://browser/content/built_in_addons.json",
Services.io.newFileURI(file).spec],
]);
- Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, false);
+ Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, prevPrefVal);
}
};
for (let [key, val] of Object.entries(AddonTestUtils)) {
if (typeof val == "function")
AddonTestUtils[key] = val.bind(AddonTestUtils);
}