зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676492, create a special blank tab page that will show the bookmarks toolbar when 'Only Show on New Tab' is used' even when the new tab page is disabled, r=Gijs,Mardak
Differential Revision: https://phabricator.services.mozilla.com/D154319
This commit is contained in:
Родитель
779084f91d
Коммит
e96d17d38c
|
@ -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 (
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src chrome:; object-src 'none'" >
|
||||
</head>
|
||||
</html>
|
|
@ -663,6 +663,7 @@ var gInitialPages = [
|
|||
"about:sessionrestore",
|
||||
"about:welcome",
|
||||
"about:welcomeback",
|
||||
"chrome://browser/content/blanktab.html",
|
||||
];
|
||||
|
||||
function isInitialPage(url) {
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 |
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче