Bug 1276117 - part 1: fix URL bar state when loading about:home after about:preferences, r=mikedeboer

MozReview-Commit-ID: D5ecLsiJF3R

--HG--
extra : rebase_source : e2182ab760cb052fb9e6996a3c9e948c6d67fd66
This commit is contained in:
Gijs Kruitbosch 2016-05-27 14:06:02 +01:00
parent 90995928a3
commit 939d620e96
4 changed files with 52 additions and 4 deletions

View File

@ -43,6 +43,7 @@ support-files =
moz.png
[browser_tabMatchesInAwesomebar_perwindowpb.js]
skip-if = os == 'linux' # Bug 1104755
[browser_urlbarAboutHomeLoading.js]
[browser_urlbarAutoFillTrimURLs.js]
[browser_urlbarCopying.js]
subsuite = clipboard

View File

@ -0,0 +1,43 @@
"use strict";
/**
* Test what happens if loading a URL that should clear the
* location bar after a parent process URL.
*/
add_task(function* clearURLBarAfterParentProcessURL() {
let tab = yield new Promise(resolve => {
gBrowser.selectedTab = gBrowser.addTab("about:preferences");
let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
newTabBrowser.addEventListener("Initialized", function onInit() {
newTabBrowser.removeEventListener("Initialized", onInit, true);
resolve(gBrowser.selectedTab);
}, true);
});
document.getElementById("home-button").click();
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
is(gURLBar.value, "", "URL bar should be empty");
is(tab.linkedBrowser.userTypedValue, null, "The browser should have no recorded userTypedValue");
yield BrowserTestUtils.removeTab(tab);
});
/**
* Same as above, but open the tab without passing the URL immediately
* which changes behaviour in tabbrowser.xml.
*/
add_task(function* clearURLBarAfterParentProcessURLInExistingTab() {
let tab = yield new Promise(resolve => {
gBrowser.selectedTab = gBrowser.addTab();
let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
newTabBrowser.addEventListener("Initialized", function onInit() {
newTabBrowser.removeEventListener("Initialized", onInit, true);
resolve(gBrowser.selectedTab);
}, true);
newTabBrowser.loadURI("about:preferences");
});
document.getElementById("home-button").click();
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
is(gURLBar.value, "", "URL bar should be empty");
is(tab.linkedBrowser.userTypedValue, null, "The browser should have no recorded userTypedValue");
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -784,7 +784,10 @@ var SessionStoreInternal = {
// clear user input instead), so we shouldn't set them here either.
// They also don't fall under the issues in bug 439675 where user input
// needs to be preserved if the load doesn't succeed.
if (!browser.userTypedValue && uri && !win.gInitialPages.includes(uri)) {
// We also don't do this for remoteness updates, where it should not
// be necessary.
if (!browser.userTypedValue && uri && !data.isRemotenessUpdate &&
!win.gInitialPages.includes(uri)) {
browser.userTypedValue = uri;
}
@ -3335,7 +3338,8 @@ var SessionStoreInternal = {
browser.messageManager.sendAsyncMessage("SessionStore:restoreHistory", {
tabData: tabData,
epoch: epoch,
loadArguments: aLoadArguments
loadArguments: aLoadArguments,
isRemotenessUpdate,
});
}

View File

@ -154,7 +154,7 @@ var MessageListener = {
}
},
restoreHistory({epoch, tabData, loadArguments}) {
restoreHistory({epoch, tabData, loadArguments, isRemotenessUpdate}) {
gContentRestore.restoreHistory(tabData, loadArguments, {
// Note: The callbacks passed here will only be used when a load starts
// that was not initiated by sessionstore itself. This can happen when
@ -179,7 +179,7 @@ var MessageListener = {
// sync about the state of the restore (particularly regarding
// docShell.currentURI). Using a synchronous message is the easiest way
// to temporarily synchronize them.
sendSyncMessage("SessionStore:restoreHistoryComplete", {epoch});
sendSyncMessage("SessionStore:restoreHistoryComplete", {epoch, isRemotenessUpdate});
},
restoreTabContent({loadArguments, isRemotenessUpdate}) {