Bug 1578624 - P11: Add a flag to ask the parent to not actually load the URI when opening a window, since we'll do it ourselves anyway. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D47867
This commit is contained in:
Matt Woodrow
2019-10-11 01:56:35 +00:00
parent d27f2f3cae
commit d90755519d
5 changed files with 35 additions and 26 deletions

View File

@@ -6469,7 +6469,8 @@ nsBrowserAccess.prototype = {
aTriggeringPrincipal = null, aTriggeringPrincipal = null,
aNextRemoteTabId = 0, aNextRemoteTabId = 0,
aName = "", aName = "",
aCsp = null aCsp = null,
aSkipLoad = false
) { ) {
let win, needToFocusWin; let win, needToFocusWin;
@@ -6508,6 +6509,7 @@ nsBrowserAccess.prototype = {
nextRemoteTabId: aNextRemoteTabId, nextRemoteTabId: aNextRemoteTabId,
name: aName, name: aName,
csp: aCsp, csp: aCsp,
skipLoad: aSkipLoad,
}); });
let browser = win.gBrowser.getBrowserForTab(tab); let browser = win.gBrowser.getBrowserForTab(tab);
@@ -6532,7 +6534,8 @@ nsBrowserAccess.prototype = {
aWhere, aWhere,
aFlags, aFlags,
aTriggeringPrincipal, aTriggeringPrincipal,
aCsp aCsp,
true
); );
}, },
@@ -6547,7 +6550,8 @@ nsBrowserAccess.prototype = {
aWhere, aWhere,
aFlags, aFlags,
aTriggeringPrincipal, aTriggeringPrincipal,
aCsp aCsp,
false
); );
}, },
@@ -6557,7 +6561,8 @@ nsBrowserAccess.prototype = {
aWhere, aWhere,
aFlags, aFlags,
aTriggeringPrincipal, aTriggeringPrincipal,
aCsp aCsp,
aSkipLoad
) { ) {
// This function should only ever be called if we're opening a URI // This function should only ever be called if we're opening a URI
// from a non-remote browser window (via nsContentTreeOwner). // from a non-remote browser window (via nsContentTreeOwner).
@@ -6687,7 +6692,8 @@ nsBrowserAccess.prototype = {
aTriggeringPrincipal, aTriggeringPrincipal,
0, 0,
"", "",
aCsp aCsp,
aSkipLoad
); );
if (browser) { if (browser) {
browsingContext = browser.browsingContext; browsingContext = browser.browsingContext;
@@ -6725,14 +6731,17 @@ nsBrowserAccess.prototype = {
aNextRemoteTabId, aNextRemoteTabId,
aName aName
) { ) {
// Passing a null-URI to only create the content window. // Passing a null-URI to only create the content window,
// and pass true for aSkipLoad to prevent loading of
// about:blank
return this.getContentWindowOrOpenURIInFrame( return this.getContentWindowOrOpenURIInFrame(
null, null,
aParams, aParams,
aWhere, aWhere,
aFlags, aFlags,
aNextRemoteTabId, aNextRemoteTabId,
aName aName,
true
); );
}, },
@@ -6750,7 +6759,8 @@ nsBrowserAccess.prototype = {
aWhere, aWhere,
aFlags, aFlags,
aNextRemoteTabId, aNextRemoteTabId,
aName aName,
false
); );
}, },
@@ -6760,7 +6770,8 @@ nsBrowserAccess.prototype = {
aWhere, aWhere,
aFlags, aFlags,
aNextRemoteTabId, aNextRemoteTabId,
aName aName,
aSkipLoad
) { ) {
if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) { if (aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) {
dump("Error: openURIInFrame can only open in new tabs"); dump("Error: openURIInFrame can only open in new tabs");
@@ -6787,7 +6798,8 @@ nsBrowserAccess.prototype = {
aParams.triggeringPrincipal, aParams.triggeringPrincipal,
aNextRemoteTabId, aNextRemoteTabId,
aName, aName,
aParams.csp aParams.csp,
aSkipLoad
); );
}, },

View File

@@ -1612,6 +1612,7 @@
var aFocusUrlBar; var aFocusUrlBar;
var aName; var aName;
var aCsp; var aCsp;
var aSkipLoad;
if ( if (
arguments.length == 2 && arguments.length == 2 &&
typeof arguments[1] == "object" && typeof arguments[1] == "object" &&
@@ -1642,6 +1643,7 @@
aFocusUrlBar = params.focusUrlBar; aFocusUrlBar = params.focusUrlBar;
aName = params.name; aName = params.name;
aCsp = params.csp; aCsp = params.csp;
aSkipLoad = params.skipLoad;
} }
// all callers of loadOneTab need to pass a valid triggeringPrincipal. // all callers of loadOneTab need to pass a valid triggeringPrincipal.
@@ -1682,6 +1684,7 @@
focusUrlBar: aFocusUrlBar, focusUrlBar: aFocusUrlBar,
name: aName, name: aName,
csp: aCsp, csp: aCsp,
skipLoad: aSkipLoad,
}); });
if (!bgLoad) { if (!bgLoad) {
this.selectedTab = tab; this.selectedTab = tab;
@@ -2094,6 +2097,7 @@
sameProcessAsFrameLoader, sameProcessAsFrameLoader,
uriIsAboutBlank, uriIsAboutBlank,
userContextId, userContextId,
skipLoad,
} = {}) { } = {}) {
let b = document.createXULElement("browser"); let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the // Use the JSM global to create the permanentKey, so that if the
@@ -2210,7 +2214,7 @@
// Prevent the superfluous initial load of a blank document // Prevent the superfluous initial load of a blank document
// if we're going to load something other than about:blank. // if we're going to load something other than about:blank.
if (!uriIsAboutBlank) { if (!uriIsAboutBlank || skipLoad) {
b.setAttribute("nodefaultsrc", "true"); b.setAttribute("nodefaultsrc", "true");
} }
@@ -2577,6 +2581,7 @@
recordExecution, recordExecution,
replayExecution, replayExecution,
csp, csp,
skipLoad,
} = {} } = {}
) { ) {
// all callers of addTab that pass a params object need to pass // all callers of addTab that pass a params object need to pass
@@ -2810,6 +2815,7 @@
name, name,
recordExecution, recordExecution,
replayExecution, replayExecution,
skipLoad,
}); });
} }
@@ -2903,7 +2909,8 @@
// then let's just continue loading the page normally. // then let's just continue loading the page normally.
if ( if (
!usingPreloadedContent && !usingPreloadedContent &&
(!uriIsAboutBlank || !allowInheritPrincipal) (!uriIsAboutBlank || !allowInheritPrincipal) &&
!skipLoad
) { ) {
// pretend the user typed this so it'll be available till // pretend the user typed this so it'll be available till
// the document successfully loads // the document successfully loads

View File

@@ -1445,10 +1445,12 @@ mozilla::ipc::IPCResult BrowserChild::RecvActivate() {
// is definitely not going to work. GetPresShell should // is definitely not going to work. GetPresShell should
// create a PresShell if one doesn't exist yet. // create a PresShell if one doesn't exist yet.
RefPtr<PresShell> presShell = GetTopLevelPresShell(); RefPtr<PresShell> presShell = GetTopLevelPresShell();
MOZ_ASSERT(presShell); NS_ASSERTION(presShell, "Need a PresShell to activate!");
Unused << presShell; Unused << presShell;
mWebBrowser->FocusActivate(); if (presShell) {
mWebBrowser->FocusActivate();
}
return IPC_OK(); return IPC_OK();
} }

View File

@@ -1134,10 +1134,6 @@ nsresult ContentChild::ProvideWindowCommon(
} }
} }
if (!urlToLoad.IsEmpty()) {
newChild->RecvLoadURL(urlToLoad, showInfo);
}
if (xpc::IsInAutomation()) { if (xpc::IsInAutomation()) {
if (nsCOMPtr<nsPIDOMWindowOuter> outer = if (nsCOMPtr<nsPIDOMWindowOuter> outer =
do_GetInterface(newChild->WebNavigation())) { do_GetInterface(newChild->WebNavigation())) {

View File

@@ -809,14 +809,6 @@ nsresult nsWindowWatcher::OpenWindowInternal(
if (NS_SUCCEEDED(rv) && newBC) { if (NS_SUCCEEDED(rv) && newBC) {
nsCOMPtr<nsIDocShell> newDocShell = newBC->GetDocShell(); nsCOMPtr<nsIDocShell> newDocShell = newBC->GetDocShell();
if (windowIsNew && newDocShell) {
// Make sure to stop any loads happening in this window that the
// window provider might have started. Otherwise if our caller
// manipulates the window it just opened and then the load
// completes their stuff will get blown away.
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(newDocShell);
webNav->Stop(nsIWebNavigation::STOP_NETWORK);
}
// If this is a new window, but it's incompatible with the current // If this is a new window, but it's incompatible with the current
// userContextId, we ignore it and we pretend that nothing has been // userContextId, we ignore it and we pretend that nothing has been