commit 94b801ed27c8abcbf81a28e7b78144450d2898ba
parent c943c5eecf75d89279b9f53b0a86d86913e12c72
Author: Rob Wu <rob@robwu.nl>
Date: Thu, 9 Oct 2025 01:59:34 +0000
Bug 1814871 - Add test coverage for clicking button in private browsing r=rpl
Adds test coverage for the scenario of clicking the Extensions Button in
a private browsing window where no extensions have access.
The behavior (and test) will change in the following patch.
Differential Revision: https://phabricator.services.mozilla.com/D265135
Diffstat:
1 file changed, 57 insertions(+), 0 deletions(-)
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
@@ -124,3 +124,60 @@ add_task(
await SpecialPowers.popPrefEnv();
}
);
+
+add_task(async function test_button_click_in_pbm_without_any_extensions() {
+ const win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
+
+ // Button click opens about:addons (reuses about:privatebrowsing tab).
+ // Primary click should open about:addons.
+ const tabLoadedPromise = BrowserTestUtils.browserStopped(
+ win.gBrowser.selectedBrowser,
+ "about:addons"
+ );
+
+ win.gUnifiedExtensions.button.click();
+
+ await tabLoadedPromise;
+ is(
+ win.gBrowser.currentURI.spec,
+ "about:addons",
+ "expected about:addons to be open"
+ );
+
+ // This also closes the new tab.
+ await BrowserTestUtils.closeWindow(win);
+});
+
+// Tests behavior when the user has extensions installed, but without private
+// browsing access. Extensions without private browsing access are not shown,
+// and if this was the only extension, then there is no extension to show.
+//
+// The scenario of there being an extension with private access is covered by
+// test_list_active_extensions_only in browser_unified_extensions.js.
+add_task(async function test_button_click_in_pbm_without_private_extensions() {
+ const extensions = createExtensions([{ name: "Without private access" }]);
+ await Promise.all(extensions.map(extension => extension.startup()));
+
+ const win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
+
+ // Button click opens about:addons (reuses about:privatebrowsing tab).
+ // Primary click should open about:addons.
+ const tabLoadedPromise = BrowserTestUtils.browserStopped(
+ win.gBrowser.selectedBrowser,
+ "about:addons"
+ );
+
+ win.gUnifiedExtensions.button.click();
+
+ await tabLoadedPromise;
+ is(
+ win.gBrowser.currentURI.spec,
+ "about:addons",
+ "expected about:addons to be open"
+ );
+
+ // This also closes the new tab.
+ await BrowserTestUtils.closeWindow(win);
+
+ await Promise.all(extensions.map(extension => extension.unload()));
+});