Bug 1513541 - Ensure system addons are not accidentally started on start-up even if their about:config preferences are off; r=kmag

Ensure system addons are not accidentally started on start-up even if their about:config preferences are off.

Differential Revision: https://phabricator.services.mozilla.com/D14297

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Wisniewski 2019-01-18 04:49:19 +00:00
Родитель 060f074a81
Коммит c92f477508
3 изменённых файлов: 82 добавлений и 5 удалений

Просмотреть файл

@ -2369,11 +2369,6 @@ this.XPIDatabaseReconcile = {
// appDisabled depends on whether the add-on is a foreignInstall so update
aNewAddon.appDisabled = !XPIDatabase.isUsableAddon(aNewAddon);
if (aLocation.isSystem) {
const pref = `extensions.${aId.split("@")[0]}.enabled`;
aNewAddon.userDisabled = !Services.prefs.getBoolPref(pref, true);
}
if (isDetectedInstall && aNewAddon.foreignInstall) {
// Add the installation source info for the sideloaded extension.
aNewAddon.installTelemetryInfo = {
@ -2556,6 +2551,19 @@ this.XPIDatabaseReconcile = {
location.name == KEY_APP_SYSTEM_DEFAULTS);
},
/**
* Returns true if this install location holds system addons.
*
* @param {XPIStateLocation} location
* The install location to check.
* @returns {boolean}
* True if this location contains system add-ons.
*/
isSystemAddonLocation(location) {
return location.name === KEY_APP_SYSTEM_DEFAULTS ||
location.name === KEY_APP_SYSTEM_ADDONS;
},
/**
* Updates the databse metadata for an existing add-on during database
* reconciliation.
@ -2690,6 +2698,13 @@ this.XPIDatabaseReconcile = {
addonStates.set(addon, xpiState);
}
}
if (this.isSystemAddonLocation(location)) {
for (let [id, addon] of locationAddons.entries()) {
const pref = `extensions.${id.split("@")[0]}.enabled`;
addon.userDisabled = !Services.prefs.getBoolPref(pref, true);
}
}
}
// Validate the updated system add-ons
@ -2810,6 +2825,10 @@ this.XPIDatabaseReconcile = {
!previousAddon._sourceBundle.equals(currentAddon._sourceBundle)) {
promise = XPIInternal.BootstrapScope.get(previousAddon).update(
currentAddon);
} else if (this.isSystemAddonLocation(currentAddon.location) &&
previousAddon.version == currentAddon.version &&
previousAddon.userDisabled != currentAddon.userDisabled) {
// A system addon change, no need for install or update events.
} else {
let reason = XPIInstall.newVersionReason(previousAddon.version, currentAddon.version);
XPIInternal.BootstrapScope.get(currentAddon).install(

Просмотреть файл

@ -0,0 +1,56 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that system addon about:config prefs
// are honored during startup/restarts/upgrades.
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");
let distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true);
registerDirectory("XREAppFeat", distroDir);
AddonTestUtils.usePrivilegedSignatures = "system";
add_task(initSystemAddonDirs);
let Monitor = SlightlyLessDodgyBootstrapMonitor;
Monitor.init();
add_task(async function setup() {
let xpi = await getSystemAddonXPI(1, "1.0");
await AddonTestUtils.manuallyInstall(xpi, distroDir);
});
add_task(async function systemAddonPreffedOff() {
const id = "system1@tests.mozilla.org";
Services.prefs.setBoolPref("extensions.system1.enabled", false);
await overrideBuiltIns({"system": [id]});
await promiseStartupManager();
Monitor.checkInstalled(id);
Monitor.checkNotStarted(id);
await promiseRestartManager();
Monitor.checkNotStarted(id);
await promiseShutdownManager(false);
});
add_task(async function systemAddonPreffedOn() {
const id = "system1@tests.mozilla.org";
Services.prefs.setBoolPref("extensions.system1.enabled", true);
await promiseStartupManager("2.0");
Monitor.checkInstalled(id);
Monitor.checkStarted(id);
await promiseRestartManager();
Monitor.checkStarted(id);
await promiseShutdownManager();
});

Просмотреть файл

@ -230,6 +230,8 @@ tags = webextensions
[test_trash_directory.js]
skip-if = os != "win"
[test_types.js]
[test_systemaddomstartupprefs.js]
head = head_addons.js head_system_addons.js
[test_undouninstall.js]
skip-if = os == "win" # Bug 1358846
[test_update.js]