commit 6bdbcbc6a323f866cda64a6a84b18a1732d759f7
parent b64f5ef676234b19c5a2a2686dd5b53db45b0c2d
Author: dadaa <daisuke.akatsuka@birchill.co.jp>
Date: Fri, 19 Dec 2025 01:41:01 +0000
Bug 1961568: Handle about:newtab and about:privatebrowsing as blank page r=adw
Differential Revision: https://phabricator.services.mozilla.com/D250532
Diffstat:
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/browser/components/urlbar/content/UrlbarInput.mjs b/browser/components/urlbar/content/UrlbarInput.mjs
@@ -791,7 +791,7 @@ export class UrlbarInput extends HTMLElement {
// identity yet. See Bug 1746383.
valid =
!dueToSessionRestore &&
- (!this.window.isBlankPageURL(uri.spec) ||
+ (!this.#canHandleAsBlankPage(uri.spec) ||
lazy.ExtensionUtils.isExtensionUrl(uri) ||
isInitialPageControlledByWebContent);
} else if (
@@ -938,7 +938,7 @@ export class UrlbarInput extends HTMLElement {
if (
browser != this.window.gBrowser.selectedBrowser &&
- !this.window.isBlankPageURL(locationURI.spec)
+ !this.#canHandleAsBlankPage(locationURI.spec)
) {
// If the page is loaded on background tab, make Unified Search Button
// unavailable when back to the tab.
@@ -5641,6 +5641,10 @@ export class UrlbarInput extends HTMLElement {
this._isKeyDownWithMetaAndLeft)
);
}
+
+ #canHandleAsBlankPage(spec) {
+ return this.window.isBlankPageURL(spec) || spec == "about:privatebrowsing";
+ }
}
/**
diff --git a/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_dynamicUnifiedSearchButton.js b/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_dynamicUnifiedSearchButton.js
@@ -134,6 +134,40 @@ add_task(async function test_button_visibility_by_tab_switching() {
BrowserTestUtils.removeTab(tab);
});
+add_task(async function test_button_visibility_by_navigate_blank_page() {
+ const BLANK_PAGE_URLS = [
+ "about:blank",
+ "about:home",
+ "about:newtab",
+ "about:privatebrowsing",
+ ];
+
+ for (let isPrivateMode of [false, true]) {
+ for (let url of BLANK_PAGE_URLS) {
+ info(`Test for ${url} in private mode: ${isPrivateMode}`);
+
+ info("Open pageproxystate valid page");
+ let tab = await BrowserTestUtils.openNewForegroundTab(
+ gBrowser,
+ "https://example.com/"
+ );
+ await assertState(false, "valid");
+
+ info("Navigate to blank page");
+ let onLocationChange = BrowserTestUtils.waitForLocationChange(
+ gBrowser,
+ url
+ );
+ gURLBar.value = url;
+ gURLBar.focus();
+ EventUtils.synthesizeKey("KEY_Enter");
+ await onLocationChange;
+ await assertState(true, "invalid");
+ BrowserTestUtils.removeTab(tab);
+ }
+ }
+});
+
async function assertState(expectedVisible, expectedProxyPageState) {
let switcher = document.getElementById("urlbar-searchmode-switcher");
await BrowserTestUtils.waitForCondition(() => {