Bug 1276117 - part 3: fix 'about:home' appearing briefly in the URL bar while loading, r?mikedeboer
MozReview-Commit-ID: IM5V1PhDhs9
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6417,16 +6417,21 @@ function checkEmptyPageOrigin(browser =
}
let contentPrincipal = browser.contentPrincipal;
// Not all principals have URIs...
if (contentPrincipal.URI) {
// A manually entered about:blank URI is slightly magical:
if (uri.spec == "about:blank" && contentPrincipal.isNullPrincipal) {
return true;
}
+ // Initial browser loads of URIs when we've changed remoteness means
+ // contentPrincipal hasn't updated.
+ if (contentPrincipal.URI.spec == "about:blank") {
+ return true;
+ }
return contentPrincipal.URI.equals(uri);
}
// ... so for those that don't have them, enforce that the page has the
// system principal (this matches e.g. on about:newtab).
let ssm = Services.scriptSecurityManager;
return ssm.isSystemPrincipal(contentPrincipal);
}
--- a/browser/base/content/test/urlbar/browser_urlbarAboutHomeLoading.js
+++ b/browser/base/content/test/urlbar/browser_urlbarAboutHomeLoading.js
@@ -1,10 +1,12 @@
"use strict";
+const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
+
/**
* 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);
@@ -59,8 +61,43 @@ add_task(function* clearURLBarAfterManua
let aboutHomeLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "about:home");
EventUtils.sendKey("return");
yield aboutHomeLoaded;
is(gURLBar.value, "", "URL bar should be empty");
is(tab.linkedBrowser.userTypedValue, null, "userTypedValue should be null");
yield BrowserTestUtils.removeTab(tab);
});
+
+/**
+ * Ensure we don't show 'about:home' in the URL bar temporarily in new tabs
+ * while we're switching remoteness (when the URL we're loading and the
+ * default content principal are different).
+ */
+add_task(function* dontTemporarilyShowAboutHome() {
+ yield SpecialPowers.pushPrefEnv({set: [["browser.startup.page", 1]]});
+ let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
+ let win = OpenBrowserWindow();
+ yield windowOpenedPromise;
+ win.BrowserOpenTab();
+ yield BrowserTestUtils.switchTab(win.gBrowser, win.gBrowser.selectedTab.nextSibling);
+ yield TabStateFlusher.flush(win.gBrowser.selectedBrowser);
+ yield BrowserTestUtils.closeWindow(win);
+ ok(SessionStore.getClosedWindowCount(), "Should have a closed window");
+
+ windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
+ win = SessionStore.undoCloseWindow(0);
+ yield windowOpenedPromise;
+ let wpl = {
+ onLocationChange(wpl, request, location, flags) {
+ is(win.gURLBar.value, "", "URL bar value should stay empty.");
+ },
+ };
+ win.gBrowser.addProgressListener(wpl);
+ let otherTab = win.gBrowser.selectedTab.previousSibling;
+ let tabLoaded = BrowserTestUtils.browserLoaded(otherTab.linkedBrowser, false, "about:home");
+ yield BrowserTestUtils.switchTab(win.gBrowser, otherTab);
+ yield tabLoaded;
+ win.gBrowser.removeProgressListener(wpl);
+ is(win.gURLBar.value, "", "URL bar value should be empty.");
+
+ yield BrowserTestUtils.closeWindow(win);
+});