зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616353 - Part 7.4: Pass nsOpenWindowInfo through tabbrowser, r=Gijs
The interface changes which browser.js and tabbrowser.js are being updated for are performed in earlier parts. This patch just covers the required changes to frontend code to propagate this information down to the nsFrameLoader when it is created. Differential Revision: https://phabricator.services.mozilla.com/D67053 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3fee0903f1
Коммит
b99cf8f798
|
@ -5986,10 +5986,9 @@ nsBrowserAccess.prototype = {
|
|||
aIsExternal,
|
||||
aForceNotRemote = false,
|
||||
aUserContextId = Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
||||
aOpenerWindow = null,
|
||||
aOpenWindowInfo = null,
|
||||
aOpenerBrowser = null,
|
||||
aTriggeringPrincipal = null,
|
||||
aNextRemoteTabId = 0,
|
||||
aName = "",
|
||||
aCsp = null,
|
||||
aSkipLoad = false
|
||||
|
@ -6026,9 +6025,8 @@ nsBrowserAccess.prototype = {
|
|||
fromExternal: aIsExternal,
|
||||
inBackground: loadInBackground,
|
||||
forceNotRemote: aForceNotRemote,
|
||||
opener: aOpenerWindow,
|
||||
openWindowInfo: aOpenWindowInfo,
|
||||
openerBrowser: aOpenerBrowser,
|
||||
nextRemoteTabId: aNextRemoteTabId,
|
||||
name: aName,
|
||||
csp: aCsp,
|
||||
skipLoad: aSkipLoad,
|
||||
|
@ -6044,7 +6042,7 @@ nsBrowserAccess.prototype = {
|
|||
|
||||
createContentWindow(
|
||||
aURI,
|
||||
aOpener,
|
||||
aOpenWindowInfo,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aTriggeringPrincipal,
|
||||
|
@ -6052,7 +6050,7 @@ nsBrowserAccess.prototype = {
|
|||
) {
|
||||
return this.getContentWindowOrOpenURI(
|
||||
null,
|
||||
aOpener,
|
||||
aOpenWindowInfo,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aTriggeringPrincipal,
|
||||
|
@ -6061,14 +6059,14 @@ nsBrowserAccess.prototype = {
|
|||
);
|
||||
},
|
||||
|
||||
openURI(aURI, aOpener, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
|
||||
openURI(aURI, aOpenWindowInfo, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
|
||||
if (!aURI) {
|
||||
Cu.reportError("openURI should only be called with a valid URI");
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
return this.getContentWindowOrOpenURI(
|
||||
aURI,
|
||||
aOpener,
|
||||
aOpenWindowInfo,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aTriggeringPrincipal,
|
||||
|
@ -6079,29 +6077,19 @@ nsBrowserAccess.prototype = {
|
|||
|
||||
getContentWindowOrOpenURI(
|
||||
aURI,
|
||||
aOpener,
|
||||
aOpenWindowInfo,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aTriggeringPrincipal,
|
||||
aCsp,
|
||||
aSkipLoad
|
||||
) {
|
||||
// This function should only ever be called if we're opening a URI
|
||||
// from a non-remote browser window (via nsContentTreeOwner).
|
||||
if (aOpener && Cu.isCrossProcessWrapper(aOpener)) {
|
||||
Cu.reportError(
|
||||
"nsBrowserAccess.openURI was passed a CPOW for aOpener. " +
|
||||
"openURI should only ever be called from non-remote browsers."
|
||||
);
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
var browsingContext = null;
|
||||
var isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||
|
||||
if (aOpener && isExternal) {
|
||||
if (aOpenWindowInfo && isExternal) {
|
||||
Cu.reportError(
|
||||
"nsBrowserAccess.openURI did not expect an opener to be " +
|
||||
"nsBrowserAccess.openURI did not expect aOpenWindowInfo to be " +
|
||||
"passed if the context is OPEN_EXTERNAL."
|
||||
);
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
|
@ -6130,18 +6118,22 @@ nsBrowserAccess.prototype = {
|
|||
let referrerInfo;
|
||||
if (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER) {
|
||||
referrerInfo = new ReferrerInfo(Ci.nsIReferrerInfo.EMPTY, false, null);
|
||||
} else {
|
||||
} else if (
|
||||
aOpenWindowInfo &&
|
||||
aOpenWindowInfo.parent &&
|
||||
aOpenWindowInfo.parent.window
|
||||
) {
|
||||
referrerInfo = new ReferrerInfo(
|
||||
aOpener && aOpener.document
|
||||
? aOpener.document.referrerInfo.referrerPolicy
|
||||
: Ci.nsIReferrerInfo.EMPTY,
|
||||
aOpenWindowInfo.parent.window.document.referrerInfo.referrerPolicy,
|
||||
true,
|
||||
aOpener ? makeURI(aOpener.location.href) : null
|
||||
makeURI(aOpenWindowInfo.parent.window.location.href)
|
||||
);
|
||||
} else {
|
||||
referrerInfo = new ReferrerInfo(Ci.nsIReferrerInfo.EMPTY, true, null);
|
||||
}
|
||||
|
||||
let isPrivate = aOpener
|
||||
? PrivateBrowsingUtils.isContentWindowPrivate(aOpener)
|
||||
let isPrivate = aOpenWindowInfo
|
||||
? aOpenWindowInfo.originAttributes.privateBrowsingId != 0
|
||||
: PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
|
||||
switch (aWhere) {
|
||||
|
@ -6195,13 +6187,10 @@ nsBrowserAccess.prototype = {
|
|||
// we can hand back the nsIDOMWindow. The XULBrowserWindow.shouldLoadURI
|
||||
// will do the job of shuttling off the newly opened browser to run in
|
||||
// the right process once it starts loading a URI.
|
||||
let forceNotRemote = !!aOpener;
|
||||
let userContextId =
|
||||
aOpener && aOpener.document
|
||||
? aOpener.document.nodePrincipal.originAttributes.userContextId
|
||||
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
|
||||
let openerWindow =
|
||||
aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER ? null : aOpener;
|
||||
let forceNotRemote = aOpenWindowInfo && !aOpenWindowInfo.remote;
|
||||
let userContextId = aOpenWindowInfo
|
||||
? aOpenWindowInfo.originAttributes.userContextId
|
||||
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
|
||||
let browser = this._openURIInNewTab(
|
||||
aURI,
|
||||
referrerInfo,
|
||||
|
@ -6209,10 +6198,9 @@ nsBrowserAccess.prototype = {
|
|||
isExternal,
|
||||
forceNotRemote,
|
||||
userContextId,
|
||||
openerWindow,
|
||||
aOpenWindowInfo,
|
||||
null,
|
||||
aTriggeringPrincipal,
|
||||
0,
|
||||
"",
|
||||
aCsp,
|
||||
aSkipLoad
|
||||
|
@ -6255,7 +6243,6 @@ nsBrowserAccess.prototype = {
|
|||
aParams,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aNextRemoteTabId,
|
||||
aName
|
||||
) {
|
||||
// Passing a null-URI to only create the content window,
|
||||
|
@ -6266,7 +6253,6 @@ nsBrowserAccess.prototype = {
|
|||
aParams,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aNextRemoteTabId,
|
||||
aName,
|
||||
true
|
||||
);
|
||||
|
@ -6277,7 +6263,6 @@ nsBrowserAccess.prototype = {
|
|||
aParams,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aNextRemoteTabId,
|
||||
aName
|
||||
) {
|
||||
return this.getContentWindowOrOpenURIInFrame(
|
||||
|
@ -6285,7 +6270,6 @@ nsBrowserAccess.prototype = {
|
|||
aParams,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aNextRemoteTabId,
|
||||
aName,
|
||||
false
|
||||
);
|
||||
|
@ -6296,7 +6280,6 @@ nsBrowserAccess.prototype = {
|
|||
aParams,
|
||||
aWhere,
|
||||
aFlags,
|
||||
aNextRemoteTabId,
|
||||
aName,
|
||||
aSkipLoad
|
||||
) {
|
||||
|
@ -6320,10 +6303,9 @@ nsBrowserAccess.prototype = {
|
|||
isExternal,
|
||||
false,
|
||||
userContextId,
|
||||
null,
|
||||
aParams.openWindowInfo,
|
||||
aParams.openerBrowser,
|
||||
aParams.triggeringPrincipal,
|
||||
aNextRemoteTabId,
|
||||
aName,
|
||||
aParams.csp,
|
||||
aSkipLoad
|
||||
|
|
|
@ -322,6 +322,10 @@
|
|||
// Bug 1485961 covers making this more sane.
|
||||
let userContextId = window.arguments && window.arguments[5];
|
||||
|
||||
let openWindowInfo = window.docShell.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIAppWindow).initialOpenWindowInfo;
|
||||
|
||||
let tabArgument = gBrowserInit.getTabToAdopt();
|
||||
|
||||
// We only need sameProcessAsFrameLoader in the case where we're passed a tab
|
||||
|
@ -335,11 +339,13 @@
|
|||
if (tabArgument && tabArgument.linkedBrowser) {
|
||||
remoteType = tabArgument.linkedBrowser.remoteType;
|
||||
sameProcessAsFrameLoader = tabArgument.linkedBrowser.frameLoader;
|
||||
} else if (
|
||||
!gMultiProcessBrowser ||
|
||||
window.hasOpenerForInitialContentBrowser
|
||||
) {
|
||||
remoteType = E10SUtils.NOT_REMOTE;
|
||||
} else if (openWindowInfo) {
|
||||
userContextId = openWindowInfo.originAttributes.userContextId;
|
||||
if (openWindowInfo.isRemote) {
|
||||
remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||
} else {
|
||||
remoteType = E10SUtils.NOT_REMOTE;
|
||||
}
|
||||
} else {
|
||||
let uriToLoad = gBrowserInit.uriToLoadPromise;
|
||||
if (uriToLoad && Array.isArray(uriToLoad)) {
|
||||
|
@ -370,6 +376,7 @@
|
|||
userContextId,
|
||||
sameProcessAsFrameLoader,
|
||||
remoteType,
|
||||
openWindowInfo,
|
||||
};
|
||||
let browser = this.createBrowser(createOptions);
|
||||
browser.setAttribute("primary", "true");
|
||||
|
@ -1559,10 +1566,9 @@
|
|||
var aSameProcessAsFrameLoader;
|
||||
var aOriginPrincipal;
|
||||
var aOriginStoragePrincipal;
|
||||
var aOpener;
|
||||
var aOpenWindowInfo;
|
||||
var aOpenerBrowser;
|
||||
var aCreateLazyBrowser;
|
||||
var aNextRemoteTabId;
|
||||
var aFocusUrlBar;
|
||||
var aName;
|
||||
var aCsp;
|
||||
|
@ -1590,10 +1596,9 @@
|
|||
aSameProcessAsFrameLoader = params.sameProcessAsFrameLoader;
|
||||
aOriginPrincipal = params.originPrincipal;
|
||||
aOriginStoragePrincipal = params.originStoragePrincipal;
|
||||
aOpener = params.opener;
|
||||
aOpenWindowInfo = params.openWindowInfo;
|
||||
aOpenerBrowser = params.openerBrowser;
|
||||
aCreateLazyBrowser = params.createLazyBrowser;
|
||||
aNextRemoteTabId = params.nextRemoteTabId;
|
||||
aFocusUrlBar = params.focusUrlBar;
|
||||
aName = params.name;
|
||||
aCsp = params.csp;
|
||||
|
@ -1632,9 +1637,8 @@
|
|||
originPrincipal: aOriginPrincipal,
|
||||
originStoragePrincipal: aOriginStoragePrincipal,
|
||||
sameProcessAsFrameLoader: aSameProcessAsFrameLoader,
|
||||
opener: aOpener,
|
||||
openWindowInfo: aOpenWindowInfo,
|
||||
openerBrowser: aOpenerBrowser,
|
||||
nextRemoteTabId: aNextRemoteTabId,
|
||||
focusUrlBar: aFocusUrlBar,
|
||||
name: aName,
|
||||
csp: aCsp,
|
||||
|
@ -1883,12 +1887,6 @@
|
|||
aBrowser.sameProcessAsFrameLoader = oldSameProcessAsFrameLoader;
|
||||
}
|
||||
|
||||
if (opener) {
|
||||
// Set the opener window on the browser, such that when the frame
|
||||
// loader is created the opener is set correctly.
|
||||
aBrowser.presetOpenerWindow(opener);
|
||||
}
|
||||
|
||||
// Note that this block is also affected by the
|
||||
// rebuild_frameloaders_on_remoteness_change pref. If the pref is set to
|
||||
// false, this attribute change is observed by browser-custom-element,
|
||||
|
@ -2052,8 +2050,7 @@
|
|||
createBrowser({
|
||||
isPreloadBrowser,
|
||||
name,
|
||||
nextRemoteTabId,
|
||||
openerWindow,
|
||||
openWindowInfo,
|
||||
remoteType,
|
||||
sameProcessAsFrameLoader,
|
||||
uriIsAboutBlank,
|
||||
|
@ -2088,13 +2085,6 @@
|
|||
b.setAttribute("remote", "true");
|
||||
}
|
||||
|
||||
if (openerWindow) {
|
||||
if (remoteType) {
|
||||
throw new Error("Cannot set opener window on a remote browser!");
|
||||
}
|
||||
b.presetOpenerWindow(openerWindow);
|
||||
}
|
||||
|
||||
if (!isPreloadBrowser) {
|
||||
b.setAttribute("autocompletepopup", "PopupAutoComplete");
|
||||
}
|
||||
|
@ -2121,18 +2111,15 @@
|
|||
b.setAttribute("preloadedState", "preloaded");
|
||||
}
|
||||
|
||||
if (nextRemoteTabId) {
|
||||
if (!remoteType) {
|
||||
throw new Error("Cannot have nextRemoteTabId without a remoteType");
|
||||
}
|
||||
// Gecko is going to read this attribute and use it.
|
||||
b.setAttribute("nextRemoteTabId", nextRemoteTabId.toString());
|
||||
}
|
||||
|
||||
if (sameProcessAsFrameLoader) {
|
||||
b.sameProcessAsFrameLoader = sameProcessAsFrameLoader;
|
||||
}
|
||||
|
||||
// Propagate information about the opening content window to the browser.
|
||||
if (openWindowInfo) {
|
||||
b.openWindowInfo = openWindowInfo;
|
||||
}
|
||||
|
||||
// This will be used by gecko to control the name of the opened
|
||||
// window.
|
||||
if (name) {
|
||||
|
@ -2522,9 +2509,8 @@
|
|||
index,
|
||||
lazyTabTitle,
|
||||
name,
|
||||
nextRemoteTabId,
|
||||
noInitialLabel,
|
||||
opener,
|
||||
openWindowInfo,
|
||||
openerBrowser,
|
||||
originPrincipal,
|
||||
originStoragePrincipal,
|
||||
|
@ -2718,8 +2704,7 @@
|
|||
uriIsAboutBlank,
|
||||
userContextId,
|
||||
sameProcessAsFrameLoader,
|
||||
openerWindow: opener,
|
||||
nextRemoteTabId,
|
||||
openWindowInfo,
|
||||
name,
|
||||
skipLoad,
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче