зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720845 - Remove the `extensions.webextPermissionPrompts` pref. r=rpl,robwu,asuth
This patch removes the `extensions.webextPermissionPrompts` pref as well as `permissionPromptsEnabled` prop on `mozAddonManager`. While working on this patch, we noticed that some of the `browser_webapi.js` weren't testing anything for a while now. That has been fixed. In addition, the `test_blocklistchange.js` file has been updated to handle the permissions prompt. Differential Revision: https://phabricator.services.mozilla.com/D121114
This commit is contained in:
Родитель
98db09fff6
Коммит
b1c4ce35a8
|
@ -31,7 +31,6 @@ pref("extensions.strictCompatibility", false);
|
|||
// extensions.checkCompatibility=false has been set.
|
||||
pref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "29.0a1");
|
||||
|
||||
pref("extensions.webextPermissionPrompts", true);
|
||||
pref("extensions.webextOptionalPermissionPrompts", true);
|
||||
// If enabled, install origin permission verification happens after addons are downloaded.
|
||||
pref("extensions.postDownloadThirdPartyPrompt", true);
|
||||
|
|
|
@ -22,13 +22,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"WEBEXT_PERMISSION_PROMPTS",
|
||||
"extensions.webextPermissionPrompts",
|
||||
false
|
||||
);
|
||||
|
||||
const DEFAULT_EXTENSION_ICON =
|
||||
"chrome://mozapps/skin/extensions/extensionGeneric.svg";
|
||||
|
||||
|
@ -84,31 +77,29 @@ var ExtensionsUI = {
|
|||
// happening in a specific order.
|
||||
sideloaded.sort((a, b) => a.id.localeCompare(b.id));
|
||||
|
||||
if (WEBEXT_PERMISSION_PROMPTS) {
|
||||
if (!this.sideloadListener) {
|
||||
this.sideloadListener = {
|
||||
onEnabled: addon => {
|
||||
if (!this.sideloaded.has(addon)) {
|
||||
return;
|
||||
}
|
||||
if (!this.sideloadListener) {
|
||||
this.sideloadListener = {
|
||||
onEnabled: addon => {
|
||||
if (!this.sideloaded.has(addon)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.sideloaded.delete(addon);
|
||||
this._updateNotifications();
|
||||
this.sideloaded.delete(addon);
|
||||
this._updateNotifications();
|
||||
|
||||
if (this.sideloaded.size == 0) {
|
||||
AddonManager.removeAddonListener(this.sideloadListener);
|
||||
this.sideloadListener = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
AddonManager.addAddonListener(this.sideloadListener);
|
||||
}
|
||||
|
||||
for (let addon of sideloaded) {
|
||||
this.sideloaded.add(addon);
|
||||
}
|
||||
this._updateNotifications();
|
||||
if (this.sideloaded.size == 0) {
|
||||
AddonManager.removeAddonListener(this.sideloadListener);
|
||||
this.sideloadListener = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
AddonManager.addAddonListener(this.sideloadListener);
|
||||
}
|
||||
|
||||
for (let addon of sideloaded) {
|
||||
this.sideloaded.add(addon);
|
||||
}
|
||||
this._updateNotifications();
|
||||
},
|
||||
|
||||
_updateNotifications() {
|
||||
|
|
|
@ -95,9 +95,6 @@ interface AddonManager : EventTarget {
|
|||
*/
|
||||
Promise<boolean> reportAbuse(DOMString id);
|
||||
|
||||
// Indicator to content whether permissions prompts are enabled
|
||||
readonly attribute boolean permissionPromptsEnabled;
|
||||
|
||||
// Indicator to content whether handing off the reports to the integrated
|
||||
// abuse report panel is enabled.
|
||||
readonly attribute boolean abuseReportPanelEnabled;
|
||||
|
|
|
@ -197,7 +197,6 @@ pref("extensions.compatability.locales.buildid", "0");
|
|||
/* Don't let XPIProvider install distribution add-ons; we do our own thing on mobile. */
|
||||
pref("extensions.installDistroAddons", false);
|
||||
|
||||
pref("extensions.webextPermissionPrompts", true);
|
||||
pref("extensions.webextOptionalPermissionPrompts", true);
|
||||
|
||||
pref("extensions.webextensions.background-delayed-startup", true);
|
||||
|
|
|
@ -712,11 +712,6 @@ async function test_permissions_prompt(manifest_version) {
|
|||
|
||||
let install = await AddonManager.getInstallForFile(xpi);
|
||||
|
||||
Services.prefs.setBoolPref("extensions.webextPermissionPrompts", true);
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("extensions.webextPermissionPrompts");
|
||||
});
|
||||
|
||||
let perminfo;
|
||||
install.promptHandler = info => {
|
||||
perminfo = info;
|
||||
|
|
|
@ -41,7 +41,6 @@ const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
|
|||
const PREF_MIN_WEBEXT_PLATFORM_VERSION =
|
||||
"extensions.webExtensionsMinPlatformVersion";
|
||||
const PREF_WEBAPI_TESTING = "extensions.webapi.testing";
|
||||
const PREF_WEBEXT_PERM_PROMPTS = "extensions.webextPermissionPrompts";
|
||||
const PREF_EM_POSTDOWNLOAD_THIRD_PARTY =
|
||||
"extensions.postDownloadThirdPartyPrompt";
|
||||
|
||||
|
@ -89,13 +88,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
Extension: "resource://gre/modules/Extension.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"WEBEXT_PERMISSION_PROMPTS",
|
||||
PREF_WEBEXT_PERM_PROMPTS,
|
||||
false
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"WEBEXT_POSTDOWNLOAD_THIRD_PARTY",
|
||||
|
@ -1349,10 +1341,8 @@ var AddonManagerInternal = {
|
|||
// XXX we really should resolve when this install is done,
|
||||
// not when update-available check completes, no?
|
||||
logger.debug(`Starting upgrade install of ${aAddon.id}`);
|
||||
if (WEBEXT_PERMISSION_PROMPTS) {
|
||||
aInstall.promptHandler = (...args) =>
|
||||
AddonManagerInternal._updatePromptHandler(...args);
|
||||
}
|
||||
aInstall.promptHandler = (...args) =>
|
||||
AddonManagerInternal._updatePromptHandler(...args);
|
||||
aInstall.install();
|
||||
}
|
||||
},
|
||||
|
@ -2151,7 +2141,7 @@ var AddonManagerInternal = {
|
|||
let needsRestart =
|
||||
install.addon.pendingOperations != AddonManager.PENDING_NONE;
|
||||
|
||||
if (WEBEXT_PERMISSION_PROMPTS && !needsRestart) {
|
||||
if (!needsRestart) {
|
||||
let subject = {
|
||||
wrappedJSObject: { target: browser, addon: install.addon },
|
||||
};
|
||||
|
@ -3150,7 +3140,7 @@ var AddonManagerInternal = {
|
|||
// the customConfirmationUI preference and responding to the
|
||||
// "addon-install-confirmation" notification. If the application
|
||||
// does not implement its own prompt, use the built-in xul dialog.
|
||||
if (info.addon.userPermissions && WEBEXT_PERMISSION_PROMPTS) {
|
||||
if (info.addon.userPermissions) {
|
||||
let subject = {
|
||||
wrappedJSObject: {
|
||||
target: browser,
|
||||
|
@ -3420,14 +3410,12 @@ var AddonManagerInternal = {
|
|||
await addon.enable();
|
||||
}
|
||||
|
||||
if (Services.prefs.getBoolPref(PREF_WEBEXT_PERM_PROMPTS, false)) {
|
||||
await new Promise(resolve => {
|
||||
let subject = {
|
||||
wrappedJSObject: { target, addon, callback: resolve },
|
||||
};
|
||||
Services.obs.notifyObservers(subject, "webextension-install-notify");
|
||||
});
|
||||
}
|
||||
await new Promise(resolve => {
|
||||
let subject = {
|
||||
wrappedJSObject: { target, addon, callback: resolve },
|
||||
};
|
||||
Services.obs.notifyObservers(subject, "webextension-install-notify");
|
||||
});
|
||||
},
|
||||
|
||||
addonInstallCancel(target, id) {
|
||||
|
|
|
@ -13,13 +13,6 @@ ChromeUtils.defineModuleGetter(
|
|||
"resource://gre/modules/Services.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"WEBEXT_PERMISSION_PROMPTS",
|
||||
"extensions.webextPermissionPrompts",
|
||||
false
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"AMO_ABUSEREPORT",
|
||||
|
@ -273,10 +266,6 @@ class WebAPI extends APIObject {
|
|||
return this._apiTask("addonReportAbuse", [id]);
|
||||
}
|
||||
|
||||
get permissionPromptsEnabled() {
|
||||
return WEBEXT_PERMISSION_PROMPTS;
|
||||
}
|
||||
|
||||
get abuseReportPanelEnabled() {
|
||||
return AMO_ABUSEREPORT;
|
||||
}
|
||||
|
|
|
@ -22,13 +22,6 @@ var { XPCOMUtils } = ChromeUtils.import(
|
|||
|
||||
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"WEBEXT_PERMISSION_PROMPTS",
|
||||
"extensions.webextPermissionPrompts",
|
||||
false
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Extension",
|
||||
|
@ -110,10 +103,6 @@ function installPromptHandler(info) {
|
|||
}
|
||||
|
||||
function attachUpdateHandler(install) {
|
||||
if (!WEBEXT_PERMISSION_PROMPTS) {
|
||||
return;
|
||||
}
|
||||
|
||||
install.promptHandler = installPromptHandler;
|
||||
}
|
||||
|
||||
|
@ -160,7 +149,7 @@ function openOptionsInTab(optionsURL) {
|
|||
}
|
||||
|
||||
function shouldShowPermissionsPrompt(addon) {
|
||||
if (!WEBEXT_PERMISSION_PROMPTS || !addon.isWebExtension || addon.seen) {
|
||||
if (!addon.isWebExtension || addon.seen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,15 +62,23 @@ addons[3].permissions &= ~AddonManager.PERM_CAN_UNINSTALL;
|
|||
function API_getAddonByID(browser, id) {
|
||||
return SpecialPowers.spawn(browser, [id], async function(id) {
|
||||
let addon = await content.navigator.mozAddonManager.getAddonByID(id);
|
||||
|
||||
let addonDetails = {};
|
||||
for (let prop in addon) {
|
||||
addonDetails[prop] = addon[prop];
|
||||
}
|
||||
// We can't send native objects back so clone its properties.
|
||||
return JSON.parse(JSON.stringify(addon));
|
||||
return JSON.parse(JSON.stringify(addonDetails));
|
||||
});
|
||||
}
|
||||
|
||||
add_task(
|
||||
testWithAPI(async function(browser) {
|
||||
function compareObjects(web, real) {
|
||||
ok(
|
||||
!!Object.keys(web).length,
|
||||
"Got a valid mozAddonManager addon object dump"
|
||||
);
|
||||
|
||||
for (let prop of Object.keys(web)) {
|
||||
let webVal = web[prop];
|
||||
let realVal = real[prop];
|
||||
|
@ -115,29 +123,3 @@ add_task(
|
|||
compareObjects(w3, a3);
|
||||
})
|
||||
);
|
||||
|
||||
add_task(
|
||||
testWithAPI(async function(browser) {
|
||||
async function check(value, message) {
|
||||
let enabled = await SpecialPowers.spawn(browser, [], async function() {
|
||||
return content.navigator.mozAddonManager.permissionPromptsEnabled;
|
||||
});
|
||||
is(enabled, value, message);
|
||||
}
|
||||
|
||||
const PERM = "extensions.webextPermissionPrompts";
|
||||
if (!Services.prefs.getBoolPref(PERM, false)) {
|
||||
await SpecialPowers.pushPrefEnv({ clear: [[PERM]] });
|
||||
await check(
|
||||
false,
|
||||
`mozAddonManager.permissionPromptsEnabled is false when ${PERM} is unset`
|
||||
);
|
||||
}
|
||||
|
||||
await SpecialPowers.pushPrefEnv({ set: [[PERM, true]] });
|
||||
await check(
|
||||
true,
|
||||
`mozAddonManager.permissionPromptsEnabled is true when ${PERM} is set`
|
||||
);
|
||||
})
|
||||
);
|
||||
|
|
|
@ -1445,12 +1445,6 @@ function waitForCondition(condition, nextTest, errorMsg) {
|
|||
// Wait for and then acknowledge (by pressing the primary button) the
|
||||
// given notification.
|
||||
function promiseNotification(id = "addon-webext-permissions") {
|
||||
if (
|
||||
!Services.prefs.getBoolPref("extensions.webextPermissionPrompts", false)
|
||||
) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
function popupshown() {
|
||||
let notification = PopupNotifications.getNotification(id);
|
||||
|
|
|
@ -29,8 +29,6 @@ const URI_EXTENSION_BLOCKLIST_DIALOG =
|
|||
// Allow insecure updates
|
||||
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
|
||||
|
||||
Services.prefs.setBoolPref("extensions.webextPermissionPrompts", false);
|
||||
|
||||
if (AppConstants.platform == "android") {
|
||||
// test_blocklistchange_v2.js tests blocklist v2, so we should flip the pref
|
||||
// to enable the v3 blocklist on Android.
|
||||
|
@ -61,6 +59,26 @@ var testserver = createHttpServer({ hosts: ["example.com"] });
|
|||
// Needed for updates:
|
||||
testserver.registerDirectory("/data/", do_get_file("../data"));
|
||||
|
||||
function permissionPromptHandler(subject, topic, data) {
|
||||
ok(
|
||||
subject?.wrappedJSObject?.info?.resolve,
|
||||
"Got a permission prompt notification as expected"
|
||||
);
|
||||
subject.wrappedJSObject.info.resolve();
|
||||
}
|
||||
|
||||
Services.obs.addObserver(
|
||||
permissionPromptHandler,
|
||||
"webextension-permission-prompt"
|
||||
);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.obs.removeObserver(
|
||||
permissionPromptHandler,
|
||||
"webextension-permission-prompt"
|
||||
);
|
||||
});
|
||||
|
||||
const XPIS = {};
|
||||
|
||||
const ADDON_IDS = [
|
||||
|
|
Загрузка…
Ссылка в новой задаче