зеркало из https://github.com/mozilla/gecko-dev.git
Bug 567487 - Option to never remember history should disable the option to restore the last session; ui-r=limi r,a=gavin
This commit is contained in:
Родитель
6bd0dee24f
Коммит
0280e054be
|
@ -51,6 +51,13 @@ var gMainPane = {
|
|||
// set up the "use current page" label-changing listener
|
||||
this._updateUseCurrentButton();
|
||||
window.addEventListener("focus", this._updateUseCurrentButton, false);
|
||||
|
||||
this.updateBrowserStartupLastSession();
|
||||
|
||||
// Notify observers that the UI is now ready
|
||||
Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.notifyObservers(window, "main-pane-loaded", null);
|
||||
},
|
||||
|
||||
// HOME PAGE
|
||||
|
@ -491,5 +498,26 @@ var gMainPane = {
|
|||
showAddonsMgr: function ()
|
||||
{
|
||||
openUILinkIn("about:addons", "window");
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide/show the "Show my windows and tabs from last time" option based
|
||||
* on the value of the browser.privatebrowsing.autostart pref.
|
||||
*/
|
||||
updateBrowserStartupLastSession: function()
|
||||
{
|
||||
let pbAutoStartPref = document.getElementById("browser.privatebrowsing.autostart");
|
||||
let startupPref = document.getElementById("browser.startup.page");
|
||||
let menu = document.getElementById("browserStartupPage");
|
||||
let option = document.getElementById("browserStartupLastSession");
|
||||
if (pbAutoStartPref.value) {
|
||||
option.setAttribute("disabled", "true");
|
||||
if (option.selected) {
|
||||
menu.selectedItem = document.getElementById("browserStartupHomePage");
|
||||
}
|
||||
} else {
|
||||
option.removeAttribute("disabled");
|
||||
startupPref.updateElements(); // select the correct index in the startup menulist
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -79,6 +79,11 @@
|
|||
name="pref.browser.homepage.disable_button.restore_default"
|
||||
type="bool"/>
|
||||
|
||||
<preference id="browser.privatebrowsing.autostart"
|
||||
name="browser.privatebrowsing.autostart"
|
||||
type="bool"
|
||||
onchange="gMainPane.updateBrowserStartupLastSession();"/>
|
||||
|
||||
<!-- Downloads -->
|
||||
<preference id="browser.download.manager.showWhenStarting"
|
||||
name="browser.download.manager.showWhenStarting"
|
||||
|
@ -109,9 +114,9 @@
|
|||
control="browserStartupPage"/>
|
||||
<menulist id="browserStartupPage" preference="browser.startup.page">
|
||||
<menupopup>
|
||||
<menuitem label="&startupHomePage.label;" value="1"/>
|
||||
<menuitem label="&startupBlankPage.label;" value="0"/>
|
||||
<menuitem label="&startupLastSession.label;" value="3"/>
|
||||
<menuitem label="&startupHomePage.label;" value="1" id="browserStartupHomePage"/>
|
||||
<menuitem label="&startupBlankPage.label;" value="0" id="browserStartupBlank"/>
|
||||
<menuitem label="&startupLastSession.label;" value="3" id="browserStartupLastSession"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
|
|
|
@ -45,6 +45,7 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
_BROWSER_FILES = \
|
||||
browser_bug410900.js \
|
||||
browser_bug567487.js \
|
||||
privacypane_tests.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_2.js \
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "main-pane-loaded")
|
||||
return;
|
||||
|
||||
Services.obs.removeObserver(observer, "main-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
Services.obs.addObserver(observer, "main-pane-loaded", false);
|
||||
|
||||
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
"chrome,titlebar,toolbar,centerscreen,dialog=no", "paneMain");
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
let doc = win.document;
|
||||
let pbAutoStartPref = doc.getElementById("browser.privatebrowsing.autostart");
|
||||
let startupPref = doc.getElementById("browser.startup.page");
|
||||
let menu = doc.getElementById("browserStartupPage");
|
||||
let option = doc.getElementById("browserStartupLastSession");
|
||||
let defOption = doc.getElementById("browserStartupHomePage");
|
||||
let otherOption = doc.getElementById("browserStartupBlank");
|
||||
|
||||
ok(!pbAutoStartPref.value, "Sanity check");
|
||||
is(startupPref.value, startupPref.defaultValue, "Sanity check");
|
||||
|
||||
// First, check to make sure that setting pbAutoStartPref disables the menu item
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now ensure the correct behavior when pbAutoStartPref is set with option enabled
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
is(startupPref.value, option.getAttribute("value"), "But the value of the startup " +
|
||||
"pref itself shouldn't change");
|
||||
menu.selectedItem = otherOption;
|
||||
menu.doCommand();
|
||||
is(startupPref.value, otherOption.getAttribute("value"), "And we should be able to " +
|
||||
"chnage it!");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now, ensure that with 'Show my windows and tabs from last time' enabled, toggling
|
||||
// pbAutoStartPref would restore that value in the menulist.
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
pbAutoStartPref.value = false;
|
||||
is(menu.selectedItem, option, "The correct value should be restored");
|
||||
|
||||
// cleanup
|
||||
[pbAutoStartPref, startupPref].forEach(function (pref) {
|
||||
if (pref.hasUserValue)
|
||||
pref.reset();
|
||||
});
|
||||
|
||||
win.close();
|
||||
finish();
|
||||
}
|
Загрузка…
Ссылка в новой задаче