diff --git a/browser/actors/AboutNewTabChild.sys.mjs b/browser/actors/AboutNewTabChild.sys.mjs index 4910be9bd3ee..f22883166814 100644 --- a/browser/actors/AboutNewTabChild.sys.mjs +++ b/browser/actors/AboutNewTabChild.sys.mjs @@ -24,6 +24,10 @@ XPCOMUtils.defineLazyPreferenceGetter( export class AboutNewTabChild extends JSWindowActorChild { handleEvent(event) { if (event.type == "DOMContentLoaded") { + if (!this.contentWindow.document.body.firstElementChild) { + return; // about:newtab is a blank page + } + // If the separate about:welcome page is enabled, we can skip all of this, // since that mode doesn't load any of the Activity Stream bits. if ( diff --git a/browser/base/content/blanktab.html b/browser/base/content/blanktab.html new file mode 100644 index 000000000000..49d4851bf860 --- /dev/null +++ b/browser/base/content/blanktab.html @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index b70f97ad92dd..fb7612c90bd2 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -663,6 +663,7 @@ var gInitialPages = [ "about:sessionrestore", "about:welcome", "about:welcomeback", + "chrome://browser/content/blanktab.html", ]; function isInitialPage(url) { diff --git a/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbar.js b/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbar.js index ae595271ad36..a0d7d5af59be 100644 --- a/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbar.js +++ b/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbar.js @@ -247,6 +247,10 @@ add_task(async function test_with_newtabpage_disabled() { visible: true, message: "Toolbar is visible with NTP enabled", }); + let firstid = await SpecialPowers.spawn(newtab.linkedBrowser, [], () => { + return content.document.body.firstElementChild?.id; + }); + is(firstid, "root", "new tab page contains content"); await BrowserTestUtils.removeTab(newtab); await SpecialPowers.pushPrefEnv({ @@ -256,11 +260,22 @@ add_task(async function test_with_newtabpage_disabled() { document.getElementById("cmd_newNavigatorTab").doCommand(); await TestUtils.waitForCondition(() => gBrowser.tabs.length == tabCount + 1); newtab = gBrowser.selectedTab; - is(newtab.linkedBrowser.currentURI.spec, "about:blank", "blank is loaded"); + await waitForBookmarksToolbarVisibility({ - visible: false, - message: "Toolbar is not visible with NTP disabled", + visible: true, + message: "Toolbar is visible with NTP disabled", }); + + is( + newtab.linkedBrowser.currentURI.spec, + "about:newtab", + "blank new tab is loaded" + ); + firstid = await SpecialPowers.spawn(newtab.linkedBrowser, [], () => { + return content.document.body.firstElementChild; + }); + ok(!firstid, "blank new tab page contains no content"); + await BrowserTestUtils.removeTab(newtab); await SpecialPowers.pushPrefEnv({ diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 4239a2af4952..fb7a04ba4582 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -30,6 +30,7 @@ browser.jar: content/browser/aboutTabCrashed.css (content/aboutTabCrashed.css) content/browser/aboutTabCrashed.js (content/aboutTabCrashed.js) content/browser/aboutTabCrashed.xhtml (content/aboutTabCrashed.xhtml) + content/browser/blanktab.html (content/blanktab.html) content/browser/browser.css (content/browser.css) content/browser/browser.js (content/browser.js) * content/browser/browser.xhtml (content/browser.xhtml) diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index 266c1770f82f..59a6ea865912 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -100,7 +100,7 @@ static const RedirEntry kRedirMap[] = { // Actual activity stream URL for home and newtab are set in channel // creation {"home", "about:blank", ACTIVITY_STREAM_FLAGS}, - {"newtab", "about:blank", ACTIVITY_STREAM_FLAGS}, + {"newtab", "chrome://browser/content/blanktab.html", ACTIVITY_STREAM_FLAGS}, {"welcome", "about:blank", nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGEDABOUT_PROCESS | diff --git a/browser/components/newtab/test/browser/browser_enabled_newtabpage.js b/browser/components/newtab/test/browser/browser_enabled_newtabpage.js index 1c003198edec..69ad9e4f4950 100644 --- a/browser/components/newtab/test/browser/browser_enabled_newtabpage.js +++ b/browser/components/newtab/test/browser/browser_enabled_newtabpage.js @@ -20,6 +20,14 @@ add_task(async function test_newtab_enabled() { set: [["browser.newtabpage.enabled", false]], }); - checkSpec("about:newtab", is, "got blank when newtab is not enabled"); + const { spec } = NetUtil.newChannel({ + loadUsingSystemPrincipal: true, + uri: "about:newtab", + }).URI; + + ok( + spec.endsWith("/blanktab.html"), + "got special blank page when newtab is not enabled" + ); checkSpec("about:home", isnot, "still did not get blank for about:home"); });