зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356462 Show a notification when non-MPC extensions are disabled r=mossop
MozReview-Commit-ID: 8KUhRe91AFt --HG-- extra : rebase_source : f5e66c416587387f42a1c29099770e962e8cdee8
This commit is contained in:
Родитель
4fef12511d
Коммит
e817ea40d7
|
@ -758,6 +758,27 @@ BrowserGlue.prototype = {
|
|||
nb.PRIORITY_WARNING_MEDIUM, buttons);
|
||||
},
|
||||
|
||||
_notifyDisabledNonMpc() {
|
||||
let win = RecentWindow.getMostRecentBrowserWindow();
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
let message = win.gNavigatorBundle.getString("nonMpcDisabled.message");
|
||||
let buttons = [
|
||||
{
|
||||
label: win.gNavigatorBundle.getString("nonMpcDisabled.manage.label"),
|
||||
accessKey: win.gNavigatorBundle.getString("nonMpcDisabled.manage.accessKey"),
|
||||
callback() {
|
||||
win.BrowserOpenAddonsMgr("addons://list/extension");
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
let nb = win.document.getElementById("high-priority-global-notificationbox");
|
||||
nb.appendNotification(message, "non-mpc-addons-disabled", "",
|
||||
nb.PRIORITY_WARNING_MEDIUM, buttons);
|
||||
},
|
||||
|
||||
_firstWindowTelemetry(aWindow) {
|
||||
let SCALING_PROBE_NAME = "";
|
||||
switch (AppConstants.platform) {
|
||||
|
@ -964,6 +985,10 @@ BrowserGlue.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
if (AddonManager.nonMpcDisabled) {
|
||||
this._notifyDisabledNonMpc();
|
||||
}
|
||||
|
||||
// Perform default browser checking.
|
||||
if (ShellService) {
|
||||
let shouldCheck = AppConstants.DEBUG ? false :
|
||||
|
|
|
@ -214,6 +214,10 @@ unsignedAddonsDisabled.message=One or more installed add-ons cannot be verified
|
|||
unsignedAddonsDisabled.learnMore.label=Learn More
|
||||
unsignedAddonsDisabled.learnMore.accesskey=L
|
||||
|
||||
nonMpcDisabled.message=Due to performance testing, we have disabled some of your add-ons. They can be re-enabled in the Add-ons Manager.
|
||||
nonMpcDisabled.manage.label=Manage Add-Ons
|
||||
nonMpcDisabled.manage.accessKey=M
|
||||
|
||||
# LOCALIZATION NOTE (compactLightTheme.name): This is displayed in about:addons -> Appearance
|
||||
compactLightTheme.name=Compact Light
|
||||
compactLightTheme.description=A compact theme with a light color scheme.
|
||||
|
|
|
@ -625,6 +625,7 @@ var gRepoShutdownState = "";
|
|||
var gShutdownInProgress = false;
|
||||
var gPluginPageListener = null;
|
||||
var gBrowserUpdated = null;
|
||||
var gNonMpcDisabled = false;
|
||||
|
||||
/**
|
||||
* This is the real manager, kept here rather than in AddonManager to keep its
|
||||
|
@ -3248,6 +3249,10 @@ this.AddonManagerPrivate = {
|
|||
return AddonManagerInternal._getProviderByName("XPIProvider")
|
||||
.isTemporaryInstallID(extensionId);
|
||||
},
|
||||
|
||||
set nonMpcDisabled(val) {
|
||||
gNonMpcDisabled = val;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -3746,6 +3751,10 @@ this.AddonManager = {
|
|||
return AddonManagerInternal.webAPI;
|
||||
},
|
||||
|
||||
get nonMpcDisabled() {
|
||||
return gNonMpcDisabled;
|
||||
},
|
||||
|
||||
get shutdown() {
|
||||
return gShutdownBarrier.client;
|
||||
},
|
||||
|
|
|
@ -35,6 +35,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "Blocklist",
|
|||
"@mozilla.org/extensions/blocklist;1",
|
||||
Ci.nsIBlocklistService);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "ALLOW_NON_MPC",
|
||||
"extensions.allow-non-mpc-extensions");
|
||||
|
||||
Cu.import("resource://gre/modules/Log.jsm");
|
||||
const LOGGER_ID = "addons.xpi-utils";
|
||||
|
||||
|
@ -1933,6 +1936,8 @@ this.XPIDatabaseReconcile = {
|
|||
}
|
||||
}
|
||||
|
||||
let wasDisabled = oldAddon.appDisabled;
|
||||
|
||||
// The add-on has changed if the modification time has changed, if
|
||||
// we have an updated manifest for it, or if the schema version has
|
||||
// changed.
|
||||
|
@ -1958,6 +1963,18 @@ this.XPIDatabaseReconcile = {
|
|||
newAddon = oldAddon;
|
||||
}
|
||||
|
||||
// If an extension has just become appDisabled and it appears to
|
||||
// be due to the ALLOW_NON_MPC pref, show a notification. If the
|
||||
// extension is also disabled for some other reason(s), don't
|
||||
// bother with the notification since flipping the pref will leave
|
||||
// the extension disabled.
|
||||
if (!wasDisabled && newAddon.appDisabled &&
|
||||
!ALLOW_NON_MPC && !newAddon.multiprocessCompatible &&
|
||||
(newAddon.blocklistState != Ci.nsIBlocklistService.STATE_BLOCKED) &&
|
||||
newAddon.isPlatformCompatible && newAddon.isCompatible) {
|
||||
AddonManagerPrivate.nonMpcDisabled = true;
|
||||
}
|
||||
|
||||
if (newAddon)
|
||||
locationAddonMap.set(newAddon.id, newAddon);
|
||||
} else {
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
Components.utils.import("resource://testing-common/httpd.js");
|
||||
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
var gServer;
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
const NON_MPC_PREF = "extensions.allow-non-mpc-extensions";
|
||||
|
||||
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
|
||||
|
||||
function build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompatible) {
|
||||
|
@ -103,7 +107,6 @@ for (let bootstrap of [false, true]) {
|
|||
}
|
||||
|
||||
add_task(async function test_disable() {
|
||||
const PREF = "extensions.allow-non-mpc-extensions";
|
||||
const ID_MPC = "mpc@tests.mozilla.org";
|
||||
const ID_NON_MPC = "non-mpc@tests.mozilla.org";
|
||||
|
||||
|
@ -129,7 +132,7 @@ add_task(async function test_disable() {
|
|||
|
||||
async function testOnce(initialAllow) {
|
||||
if (initialAllow !== undefined) {
|
||||
Services.prefs.setBoolPref(PREF, initialAllow);
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, initialAllow);
|
||||
}
|
||||
|
||||
let install1 = await AddonManager.getInstallForFile(xpi1);
|
||||
|
@ -147,7 +150,7 @@ add_task(async function test_disable() {
|
|||
|
||||
// Flip the allow-non-mpc preference
|
||||
let newValue = (initialAllow === true) ? false : true;
|
||||
Services.prefs.setBoolPref(PREF, newValue);
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, newValue);
|
||||
|
||||
// the mpc extension should never become appDisabled
|
||||
do_check_eq(addon1.appDisabled, false);
|
||||
|
@ -156,7 +159,7 @@ add_task(async function test_disable() {
|
|||
do_check_eq(addon2.appDisabled, !newValue);
|
||||
|
||||
// Flip the pref back and check appDisabled
|
||||
Services.prefs.setBoolPref(PREF, !newValue);
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, !newValue);
|
||||
|
||||
do_check_eq(addon1.appDisabled, false);
|
||||
do_check_eq(addon2.appDisabled, newValue);
|
||||
|
@ -169,7 +172,144 @@ add_task(async function test_disable() {
|
|||
await testOnce(true);
|
||||
await testOnce(false);
|
||||
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
Services.prefs.clearUserPref(NON_MPC_PREF);
|
||||
});
|
||||
|
||||
// Test that the nonMpcDisabled flag gets set properly at startup
|
||||
// when the allow-non-mpc-extensions pref is flipped.
|
||||
add_task(async function test_restart() {
|
||||
const ID = "non-mpc@tests.mozilla.org";
|
||||
|
||||
let xpifile = createTempXPIFile({
|
||||
id: ID,
|
||||
name: "Test Add-on",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
multiprocessCompatible: false,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
});
|
||||
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, true);
|
||||
let install = await AddonManager.getInstallForFile(xpifile);
|
||||
await promiseCompleteAllInstalls([install]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
do_check_neq(addon, null);
|
||||
do_check_eq(addon.multiprocessCompatible, false);
|
||||
do_check_eq(addon.appDisabled, false);
|
||||
|
||||
// Simulate a new app version in which the allow-non-mpc-extensions
|
||||
// pref is flipped.
|
||||
await promiseShutdownManager();
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, false);
|
||||
gAppInfo.version = "1.5";
|
||||
await promiseStartupManager();
|
||||
|
||||
addon = await AddonManager.getAddonByID(ID);
|
||||
do_check_neq(addon, null);
|
||||
do_check_eq(addon.appDisabled, true);
|
||||
|
||||
// The flag we use for startup notification should be true
|
||||
do_check_eq(AddonManager.nonMpcDisabled, true);
|
||||
|
||||
addon.uninstall();
|
||||
|
||||
Services.prefs.clearUserPref(NON_MPC_PREF);
|
||||
AddonManagerPrivate.nonMpcDisabled = false;
|
||||
});
|
||||
|
||||
// Test that the nonMpcDisabled flag is not set if there are non-mpc
|
||||
// extensions that are also disabled for some other reason.
|
||||
add_task(async function test_restart2() {
|
||||
const ID1 = "blocked@tests.mozilla.org";
|
||||
let xpi1 = createTempXPIFile({
|
||||
id: ID1,
|
||||
name: "Blocked Add-on",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
multiprocessCompatible: false,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
});
|
||||
|
||||
const ID2 = "incompatible@tests.mozilla.org";
|
||||
let xpi2 = createTempXPIFile({
|
||||
id: ID2,
|
||||
name: "Incompatible Add-on",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
multiprocessCompatible: false,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1.5"
|
||||
}]
|
||||
});
|
||||
|
||||
const BLOCKLIST = `<?xml version="1.0"?>
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1396046918000">
|
||||
<emItems>
|
||||
<emItem blockID="i454" id="${ID1}">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3"/>
|
||||
</emItem>
|
||||
</emItems>
|
||||
</blocklist>`;
|
||||
|
||||
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, true);
|
||||
let install1 = await AddonManager.getInstallForFile(xpi1);
|
||||
let install2 = await AddonManager.getInstallForFile(xpi2);
|
||||
await promiseCompleteAllInstalls([install1, install2]);
|
||||
|
||||
let [addon1, addon2] = await AddonManager.getAddonsByIDs([ID1, ID2]);
|
||||
do_check_neq(addon1, null);
|
||||
do_check_eq(addon1.multiprocessCompatible, false);
|
||||
do_check_eq(addon1.appDisabled, false);
|
||||
do_check_neq(addon2, null);
|
||||
do_check_eq(addon2.multiprocessCompatible, false);
|
||||
do_check_eq(addon2.appDisabled, false);
|
||||
|
||||
await promiseShutdownManager();
|
||||
|
||||
Services.prefs.setBoolPref(NON_MPC_PREF, false);
|
||||
gAppInfo.version = "2";
|
||||
|
||||
// Simulate including a new blocklist with the new version by
|
||||
// flipping the pref below which causes the blocklist to be re-read.
|
||||
let blocklistPath = OS.Path.join(OS.Constants.Path.profileDir, "blocklist.xml");
|
||||
await OS.File.writeAtomic(blocklistPath, BLOCKLIST);
|
||||
let BLOCKLIST_PREF = "extensions.blocklist.enabled";
|
||||
Services.prefs.setBoolPref(BLOCKLIST_PREF, false);
|
||||
Services.prefs.setBoolPref(BLOCKLIST_PREF, true);
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
// When we restart, one of the test addons should be blocklisted, and
|
||||
// one is incompatible. Both are MPC=false but that should not trigger
|
||||
// the startup notification since flipping allow-non-mpc-extensions
|
||||
// won't re-enable either extension.
|
||||
const {STATE_BLOCKED} = Components.interfaces.nsIBlocklistService;
|
||||
[addon1, addon2] = await AddonManager.getAddonsByIDs([ID1, ID2]);
|
||||
do_check_neq(addon1, null);
|
||||
do_check_eq(addon1.appDisabled, true);
|
||||
do_check_eq(addon1.blocklistState, STATE_BLOCKED);
|
||||
do_check_neq(addon2, null);
|
||||
do_check_eq(addon2.appDisabled, true);
|
||||
do_check_eq(addon2.isCompatible, false);
|
||||
|
||||
do_check_eq(AddonManager.nonMpcDisabled, false);
|
||||
|
||||
addon1.uninstall();
|
||||
addon2.uninstall();
|
||||
|
||||
Services.prefs.clearUserPref(NON_MPC_PREF);
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче