tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit a748e9d61e04fa1f0f6c8f5c6bb312967f4901a2
parent 40facf4946eaa56583da9905a7aa657dd381fb61
Author: Rob Wu <rob@robwu.nl>
Date:   Thu,  9 Oct 2025 01:59:35 +0000

Bug 1778684 - Add test coverage for blocklisted addon r=rpl

When bug 1917848 introduced the blocklist messages in the extensions
panel, it added logic to customize the about:addons page that would be
opened if there are no extensions in the panel. It did not include unit
tests for this scenario.

The previous commit in this bug (bug 1778684) defaults to showing the
panel when extensions are disabled, with some explanatory UI. Because
blocklisted add-ons are disabled, this also implies that the
shouldShowBlocklistAttention check in browser-addons.js is now obsolete.
This patch removes that check as a cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D265968

Diffstat:
Mbrowser/base/content/browser-addons.js | 5+----
Mbrowser/components/extensions/test/browser/browser_unified_extensions_empty_panel.js | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js @@ -2634,10 +2634,7 @@ var gUnifiedExtensions = { ) { let viewID; if ( - Services.prefs.getBoolPref("extensions.getAddons.showPane", true) && - // Unconditionally show the list of extensions if the blocklist - // attention flag has been shown on the extension panel button. - !AddonManager.shouldShowBlocklistAttention() + Services.prefs.getBoolPref("extensions.getAddons.showPane", true) ) { viewID = "addons://discover/"; } else { diff --git a/browser/components/extensions/test/browser/browser_unified_extensions_empty_panel.js b/browser/components/extensions/test/browser/browser_unified_extensions_empty_panel.js @@ -357,3 +357,70 @@ add_task(async function test_no_empty_state_with_disabled_non_extension() { await disabledDictAddon.uninstall(); await dictAddon.uninstall(); }); + +// Verifies that if the only add-on is disabled by blocklisting, that we still +// see a panel and that the blocklist message is visible. +add_task(async function test_empty_state_with_blocklisted_addon() { + const addonId = "@extension-that-is-blocked"; + const addon = await promiseInstallWebExtension({ + manifest: { + name: "Name of the blocked ext", + browser_specific_settings: { gecko: { id: addonId } }, + }, + }); + + let promiseBlocklistAttentionUpdated = AddonTestUtils.promiseManagerEvent( + "onBlocklistAttentionUpdated" + ); + const cleanupBlocklist = await loadBlocklistRawData({ blocked: [addon] }); + info("Wait for onBlocklistAttentionUpdated manager listener call"); + await promiseBlocklistAttentionUpdated; + + // This clicks on gUnifiedExtensions.button and waits for panel to show. + await openExtensionsPanel(window); + + // Verify that the blocklist messages appear. + const messages = getMessageBars(window); + is(messages.length, 1, "Expected a message in the Extensions Panel"); + Assert.deepEqual( + window.document.l10n.getAttributes(messages[0]), + { + id: "unified-extensions-mb-blocklist-error-single", + args: { + extensionName: "Name of the blocked ext", + extensionsCount: 1, + }, + }, + "Blocklist message appears in the (empty) extension panel" + ); + + let emptyStateBox = getEmptyStateContainer(window); + ok(BrowserTestUtils.isVisible(emptyStateBox), "Empty state is visible"); + is( + emptyStateBox.querySelector("h2").getAttribute("data-l10n-id"), + "unified-extensions-empty-reason-extension-not-enabled", + "Has header 'You have extensions installed, but not enabled'" + ); + is( + emptyStateBox.querySelector("description").getAttribute("data-l10n-id"), + "unified-extensions-empty-content-explain-enable", + "Has description pointing to Manage extensions button." + ); + + await closeExtensionsPanel(window); + + await cleanupBlocklist(); + + // Verify that the messages and empty state gets cleaned up when we re-open + // after unblocking. + + await openExtensionsPanel(window); + is(getMessageBars().length, 0, "No blocklist messages after unblocking"); + ok( + BrowserTestUtils.isHidden(getEmptyStateContainer(window)), + "Empty state is hidden when extension is unblocked" + ); + await closeExtensionsPanel(window); + + await addon.uninstall(); +});