Bug 1568855 - Setting a new default homepage should switch to Custom URL in prefs. r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D39405

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Kaply 2019-07-30 23:34:49 +00:00
Родитель 12bb7f0789
Коммит 40ce0682c3
4 изменённых файлов: 40 добавлений и 2 удалений

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

@ -323,6 +323,7 @@ var gHomePane = {
if (startupPref.value === gMainPane.STARTUP_PREF_BLANK) {
Services.prefs.clearUserPref(startupPref.id);
}
HomePage.clear();
this._renderCustomSettings({ shouldShow: true });
break;
}

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

@ -57,6 +57,7 @@ skip-if = (verify && debug && (os == 'linux' || os == 'mac'))
skip-if = true || !healthreport # Bug 1185403 for the "true"
[browser_homepages_filter_aboutpreferences.js]
[browser_homepages_use_bookmark.js]
[browser_homepage_default.js]
[browser_extension_controlled.js]
skip-if = ccov && os == 'win' # bug 1437051
[browser_languages_subdialog.js]

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

@ -0,0 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function default_homepage_test() {
await SpecialPowers.pushPrefEnv({
set: [["browser.startup.page", 1]],
});
let defaults = Services.prefs.getDefaultBranch("");
// Simulate a homepage set via policy or a distribution.
defaults.setStringPref("browser.startup.homepage", "https://example.com");
await openPreferencesViaOpenPreferencesAPI("paneHome", { leaveOpen: true });
let doc = gBrowser.contentDocument;
let homeMode = doc.getElementById("homeMode");
Assert.equal(homeMode.value, 2, "homeMode should be 2 (Custom URL)");
let homePageUrl = doc.getElementById("homePageUrl");
Assert.equal(
homePageUrl.value,
"https://example.com",
"homePageUrl should be example.com"
);
registerCleanupFunction(async () => {
defaults.setStringPref("browser.startup.homepage", "about:home");
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
});

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

@ -17,6 +17,7 @@ ChromeUtils.defineModuleGetter(
);
const kPrefName = "browser.startup.homepage";
const kDefaultHomePage = "about:home";
function getHomepagePref(useDefault) {
let homePage;
@ -89,14 +90,18 @@ let HomePage = {
},
get isDefault() {
return HomePage.get() === HomePage.getDefault();
return HomePage.get() === kDefaultHomePage;
},
set(value) {
Services.prefs.setStringPref(kPrefName, value);
},
reset() {
clear() {
Services.prefs.clearUserPref(kPrefName);
},
reset() {
Services.prefs.setStringPref(kPrefName, kDefaultHomePage);
},
};