Bug 1346288 - Setting e10sMultiBlockedByAddons for bootrapped add-on users. r=felipe

This commit is contained in:
Gabor Krizsanits 2017-03-30 18:44:27 +02:00
Родитель a01e65bce7
Коммит 0384d05aa6
5 изменённых файлов: 146 добавлений и 4 удалений

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

@ -1472,9 +1472,10 @@ pref("browser.tabs.crashReporting.email", "");
pref("extensions.interposition.enabled", true); pref("extensions.interposition.enabled", true);
pref("extensions.interposition.prefetching", true); pref("extensions.interposition.prefetching", true);
// Enable blocking of e10s for add-on users on beta/release. // Enable blocking of e10s and e10s-multi for add-on users on beta/release.
#ifdef RELEASE_OR_BETA #ifdef RELEASE_OR_BETA
pref("extensions.e10sBlocksEnabling", true); pref("extensions.e10sBlocksEnabling", true);
pref("extensions.e10sMultiBlocksEnabling", true);
#endif #endif
// How often to check for CPOW timeouts. CPOWs are only timed out by // How often to check for CPOW timeouts. CPOWs are only timed out by

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

@ -719,7 +719,9 @@ ContentParent::GetMaxProcessCount(const nsAString& aContentProcessType)
// Let's respect the user's decision to enable multiple content processes // Let's respect the user's decision to enable multiple content processes
// despite some add-ons installed that might performing poorly. // despite some add-ons installed that might performing poorly.
if (!hasUserValue && Preferences::GetBool("extensions.e10sMultiBlockedByAddons", false)) { if (!hasUserValue &&
Preferences::GetBool("extensions.e10sMultiBlocksEnabling", false) &&
Preferences::GetBool("extensions.e10sMultiBlockedByAddons", false)) {
return 1; return 1;
} }

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

@ -4525,6 +4525,32 @@ this.XPIProvider = {
return true; return true;
}, },
/**
* Determine if an add-on should be blocking multiple content processes.
*
* @param aAddon
* The add-on to test
* @return true if enabling the add-on should block multiple content processes.
*/
isBlockingE10sMulti(aAddon) {
if (aAddon.type != "extension")
return false;
// The hotfix is exempt
let hotfixID = Preferences.get(PREF_EM_HOTFIX_ID, undefined);
if (hotfixID && hotfixID == aAddon.id)
return false;
// System add-ons are exempt
let locName = aAddon._installLocation ? aAddon._installLocation.name
: undefined;
if (locName == KEY_APP_SYSTEM_DEFAULTS ||
locName == KEY_APP_SYSTEM_ADDONS)
return false;
return aAddon.bootstrap;
},
/** /**
* In some cases having add-ons active blocks e10s but turning off e10s * In some cases having add-ons active blocks e10s but turning off e10s
* requires a restart so some add-ons that are normally restartless will * requires a restart so some add-ons that are normally restartless will

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

@ -57,6 +57,7 @@ const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons"; const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes"; const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes";
const PREF_E10S_BLOCKED_BY_ADDONS = "extensions.e10sBlockedByAddons"; const PREF_E10S_BLOCKED_BY_ADDONS = "extensions.e10sBlockedByAddons";
const PREF_E10S_MULTI_BLOCKED_BY_ADDONS = "extensions.e10sMultiBlockedByAddons";
const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon"; const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon";
const KEY_APP_PROFILE = "app-profile"; const KEY_APP_PROFILE = "app-profile";
@ -437,6 +438,7 @@ this.XPIDatabase = {
} }
this.updateAddonsBlockingE10s(); this.updateAddonsBlockingE10s();
this.updateAddonsBlockingE10sMulti();
let promise = this._deferredSave.saveChanges(); let promise = this._deferredSave.saveChanges();
if (!this._schemaVersionSet) { if (!this._schemaVersionSet) {
this._schemaVersionSet = true; this._schemaVersionSet = true;
@ -1372,6 +1374,20 @@ this.XPIDatabase = {
Preferences.set(PREF_E10S_BLOCKED_BY_ADDONS, blockE10s); Preferences.set(PREF_E10S_BLOCKED_BY_ADDONS, blockE10s);
}, },
updateAddonsBlockingE10sMulti() {
let blockMulti = false;
for (let [, addon] of this.addonDB) {
let active = (addon.visible && !addon.disabled && !addon.pendingUninstall);
if (active && XPIProvider.isBlockingE10sMulti(addon)) {
blockMulti = true;
break;
}
}
Preferences.set(PREF_E10S_MULTI_BLOCKED_BY_ADDONS, blockMulti);
},
/** /**
* Synchronously calculates and updates all the active flags in the database. * Synchronously calculates and updates all the active flags in the database.
*/ */

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

@ -19,7 +19,11 @@ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
startupManager(); startupManager();
function* check_normal() { function check_multi_disabled() {
return Services.prefs.getBoolPref("extensions.e10sMultiBlockedByAddons", false);
}
function* check_normal(checkMultiDisabled) {
let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1")); let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1"));
do_check_eq(install.state, AddonManager.STATE_INSTALLED); do_check_eq(install.state, AddonManager.STATE_INSTALLED);
do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL)); do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
@ -30,6 +34,10 @@ function* check_normal() {
let addon = yield promiseAddonByID(ID); let addon = yield promiseAddonByID(ID);
do_check_eq(addon, install.addon); do_check_eq(addon, install.addon);
if (checkMultiDisabled) {
do_check_false(check_multi_disabled());
}
do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE)); do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
addon.userDisabled = true; addon.userDisabled = true;
BootstrapMonitor.checkAddonNotStarted(ID); BootstrapMonitor.checkAddonNotStarted(ID);
@ -82,6 +90,7 @@ add_task(function*() {
let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1")); let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1"));
do_check_eq(install.state, AddonManager.STATE_INSTALLED); do_check_eq(install.state, AddonManager.STATE_INSTALLED);
do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL)); do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
do_check_false(check_multi_disabled());
let addon = yield promiseAddonByID(ID); let addon = yield promiseAddonByID(ID);
do_check_eq(addon, null); do_check_eq(addon, null);
@ -94,12 +103,14 @@ add_task(function*() {
addon = yield promiseAddonByID(ID); addon = yield promiseAddonByID(ID);
do_check_neq(addon, null); do_check_neq(addon, null);
do_check_true(check_multi_disabled());
do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE)); do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
addon.userDisabled = true; addon.userDisabled = true;
BootstrapMonitor.checkAddonNotStarted(ID); BootstrapMonitor.checkAddonNotStarted(ID);
do_check_false(addon.isActive); do_check_false(addon.isActive);
do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE)); do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
do_check_false(check_multi_disabled());
do_check_true(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE)); do_check_true(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
addon.userDisabled = false; addon.userDisabled = false;
@ -116,6 +127,7 @@ add_task(function*() {
BootstrapMonitor.checkAddonStarted(ID); BootstrapMonitor.checkAddonStarted(ID);
do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL)); do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
do_check_true(check_multi_disabled());
addon.uninstall(); addon.uninstall();
BootstrapMonitor.checkAddonNotStarted(ID); BootstrapMonitor.checkAddonNotStarted(ID);
BootstrapMonitor.checkAddonNotInstalled(ID); BootstrapMonitor.checkAddonNotInstalled(ID);
@ -130,6 +142,7 @@ add_task(function*() {
let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1")); let install = yield promiseInstallFile(do_get_addon("test_bootstrap1_1"));
do_check_eq(install.state, AddonManager.STATE_INSTALLED); do_check_eq(install.state, AddonManager.STATE_INSTALLED);
do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL)); do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
do_check_false(check_multi_disabled());
let addon = yield promiseAddonByID(ID); let addon = yield promiseAddonByID(ID);
do_check_eq(addon, null); do_check_eq(addon, null);
@ -139,6 +152,7 @@ add_task(function*() {
// After install and restart we should block. // After install and restart we should block.
let blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); let blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_true(blocked); do_check_true(blocked);
do_check_true(check_multi_disabled());
BootstrapMonitor.checkAddonInstalled(ID); BootstrapMonitor.checkAddonInstalled(ID);
BootstrapMonitor.checkAddonStarted(ID); BootstrapMonitor.checkAddonStarted(ID);
@ -159,6 +173,7 @@ add_task(function*() {
// After disable and restart we should not block. // After disable and restart we should not block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_false(blocked); do_check_false(blocked);
do_check_false(check_multi_disabled());
addon = yield promiseAddonByID(ID); addon = yield promiseAddonByID(ID);
addon.userDisabled = false; addon.userDisabled = false;
@ -171,6 +186,7 @@ add_task(function*() {
// After re-enable and restart we should block. // After re-enable and restart we should block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_true(blocked); do_check_true(blocked);
do_check_true(check_multi_disabled());
addon = yield promiseAddonByID(ID); addon = yield promiseAddonByID(ID);
do_check_neq(addon, null); do_check_neq(addon, null);
@ -191,6 +207,7 @@ add_task(function*() {
// After uninstall and restart we should not block. // After uninstall and restart we should not block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_false(blocked); do_check_false(blocked);
do_check_false(check_multi_disabled());
restartManager(); restartManager();
}); });
@ -246,6 +263,7 @@ add_task(function*() {
// After disable one addon and restart we should block. // After disable one addon and restart we should block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_true(blocked); do_check_true(blocked);
do_check_true(check_multi_disabled());
addon2 = yield promiseAddonByID(ID2); addon2 = yield promiseAddonByID(ID2);
@ -261,6 +279,7 @@ add_task(function*() {
// After disable both addons and restart we should not block. // After disable both addons and restart we should not block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_false(blocked); do_check_false(blocked);
do_check_false(check_multi_disabled());
addon = yield promiseAddonByID(ID); addon = yield promiseAddonByID(ID);
addon.userDisabled = false; addon.userDisabled = false;
@ -273,6 +292,7 @@ add_task(function*() {
// After re-enable one addon and restart we should block. // After re-enable one addon and restart we should block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_true(blocked); do_check_true(blocked);
do_check_true(check_multi_disabled());
addon = yield promiseAddonByID(ID); addon = yield promiseAddonByID(ID);
do_check_neq(addon, null); do_check_neq(addon, null);
@ -292,6 +312,7 @@ add_task(function*() {
// After uninstall the only enabled addon and restart we should not block. // After uninstall the only enabled addon and restart we should not block.
blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons"); blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
do_check_false(blocked); do_check_false(blocked);
do_check_false(check_multi_disabled());
addon2 = yield promiseAddonByID(ID2); addon2 = yield promiseAddonByID(ID2);
addon2.uninstall(); addon2.uninstall();
@ -426,5 +447,81 @@ add_task(function*() {
Services.prefs.setCharPref("extensions.hotfix.id", ID); Services.prefs.setCharPref("extensions.hotfix.id", ID);
Services.prefs.setBoolPref("extensions.hotfix.cert.checkAttributes", false); Services.prefs.setBoolPref("extensions.hotfix.cert.checkAttributes", false);
yield check_normal(); yield check_normal(true);
});
// Test non-restarless add-on's should not block multi
add_task(function*() {
yield promiseInstallAllFiles([do_get_addon("test_install1")], true);
let non_restartless_ID = "addon1@tests.mozilla.org";
restartManager();
let addon = yield promiseAddonByID(non_restartless_ID);
// non-restartless add-on is installed and started
do_check_neq(addon, null);
do_check_false(check_multi_disabled());
addon.uninstall();
BootstrapMonitor.checkAddonNotInstalled(non_restartless_ID);
BootstrapMonitor.checkAddonNotStarted(non_restartless_ID);
yield promiseRestartManager();
});
// Test experiment add-on should not block multi
add_task(function*() {
yield promiseInstallAllFiles([do_get_addon("test_experiment1")], true);
let experiment_ID = "experiment1@tests.mozilla.org";
BootstrapMonitor.checkAddonInstalled(experiment_ID, "1.0");
BootstrapMonitor.checkAddonNotStarted(experiment_ID);
let addon = yield promiseAddonByID(experiment_ID);
// non-restartless add-on is installed and started
do_check_neq(addon, null);
do_check_false(check_multi_disabled());
addon.uninstall();
BootstrapMonitor.checkAddonNotInstalled(experiment_ID);
BootstrapMonitor.checkAddonNotStarted(experiment_ID);
yield promiseRestartManager();
});
const { GlobalManager } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
// Test web extension add-on's should not block multi
add_task(function*() {
yield promiseInstallAllFiles([do_get_addon("webextension_1")], true),
restartManager();
yield promiseWebExtensionStartup();
let we_ID = "webextension1@tests.mozilla.org";
do_check_eq(GlobalManager.extensionMap.size, 1);
let addon = yield promiseAddonByID(we_ID);
do_check_neq(addon, null);
do_check_false(check_multi_disabled());
addon.uninstall();
BootstrapMonitor.checkAddonNotInstalled(we_ID);
BootstrapMonitor.checkAddonNotStarted(we_ID);
yield promiseRestartManager();
}); });