Skip to content

Commit

Permalink
Change and remove things in extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed Oct 6, 2023
1 parent 25620e4 commit 5ce6c62
Show file tree
Hide file tree
Showing 189 changed files with 296 additions and 15,055 deletions.
12 changes: 1 addition & 11 deletions browser/app/profile/mypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ pref("extensions.webextensions.default-content-security-policy", "script-src 'se
pref("extensions.webextensions.remote", true);
pref("extensions.webextensions.background-delayed-startup", true);

// Extensions that should not be flagged as legacy in about:addons
pref("extensions.legacy.exceptions", "[email protected],@testpilot-containers,jid1-NeEaf3sAHdKHPA@jetpack,@activity-streams,[email protected],@testpilot-addon,@min-vid,[email protected],[email protected],[email protected],[email protected]");

// Require signed add-ons by default
pref("extensions.langpacks.signatures.required", false);
pref("xpinstall.signatures.required", false);
pref("xpinstall.signatures.devInfoURL", "data:text/plain,");

// Dictionary download preference
pref("browser.dictionaries.download.url", "data:text/plain,");

Expand Down Expand Up @@ -717,7 +709,7 @@ pref("browser.preferences.search", true);
pref("browser.preferences.defaultPerformanceSettings.enabled", true);

pref("browser.download.show_plugins_in_list", true);
pref("browser.download.hide_plugins_without_extensions", true);
pref("browser.download.hide_plugins_without_extensions", false);

// Backspace and Shift+Backspace behavior
// 0 goes Back/Forward
Expand Down Expand Up @@ -1582,8 +1574,6 @@ pref("browser.tabs.crashReporting.requestEmail", false);
pref("browser.tabs.crashReporting.emailMe", false);
pref("browser.tabs.crashReporting.email", "");

pref("extensions.legacy.enabled", false);

// How often to check for CPOW timeouts. CPOWs are only timed out by
// the hang monitor.
pref("dom.ipc.cpow.timeout", 500);
Expand Down
7 changes: 0 additions & 7 deletions browser/base/content/browser-pageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,6 @@ var BrowserPageActions = {
let action = this._contextAction;
this._contextAction = null;

PageActions.logTelemetry("managed", action);
AMTelemetry.recordActionEvent({
object: "pageAction",
action: "manage",
extra: { addonId: action.extensionID },
});

let viewID = "addons://detail/" + encodeURIComponent(action.extensionID);
window.BrowserOpenAddonsMgr(viewID);
},
Expand Down
58 changes: 3 additions & 55 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ChromeUtils.import("resource://gre/modules/NotificationDB.jsm");

XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
AMTelemetry: "resource://gre/modules/AddonManager.jsm",
NewTabPagePreloading: "resource:///modules/NewTabPagePreloading.jsm",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.jsm",
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
Expand Down Expand Up @@ -534,13 +533,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
false
);

XPCOMUtils.defineLazyPreferenceGetter(
this,
"gAddonAbuseReportEnabled",
"extensions.abuseReport.enabled",
false
);

customElements.setElementCreationCallback("translation-notification", () => {
Services.scriptloader.loadSubScript(
"chrome://browser/content/translation-notification.js",
Expand Down Expand Up @@ -7763,19 +7755,6 @@ function promptRemoveExtension(addon) {
let checkboxState = { value: false };
let checkboxMessage = null;

// Enable abuse report checkbox in the remove extension dialog,
// if enabled by the about:config prefs and the addon type
// is currently supported.
if (
gHtmlAboutAddonsEnabled &&
gAddonAbuseReportEnabled &&
["extension", "theme"].includes(addon.type)
) {
checkboxMessage = getFormattedString(
"webext.remove.abuseReportCheckbox.message",
[document.getElementById("bundle_brand").getString("vendorShortName")]
);
}
const result = confirmEx(
null,
title,
Expand Down Expand Up @@ -7834,20 +7813,16 @@ var ToolbarContextMenu = {
let manageExtension = popup.querySelector(
".customize-context-manageExtension"
);
let reportExtension = popup.querySelector(
".customize-context-reportExtension"
);
let separator = reportExtension.nextElementSibling;
let id = this._getExtensionId(popup);
let addon = id && (await AddonManager.getAddonByID(id));

let separator = popup.querySelector(
".customize-context-removeExtension"
).nextElementSibling;
for (let element of [removeExtension, manageExtension, separator]) {
element.hidden = !addon;
}

reportExtension.hidden =
!addon || !gAddonAbuseReportEnabled || !gHtmlAboutAddonsEnabled;

if (addon) {
removeExtension.disabled = !(
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
Expand All @@ -7862,45 +7837,18 @@ var ToolbarContextMenu = {
return;
}
let { remove, report } = promptRemoveExtension(addon);
AMTelemetry.recordActionEvent({
object: "browserAction",
action: "uninstall",
value: remove ? "accepted" : "cancelled",
extra: { addonId: addon.id },
});
if (remove) {
// Leave the extension in pending uninstall if we are also
// reporting the add-on.
await addon.uninstall(report);
if (report) {
this.reportExtensionForContextAction(popup, "uninstall");
}
}
},

async reportExtensionForContextAction(popup, reportEntryPoint) {
let id = this._getExtensionId(popup);
let addon = id && (await AddonManager.getAddonByID(id));
if (!addon) {
return;
}
const win = await BrowserOpenAddonsMgr("addons://list/extension");
win.openAbuseReport({
addonId: addon.id,
reportEntryPoint,
});
},

openAboutAddonsForContextAction(popup) {
let id = this._getExtensionId(popup);
if (id) {
let viewID = "addons://detail/" + encodeURIComponent(id);
BrowserOpenAddonsMgr(viewID);
AMTelemetry.recordActionEvent({
object: "browserAction",
action: "manage",
extra: { addonId: id },
});
}
},
};
Expand Down
5 changes: 0 additions & 5 deletions browser/base/content/browser.xul
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,6 @@
label="&customizeMenu.removeExtension.label;"
contexttype="toolbaritem"
class="customize-context-removeExtension"/>
<menuitem oncommand="ToolbarContextMenu.reportExtensionForContextAction(this.parentElement, 'toolbar_context_menu')"
accesskey="&customizeMenu.reportExtension.accesskey;"
label="&customizeMenu.reportExtension.label;"
contexttype="toolbaritem"
class="customize-context-reportExtension"/>
<menuseparator/>
<menuitem oncommand="gCustomizeMode.addToPanel(document.popupNode)"
accesskey="&customizeMenu.pinToOverflowMenu.accesskey;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ add_task(async function startup() {
"network.loadinfo.skip_type_assertion": {
// This is accessed in debug only.
},
"extensions.getAddons.cache.enabled": {
min: 4,
max: 55,
},
"chrome.override_package.global": {
min: 0,
max: 50,
Expand Down
1 change: 0 additions & 1 deletion browser/base/content/test/webextensions/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ support-files =
skip-if = !e10s
[browser_permissions_pointerevent.js]
[browser_permissions_unsigned.js]
skip-if = require_signing
[browser_update_checkForUpdates.js]
[browser_update_findUpdates.js]
[browser_update_interactive_noprompt.js]
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const { AddonTestUtils } = ChromeUtils.import(

AddonTestUtils.initMochitest(this);

hookExtensionsTelemetry();
AddonTestUtils.hookAMTelemetryEvents();

async function createWebExtension(details) {
let options = {
manifest: {
Expand Down Expand Up @@ -104,7 +101,6 @@ async function test_sideloading({ useHtmlViews }) {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.htmlaboutaddons.enabled", useHtmlViews],
["xpinstall.signatures.required", false],
["extensions.autoDisableScopes", 15],
["extensions.ui.ignoreUnsigned", true],
["extensions.allowPrivateBrowsingByDefault", false],
Expand Down Expand Up @@ -373,16 +369,7 @@ async function test_sideloading({ useHtmlViews }) {
const getEventsForAddonId = (events, addonId) =>
events.filter(ev => ev.value === addonId);

const amEvents = AddonTestUtils.getAMTelemetryEvents();

// Test telemetry events for addon1 (1 permission and 1 origin).
info("Test telemetry events collected for addon1");

const baseEventAddon1 = createBaseEventAddon(1);
const collectedEventsAddon1 = getEventsForAddonId(
amEvents,
baseEventAddon1.value
);
const expectedEventsAddon1 = [
{
...baseEventAddon1,
Expand All @@ -392,26 +379,7 @@ async function test_sideloading({ useHtmlViews }) {
{ ...baseEventAddon1, method: "uninstall" },
];

let i = 0;
for (let event of collectedEventsAddon1) {
Assert.deepEqual(
event,
expectedEventsAddon1[i++],
"Got the expected telemetry event"
);
}

is(
collectedEventsAddon1.length,
expectedEventsAddon1.length,
"Got the expected number of telemetry events for addon1"
);

const baseEventAddon2 = createBaseEventAddon(2);
const collectedEventsAddon2 = getEventsForAddonId(
amEvents,
baseEventAddon2.value
);
const expectedEventsAddon2 = [
{
...baseEventAddon2,
Expand All @@ -421,21 +389,6 @@ async function test_sideloading({ useHtmlViews }) {
{ ...baseEventAddon2, method: "enable" },
{ ...baseEventAddon2, method: "uninstall" },
];

i = 0;
for (let event of collectedEventsAddon2) {
Assert.deepEqual(
event,
expectedEventsAddon2[i++],
"Got the expected telemetry event"
);
}

is(
collectedEventsAddon2.length,
expectedEventsAddon2.length,
"Got the expected number of telemetry events for addon2"
);
}

add_task(async function test_xul_aboutaddons_sideloading() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ add_task(async function setup() {
});
});

hookExtensionsTelemetry();
AddonTestUtils.hookAMTelemetryEvents();

// Helper function to test background updates.
async function backgroundUpdateTest(url, id, checkIconFn) {
await SpecialPowers.pushPrefEnv({
Expand Down Expand Up @@ -209,35 +206,6 @@ async function backgroundUpdateTest(url, id, checkIconFn) {
await addon.uninstall();
await SpecialPowers.popPrefEnv();

// Test that the expected telemetry events have been recorded (and that they include the
// permission_prompt event).
const amEvents = AddonTestUtils.getAMTelemetryEvents();
const updateEvents = amEvents
.filter(evt => evt.method === "update")
.map(evt => {
delete evt.value;
return evt;
});

Assert.deepEqual(
updateEvents.map(evt => evt.extra && evt.extra.step),
[
// First update (cancelled).
"started",
"download_started",
"download_completed",
"permissions_prompt",
"cancelled",
// Second update (completed).
"started",
"download_started",
"download_completed",
"permissions_prompt",
"completed",
],
"Got the steps from the collected telemetry events"
);

const method = "update";
const object = "extension";
const baseExtra = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const { AddonTestUtils } = ChromeUtils.import(

AddonTestUtils.initMochitest(this);

hookExtensionsTelemetry();
AddonTestUtils.hookAMTelemetryEvents();

const ID_PERMS = "[email protected]";
const ID_ORIGINS = "[email protected]";

Expand All @@ -27,8 +24,6 @@ add_task(async function setup() {
// We don't have pre-pinned certificates for the local mochitest server
["extensions.install.requireBuiltInCerts", false],
["extensions.update.requireBuiltInCerts", false],
// Don't require the extensions to be signed
["xpinstall.signatures.required", false],
],
});

Expand Down Expand Up @@ -92,23 +87,6 @@ async function testNoPrompt(origUrl, id) {
await addon.uninstall();
await SpecialPowers.popPrefEnv();

// Test that the expected telemetry events have been recorded (and that they do not
// include the permission_prompt event).
const amEvents = AddonTestUtils.getAMTelemetryEvents();
const updateEventsSteps = amEvents
.filter(evt => {
return evt.method === "update" && evt.extra && evt.extra.addon_id == id;
})
.map(evt => {
return evt.extra.step;
});

// Expect telemetry events related to a completed update with no permissions_prompt event.
Assert.deepEqual(
updateEventsSteps,
["started", "download_started", "download_completed", "completed"],
"Got the steps from the collected telemetry events"
);
}

// Test that an update that adds new non-promptable permissions is just
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ add_task(async function setup() {
["extensions.install.requireBuiltInCerts", false],
["extensions.update.requireBuiltInCerts", false],

// Don't require the extensions to be signed
["xpinstall.signatures.required", false],

// Point updates to the local mochitest server
["extensions.update.url", `${BASE}/browser_webext_update.json`],
],
Expand Down
Loading

0 comments on commit 5ce6c62

Please sign in to comment.