Bug 1579418 - Don't reset homepage unless we need to. r=jaws

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Kaply 2019-09-30 21:35:38 +00:00
Родитель db3ac60fec
Коммит 54257dc01e
4 изменённых файлов: 60 добавлений и 1 удалений

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

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

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

@ -15,6 +15,7 @@ skip-if = !updater
[browser_basic_rebuild_fonts_test.js]
[browser_bug410900.js]
[browser_bug731866.js]
[browser_bug1579418.js]
[browser_search_no_results_change_category.js]
[browser_search_within_preferences_1.js]
skip-if = (os == 'win' && (processor == "x86_64" || processor == "aarch64")) # Bug 1480314, aarch64 due to 1536560

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

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function default_homepage_test() {
let oldHomepagePref = Services.prefs.getCharPref("browser.startup.homepage");
let oldStartpagePref = Services.prefs.getIntPref("browser.startup.page");
await openPreferencesViaOpenPreferencesAPI("paneHome", { leaveOpen: true });
let doc = gBrowser.contentDocument;
let homeMode = doc.getElementById("homeMode");
let customSettings = doc.getElementById("customSettings");
// HOME_MODE_FIREFOX_HOME
homeMode.value = 0;
homeMode.dispatchEvent(new Event("command"));
// HOME_MODE_BLANK
homeMode.value = 1;
homeMode.dispatchEvent(new Event("command"));
await TestUtils.waitForCondition(
() => customSettings.hidden === true,
"Wait for customSettings to be hidden."
);
// HOME_MODE_CUSTOM
homeMode.value = 2;
homeMode.dispatchEvent(new Event("command"));
await TestUtils.waitForCondition(
() => customSettings.hidden === false,
"Wait for customSettings to be shown."
);
is(customSettings.hidden, false, "homePageURL should be visible");
registerCleanupFunction(async () => {
Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
Services.prefs.setIntPref("browser.startup.page", oldStartpagePref);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
});

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

@ -138,6 +138,14 @@ let HomePage = {
return getHomepagePref(true);
},
/**
* @returns {string}
* Returns the original application homepage URL (not from prefs).
*/
getOriginalDefault() {
return kDefaultHomePage;
},
/**
* @returns {boolean}
* Returns true if the homepage has been changed.