Bug 1676492, show the bookmarks toolbar when a new window is opened when the preference is set to show a blank page, r=Mardak,settings-reviewers

w

Differential Revision: https://phabricator.services.mozilla.com/D155003
This commit is contained in:
Neil Deakin 2022-11-01 20:43:02 +00:00
Родитель e96d17d38c
Коммит 7997a24179
7 изменённых файлов: 42 добавлений и 21 удалений

Просмотреть файл

@ -6741,7 +6741,9 @@ function setToolbarVisibility(
}
}
isVisible =
!!currentURI && BookmarkingUI.isOnNewTabPage({ currentURI });
!!currentURI &&
(BookmarkingUI.isOnNewTabPage({ currentURI }) ||
currentURI?.spec == "chrome://browser/content/blanktab.html");
break;
}
}

Просмотреть файл

@ -79,7 +79,8 @@ function isBlankPageURL(aURL) {
aURL == "about:blank" ||
aURL == "about:home" ||
aURL == "about:welcome" ||
aURL == BROWSER_NEW_TAB_URL
aURL == BROWSER_NEW_TAB_URL ||
aURL == "chrome://browser/content/blanktab.html"
);
}

Просмотреть файл

@ -51,7 +51,7 @@ add_task(async function homepage_test_startpage_none() {
},
});
await check_homepage({
expectedURL: "about:blank",
expectedURL: "chrome://browser/content/blanktab.html",
expectedPageVal: 1,
});
});

Просмотреть файл

@ -1,33 +1,33 @@
function checkSpec(uri, check, message) {
function getSpec(uri) {
const { spec } = NetUtil.newChannel({
loadUsingSystemPrincipal: true,
uri,
}).URI;
info(`got ${spec} for ${uri}`);
check(spec, "about:blank", message);
return spec;
}
add_task(async function test_newtab_enabled() {
checkSpec(
"about:newtab",
isnot,
ok(
!getSpec("about:newtab").endsWith("/blanktab.html"),
"did not get blank for default about:newtab"
);
checkSpec("about:home", isnot, "did not get blank for default about:home");
ok(
!getSpec("about:home").endsWith("/blanktab.html"),
"did not get blank for default about:home"
);
await SpecialPowers.pushPrefEnv({
set: [["browser.newtabpage.enabled", false]],
});
const { spec } = NetUtil.newChannel({
loadUsingSystemPrincipal: true,
uri: "about:newtab",
}).URI;
ok(
spec.endsWith("/blanktab.html"),
getSpec("about:newtab").endsWith("/blanktab.html"),
"got special blank page when newtab is not enabled"
);
checkSpec("about:home", isnot, "still did not get blank for about:home");
ok(
!getSpec("about:home").endsWith("/blanktab.html"),
"got special blank page for about:home"
);
});

Просмотреть файл

@ -32,6 +32,8 @@ const HOMEPAGE_OVERRIDE_KEY = "homepage_override";
const URL_OVERRIDES_TYPE = "url_overrides";
const NEW_TAB_KEY = "newTabURL";
const BLANK_HOMEPAGE_URL = "chrome://browser/content/blanktab.html";
var gHomePane = {
HOME_MODE_FIREFOX_HOME: "0",
HOME_MODE_BLANK: "1",
@ -100,7 +102,8 @@ var gHomePane = {
// If the new tab url was changed to about:blank or about:newtab
if (
AboutNewTab.newTabURL === "about:newtab" ||
AboutNewTab.newTabURL === "about:blank"
AboutNewTab.newTabURL === "about:blank" ||
AboutNewTab.newTabURL === BLANK_HOMEPAGE_URL
) {
let newtabEnabledPref = Services.prefs.getBoolPref(
this.NEWTAB_ENABLED_PREF,
@ -305,7 +308,7 @@ var gHomePane = {
// (and it makes existing tests happy).
let newValue;
if (
homePage === "about:blank" ||
this._isBlankPage(homePage) ||
(HomePage.isDefault && !HomePage.locked)
) {
newValue = "";
@ -335,7 +338,7 @@ var gHomePane = {
isHomePageBlank() {
const startupPref = Preferences.get("browser.startup.page");
return (
["about:blank", ""].includes(HomePage.get()) ||
["about:blank", BLANK_HOMEPAGE_URL, ""].includes(HomePage.get()) ||
startupPref.value === gMainPane.STARTUP_PREF_BLANK
);
},
@ -472,8 +475,8 @@ var gHomePane = {
}
break;
case this.HOME_MODE_BLANK:
if (HomePage.get() !== "about:blank") {
HomePage.safeSet("about:blank");
if (!this._isBlankPage(HomePage.get())) {
HomePage.safeSet(BLANK_HOMEPAGE_URL);
} else {
this._renderCustomSettings({ shouldShow: false });
}
@ -621,6 +624,10 @@ var gHomePane = {
);
},
_isBlankPage(url) {
return url == "about:blank" || url == BLANK_HOMEPAGE_URL;
},
/**
* Show the Restore Defaults button if any preference on the Home tab was
* changed, or hide it otherwise.

Просмотреть файл

@ -18,6 +18,8 @@ add_task(async function default_homepage_test() {
homeMode.dispatchEvent(new Event("command"));
is(Services.prefs.getCharPref("browser.startup.homepage"), "about:home");
// HOME_MODE_BLANK
homeMode.value = 1;
@ -28,6 +30,11 @@ add_task(async function default_homepage_test() {
"Wait for customSettings to be hidden."
);
is(
Services.prefs.getCharPref("browser.startup.homepage"),
"chrome://browser/content/blanktab.html"
);
// HOME_MODE_CUSTOM
homeMode.value = 2;

Просмотреть файл

@ -139,6 +139,10 @@ let HomePage = {
}
}
if (homePages == "about:blank") {
homePages = "chrome://browser/content/blanktab.html";
}
return homePages;
},