Bug 508000 - Search bar & find bar value before switching into Private Browsing mode is not restored after leaving PB mode; r=mconnor

This commit is contained in:
Ehsan Akhgari 2009-08-08 21:37:27 +04:30
Родитель 7e911a2315
Коммит 15664b5a8d
3 изменённых файлов: 38 добавлений и 22 удалений

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

@ -6862,6 +6862,8 @@ let gPrivateBrowsingUI = {
_observerService: null,
_privateBrowsingService: null,
_privateBrowsingAutoStarted: false,
_searchBarValue: null,
_findBarValue: null,
init: function PBUI_init() {
this._observerService = Cc["@mozilla.org/observer-service;1"].
@ -6946,6 +6948,12 @@ let gPrivateBrowsingUI = {
},
onEnterPrivateBrowsing: function PBUI_onEnterPrivateBrowsing() {
if (BrowserSearch.searchBar)
this._searchBarValue = BrowserSearch.searchBar.textbox.value;
if (gFindBar)
this._findBarValue = gFindBar.getElement("findbar-textbox").value;
this._setPBMenuTitle("stop");
document.getElementById("menu_import").setAttribute("disabled", "true");
@ -6979,8 +6987,14 @@ let gPrivateBrowsingUI = {
},
onExitPrivateBrowsing: function PBUI_onExitPrivateBrowsing() {
if (BrowserSearch.searchBar)
BrowserSearch.searchBar.textbox.reset();
if (BrowserSearch.searchBar) {
let searchBox = BrowserSearch.searchBar.textbox;
searchBox.reset();
if (this._searchBarValue) {
searchBox.value = this._searchBarValue;
this._searchBarValue = null;
}
}
document.getElementById("menu_import").removeAttribute("disabled");
@ -6988,8 +7002,14 @@ let gPrivateBrowsingUI = {
// temporary fix until bug 463607 is fixed
document.getElementById("Tools:Sanitize").removeAttribute("disabled");
if (gFindBar)
gFindBar.getElement("findbar-textbox").reset();
if (gFindBar) {
let findbox = gFindBar.getElement("findbar-textbox");
findbox.reset();
if (this._findBarValue) {
findbox.value = this._findBarValue;
this._findBarValue = null;
}
}
this._setPBMenuTitle("start");

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

@ -67,13 +67,16 @@ function test() {
ok(findBox.editor.transactionManager.numberOfUndoItems > 0,
"entering the private browsing mode should not reset the undo list of the findbar control");
// Change the find bar value inside the private browsing mode
findBox.value = "something else";
// leave private browsing mode
pb.privateBrowsingEnabled = false;
is(findBox.value, "",
"leaving the private browsing mode should clear the findbar");
is(findBox.editor.transactionManager.numberOfUndoItems, 0,
"leaving the private browsing mode should reset the undo list of the findbar control");
is(findBox.value, kTestSearchString,
"leaving the private browsing mode should restore the findbar contents");
is(findBox.editor.transactionManager.numberOfUndoItems, 1,
"leaving the private browsing mode should only leave 1 item in the undo list of the findbar control");
// cleanup
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");

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

@ -56,26 +56,19 @@ function test() {
is(searchBar.value, kTestSearchString,
"entering the private browsing mode should not clear the search bar");
/*
XXXehsan: uncomment this code when bug 418874 is fixed.
can't use todo, because it would pass unexpectedly!
ok(searchBar.textbox.editor.transactionManager.numberOfUndoItems > 0,
"entering the private browsing mode should not reset the undo list of the searchbar control");
*/
// Change the search bar value inside the private browsing mode
searchBar.value = "something else";
// leave private browsing mode
pb.privateBrowsingEnabled = false;
is(searchBar.value, "",
"leaving the private browsing mode should clear the search bar");
/*
XXXehsan: uncomment this code when bug 418874 is fixed.
can't use todo_is, because it would pass unexpectedly!
is(searchBar.textbox.editor.transactionManager.numberOfUndoItems, 0,
"leaving the private browsing mode should reset the undo list of the searchbar control");
*/
is(searchBar.value, kTestSearchString,
"leaving the private browsing mode should restore the search bar contents");
is(searchBar.textbox.editor.transactionManager.numberOfUndoItems, 1,
"leaving the private browsing mode should only leave 1 item in the undo list of the searchbar control");
// cleanup
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");