зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
060f074a81
Коммит
c92f477508
|
@ -2369,11 +2369,6 @@ this.XPIDatabaseReconcile = {
|
||||||
// appDisabled depends on whether the add-on is a foreignInstall so update
|
// appDisabled depends on whether the add-on is a foreignInstall so update
|
||||||
aNewAddon.appDisabled = !XPIDatabase.isUsableAddon(aNewAddon);
|
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) {
|
if (isDetectedInstall && aNewAddon.foreignInstall) {
|
||||||
// Add the installation source info for the sideloaded extension.
|
// Add the installation source info for the sideloaded extension.
|
||||||
aNewAddon.installTelemetryInfo = {
|
aNewAddon.installTelemetryInfo = {
|
||||||
|
@ -2556,6 +2551,19 @@ this.XPIDatabaseReconcile = {
|
||||||
location.name == KEY_APP_SYSTEM_DEFAULTS);
|
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
|
* Updates the databse metadata for an existing add-on during database
|
||||||
* reconciliation.
|
* reconciliation.
|
||||||
|
@ -2690,6 +2698,13 @@ this.XPIDatabaseReconcile = {
|
||||||
addonStates.set(addon, xpiState);
|
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
|
// Validate the updated system add-ons
|
||||||
|
@ -2810,6 +2825,10 @@ this.XPIDatabaseReconcile = {
|
||||||
!previousAddon._sourceBundle.equals(currentAddon._sourceBundle)) {
|
!previousAddon._sourceBundle.equals(currentAddon._sourceBundle)) {
|
||||||
promise = XPIInternal.BootstrapScope.get(previousAddon).update(
|
promise = XPIInternal.BootstrapScope.get(previousAddon).update(
|
||||||
currentAddon);
|
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 {
|
} else {
|
||||||
let reason = XPIInstall.newVersionReason(previousAddon.version, currentAddon.version);
|
let reason = XPIInstall.newVersionReason(previousAddon.version, currentAddon.version);
|
||||||
XPIInternal.BootstrapScope.get(currentAddon).install(
|
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]
|
[test_trash_directory.js]
|
||||||
skip-if = os != "win"
|
skip-if = os != "win"
|
||||||
[test_types.js]
|
[test_types.js]
|
||||||
|
[test_systemaddomstartupprefs.js]
|
||||||
|
head = head_addons.js head_system_addons.js
|
||||||
[test_undouninstall.js]
|
[test_undouninstall.js]
|
||||||
skip-if = os == "win" # Bug 1358846
|
skip-if = os == "win" # Bug 1358846
|
||||||
[test_update.js]
|
[test_update.js]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче