зеркало из 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,
|
aIsExternal,
|
||||||
aForceNotRemote = false,
|
aForceNotRemote = false,
|
||||||
aUserContextId = Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
aUserContextId = Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID,
|
||||||
aOpenerWindow = null,
|
aOpenWindowInfo = null,
|
||||||
aOpenerBrowser = null,
|
aOpenerBrowser = null,
|
||||||
aTriggeringPrincipal = null,
|
aTriggeringPrincipal = null,
|
||||||
aNextRemoteTabId = 0,
|
|
||||||
aName = "",
|
aName = "",
|
||||||
aCsp = null,
|
aCsp = null,
|
||||||
aSkipLoad = false
|
aSkipLoad = false
|
||||||
|
@ -6026,9 +6025,8 @@ nsBrowserAccess.prototype = {
|
||||||
fromExternal: aIsExternal,
|
fromExternal: aIsExternal,
|
||||||
inBackground: loadInBackground,
|
inBackground: loadInBackground,
|
||||||
forceNotRemote: aForceNotRemote,
|
forceNotRemote: aForceNotRemote,
|
||||||
opener: aOpenerWindow,
|
openWindowInfo: aOpenWindowInfo,
|
||||||
openerBrowser: aOpenerBrowser,
|
openerBrowser: aOpenerBrowser,
|
||||||
nextRemoteTabId: aNextRemoteTabId,
|
|
||||||
name: aName,
|
name: aName,
|
||||||
csp: aCsp,
|
csp: aCsp,
|
||||||
skipLoad: aSkipLoad,
|
skipLoad: aSkipLoad,
|
||||||
|
@ -6044,7 +6042,7 @@ nsBrowserAccess.prototype = {
|
||||||
|
|
||||||
createContentWindow(
|
createContentWindow(
|
||||||
aURI,
|
aURI,
|
||||||
aOpener,
|
aOpenWindowInfo,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aTriggeringPrincipal,
|
aTriggeringPrincipal,
|
||||||
|
@ -6052,7 +6050,7 @@ nsBrowserAccess.prototype = {
|
||||||
) {
|
) {
|
||||||
return this.getContentWindowOrOpenURI(
|
return this.getContentWindowOrOpenURI(
|
||||||
null,
|
null,
|
||||||
aOpener,
|
aOpenWindowInfo,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aTriggeringPrincipal,
|
aTriggeringPrincipal,
|
||||||
|
@ -6061,14 +6059,14 @@ nsBrowserAccess.prototype = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
openURI(aURI, aOpener, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
|
openURI(aURI, aOpenWindowInfo, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
|
||||||
if (!aURI) {
|
if (!aURI) {
|
||||||
Cu.reportError("openURI should only be called with a valid URI");
|
Cu.reportError("openURI should only be called with a valid URI");
|
||||||
throw Cr.NS_ERROR_FAILURE;
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return this.getContentWindowOrOpenURI(
|
return this.getContentWindowOrOpenURI(
|
||||||
aURI,
|
aURI,
|
||||||
aOpener,
|
aOpenWindowInfo,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aTriggeringPrincipal,
|
aTriggeringPrincipal,
|
||||||
|
@ -6079,29 +6077,19 @@ nsBrowserAccess.prototype = {
|
||||||
|
|
||||||
getContentWindowOrOpenURI(
|
getContentWindowOrOpenURI(
|
||||||
aURI,
|
aURI,
|
||||||
aOpener,
|
aOpenWindowInfo,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aTriggeringPrincipal,
|
aTriggeringPrincipal,
|
||||||
aCsp,
|
aCsp,
|
||||||
aSkipLoad
|
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 browsingContext = null;
|
||||||
var isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
var isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||||
|
|
||||||
if (aOpener && isExternal) {
|
if (aOpenWindowInfo && isExternal) {
|
||||||
Cu.reportError(
|
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."
|
"passed if the context is OPEN_EXTERNAL."
|
||||||
);
|
);
|
||||||
throw Cr.NS_ERROR_FAILURE;
|
throw Cr.NS_ERROR_FAILURE;
|
||||||
|
@ -6130,18 +6118,22 @@ nsBrowserAccess.prototype = {
|
||||||
let referrerInfo;
|
let referrerInfo;
|
||||||
if (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER) {
|
if (aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_REFERRER) {
|
||||||
referrerInfo = new ReferrerInfo(Ci.nsIReferrerInfo.EMPTY, false, null);
|
referrerInfo = new ReferrerInfo(Ci.nsIReferrerInfo.EMPTY, false, null);
|
||||||
} else {
|
} else if (
|
||||||
|
aOpenWindowInfo &&
|
||||||
|
aOpenWindowInfo.parent &&
|
||||||
|
aOpenWindowInfo.parent.window
|
||||||
|
) {
|
||||||
referrerInfo = new ReferrerInfo(
|
referrerInfo = new ReferrerInfo(
|
||||||
aOpener && aOpener.document
|
aOpenWindowInfo.parent.window.document.referrerInfo.referrerPolicy,
|
||||||
? aOpener.document.referrerInfo.referrerPolicy
|
|
||||||
: Ci.nsIReferrerInfo.EMPTY,
|
|
||||||
true,
|
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
|
let isPrivate = aOpenWindowInfo
|
||||||
? PrivateBrowsingUtils.isContentWindowPrivate(aOpener)
|
? aOpenWindowInfo.originAttributes.privateBrowsingId != 0
|
||||||
: PrivateBrowsingUtils.isWindowPrivate(window);
|
: PrivateBrowsingUtils.isWindowPrivate(window);
|
||||||
|
|
||||||
switch (aWhere) {
|
switch (aWhere) {
|
||||||
|
@ -6195,13 +6187,10 @@ nsBrowserAccess.prototype = {
|
||||||
// we can hand back the nsIDOMWindow. The XULBrowserWindow.shouldLoadURI
|
// we can hand back the nsIDOMWindow. The XULBrowserWindow.shouldLoadURI
|
||||||
// will do the job of shuttling off the newly opened browser to run in
|
// will do the job of shuttling off the newly opened browser to run in
|
||||||
// the right process once it starts loading a URI.
|
// the right process once it starts loading a URI.
|
||||||
let forceNotRemote = !!aOpener;
|
let forceNotRemote = aOpenWindowInfo && !aOpenWindowInfo.remote;
|
||||||
let userContextId =
|
let userContextId = aOpenWindowInfo
|
||||||
aOpener && aOpener.document
|
? aOpenWindowInfo.originAttributes.userContextId
|
||||||
? aOpener.document.nodePrincipal.originAttributes.userContextId
|
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
|
||||||
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
|
|
||||||
let openerWindow =
|
|
||||||
aFlags & Ci.nsIBrowserDOMWindow.OPEN_NO_OPENER ? null : aOpener;
|
|
||||||
let browser = this._openURIInNewTab(
|
let browser = this._openURIInNewTab(
|
||||||
aURI,
|
aURI,
|
||||||
referrerInfo,
|
referrerInfo,
|
||||||
|
@ -6209,10 +6198,9 @@ nsBrowserAccess.prototype = {
|
||||||
isExternal,
|
isExternal,
|
||||||
forceNotRemote,
|
forceNotRemote,
|
||||||
userContextId,
|
userContextId,
|
||||||
openerWindow,
|
aOpenWindowInfo,
|
||||||
null,
|
null,
|
||||||
aTriggeringPrincipal,
|
aTriggeringPrincipal,
|
||||||
0,
|
|
||||||
"",
|
"",
|
||||||
aCsp,
|
aCsp,
|
||||||
aSkipLoad
|
aSkipLoad
|
||||||
|
@ -6255,7 +6243,6 @@ nsBrowserAccess.prototype = {
|
||||||
aParams,
|
aParams,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName
|
aName
|
||||||
) {
|
) {
|
||||||
// Passing a null-URI to only create the content window,
|
// Passing a null-URI to only create the content window,
|
||||||
|
@ -6266,7 +6253,6 @@ nsBrowserAccess.prototype = {
|
||||||
aParams,
|
aParams,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName,
|
aName,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -6277,7 +6263,6 @@ nsBrowserAccess.prototype = {
|
||||||
aParams,
|
aParams,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName
|
aName
|
||||||
) {
|
) {
|
||||||
return this.getContentWindowOrOpenURIInFrame(
|
return this.getContentWindowOrOpenURIInFrame(
|
||||||
|
@ -6285,7 +6270,6 @@ nsBrowserAccess.prototype = {
|
||||||
aParams,
|
aParams,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName,
|
aName,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
@ -6296,7 +6280,6 @@ nsBrowserAccess.prototype = {
|
||||||
aParams,
|
aParams,
|
||||||
aWhere,
|
aWhere,
|
||||||
aFlags,
|
aFlags,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName,
|
aName,
|
||||||
aSkipLoad
|
aSkipLoad
|
||||||
) {
|
) {
|
||||||
|
@ -6320,10 +6303,9 @@ nsBrowserAccess.prototype = {
|
||||||
isExternal,
|
isExternal,
|
||||||
false,
|
false,
|
||||||
userContextId,
|
userContextId,
|
||||||
null,
|
aParams.openWindowInfo,
|
||||||
aParams.openerBrowser,
|
aParams.openerBrowser,
|
||||||
aParams.triggeringPrincipal,
|
aParams.triggeringPrincipal,
|
||||||
aNextRemoteTabId,
|
|
||||||
aName,
|
aName,
|
||||||
aParams.csp,
|
aParams.csp,
|
||||||
aSkipLoad
|
aSkipLoad
|
||||||
|
|
|
@ -322,6 +322,10 @@
|
||||||
// Bug 1485961 covers making this more sane.
|
// Bug 1485961 covers making this more sane.
|
||||||
let userContextId = window.arguments && window.arguments[5];
|
let userContextId = window.arguments && window.arguments[5];
|
||||||
|
|
||||||
|
let openWindowInfo = window.docShell.treeOwner
|
||||||
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIAppWindow).initialOpenWindowInfo;
|
||||||
|
|
||||||
let tabArgument = gBrowserInit.getTabToAdopt();
|
let tabArgument = gBrowserInit.getTabToAdopt();
|
||||||
|
|
||||||
// We only need sameProcessAsFrameLoader in the case where we're passed a tab
|
// We only need sameProcessAsFrameLoader in the case where we're passed a tab
|
||||||
|
@ -335,11 +339,13 @@
|
||||||
if (tabArgument && tabArgument.linkedBrowser) {
|
if (tabArgument && tabArgument.linkedBrowser) {
|
||||||
remoteType = tabArgument.linkedBrowser.remoteType;
|
remoteType = tabArgument.linkedBrowser.remoteType;
|
||||||
sameProcessAsFrameLoader = tabArgument.linkedBrowser.frameLoader;
|
sameProcessAsFrameLoader = tabArgument.linkedBrowser.frameLoader;
|
||||||
} else if (
|
} else if (openWindowInfo) {
|
||||||
!gMultiProcessBrowser ||
|
userContextId = openWindowInfo.originAttributes.userContextId;
|
||||||
window.hasOpenerForInitialContentBrowser
|
if (openWindowInfo.isRemote) {
|
||||||
) {
|
remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||||
remoteType = E10SUtils.NOT_REMOTE;
|
} else {
|
||||||
|
remoteType = E10SUtils.NOT_REMOTE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let uriToLoad = gBrowserInit.uriToLoadPromise;
|
let uriToLoad = gBrowserInit.uriToLoadPromise;
|
||||||
if (uriToLoad && Array.isArray(uriToLoad)) {
|
if (uriToLoad && Array.isArray(uriToLoad)) {
|
||||||
|
@ -370,6 +376,7 @@
|
||||||
userContextId,
|
userContextId,
|
||||||
sameProcessAsFrameLoader,
|
sameProcessAsFrameLoader,
|
||||||
remoteType,
|
remoteType,
|
||||||
|
openWindowInfo,
|
||||||
};
|
};
|
||||||
let browser = this.createBrowser(createOptions);
|
let browser = this.createBrowser(createOptions);
|
||||||
browser.setAttribute("primary", "true");
|
browser.setAttribute("primary", "true");
|
||||||
|
@ -1559,10 +1566,9 @@
|
||||||
var aSameProcessAsFrameLoader;
|
var aSameProcessAsFrameLoader;
|
||||||
var aOriginPrincipal;
|
var aOriginPrincipal;
|
||||||
var aOriginStoragePrincipal;
|
var aOriginStoragePrincipal;
|
||||||
var aOpener;
|
var aOpenWindowInfo;
|
||||||
var aOpenerBrowser;
|
var aOpenerBrowser;
|
||||||
var aCreateLazyBrowser;
|
var aCreateLazyBrowser;
|
||||||
var aNextRemoteTabId;
|
|
||||||
var aFocusUrlBar;
|
var aFocusUrlBar;
|
||||||
var aName;
|
var aName;
|
||||||
var aCsp;
|
var aCsp;
|
||||||
|
@ -1590,10 +1596,9 @@
|
||||||
aSameProcessAsFrameLoader = params.sameProcessAsFrameLoader;
|
aSameProcessAsFrameLoader = params.sameProcessAsFrameLoader;
|
||||||
aOriginPrincipal = params.originPrincipal;
|
aOriginPrincipal = params.originPrincipal;
|
||||||
aOriginStoragePrincipal = params.originStoragePrincipal;
|
aOriginStoragePrincipal = params.originStoragePrincipal;
|
||||||
aOpener = params.opener;
|
aOpenWindowInfo = params.openWindowInfo;
|
||||||
aOpenerBrowser = params.openerBrowser;
|
aOpenerBrowser = params.openerBrowser;
|
||||||
aCreateLazyBrowser = params.createLazyBrowser;
|
aCreateLazyBrowser = params.createLazyBrowser;
|
||||||
aNextRemoteTabId = params.nextRemoteTabId;
|
|
||||||
aFocusUrlBar = params.focusUrlBar;
|
aFocusUrlBar = params.focusUrlBar;
|
||||||
aName = params.name;
|
aName = params.name;
|
||||||
aCsp = params.csp;
|
aCsp = params.csp;
|
||||||
|
@ -1632,9 +1637,8 @@
|
||||||
originPrincipal: aOriginPrincipal,
|
originPrincipal: aOriginPrincipal,
|
||||||
originStoragePrincipal: aOriginStoragePrincipal,
|
originStoragePrincipal: aOriginStoragePrincipal,
|
||||||
sameProcessAsFrameLoader: aSameProcessAsFrameLoader,
|
sameProcessAsFrameLoader: aSameProcessAsFrameLoader,
|
||||||
opener: aOpener,
|
openWindowInfo: aOpenWindowInfo,
|
||||||
openerBrowser: aOpenerBrowser,
|
openerBrowser: aOpenerBrowser,
|
||||||
nextRemoteTabId: aNextRemoteTabId,
|
|
||||||
focusUrlBar: aFocusUrlBar,
|
focusUrlBar: aFocusUrlBar,
|
||||||
name: aName,
|
name: aName,
|
||||||
csp: aCsp,
|
csp: aCsp,
|
||||||
|
@ -1883,12 +1887,6 @@
|
||||||
aBrowser.sameProcessAsFrameLoader = oldSameProcessAsFrameLoader;
|
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
|
// Note that this block is also affected by the
|
||||||
// rebuild_frameloaders_on_remoteness_change pref. If the pref is set to
|
// rebuild_frameloaders_on_remoteness_change pref. If the pref is set to
|
||||||
// false, this attribute change is observed by browser-custom-element,
|
// false, this attribute change is observed by browser-custom-element,
|
||||||
|
@ -2052,8 +2050,7 @@
|
||||||
createBrowser({
|
createBrowser({
|
||||||
isPreloadBrowser,
|
isPreloadBrowser,
|
||||||
name,
|
name,
|
||||||
nextRemoteTabId,
|
openWindowInfo,
|
||||||
openerWindow,
|
|
||||||
remoteType,
|
remoteType,
|
||||||
sameProcessAsFrameLoader,
|
sameProcessAsFrameLoader,
|
||||||
uriIsAboutBlank,
|
uriIsAboutBlank,
|
||||||
|
@ -2088,13 +2085,6 @@
|
||||||
b.setAttribute("remote", "true");
|
b.setAttribute("remote", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openerWindow) {
|
|
||||||
if (remoteType) {
|
|
||||||
throw new Error("Cannot set opener window on a remote browser!");
|
|
||||||
}
|
|
||||||
b.presetOpenerWindow(openerWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isPreloadBrowser) {
|
if (!isPreloadBrowser) {
|
||||||
b.setAttribute("autocompletepopup", "PopupAutoComplete");
|
b.setAttribute("autocompletepopup", "PopupAutoComplete");
|
||||||
}
|
}
|
||||||
|
@ -2121,18 +2111,15 @@
|
||||||
b.setAttribute("preloadedState", "preloaded");
|
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) {
|
if (sameProcessAsFrameLoader) {
|
||||||
b.sameProcessAsFrameLoader = 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
|
// This will be used by gecko to control the name of the opened
|
||||||
// window.
|
// window.
|
||||||
if (name) {
|
if (name) {
|
||||||
|
@ -2522,9 +2509,8 @@
|
||||||
index,
|
index,
|
||||||
lazyTabTitle,
|
lazyTabTitle,
|
||||||
name,
|
name,
|
||||||
nextRemoteTabId,
|
|
||||||
noInitialLabel,
|
noInitialLabel,
|
||||||
opener,
|
openWindowInfo,
|
||||||
openerBrowser,
|
openerBrowser,
|
||||||
originPrincipal,
|
originPrincipal,
|
||||||
originStoragePrincipal,
|
originStoragePrincipal,
|
||||||
|
@ -2718,8 +2704,7 @@
|
||||||
uriIsAboutBlank,
|
uriIsAboutBlank,
|
||||||
userContextId,
|
userContextId,
|
||||||
sameProcessAsFrameLoader,
|
sameProcessAsFrameLoader,
|
||||||
openerWindow: opener,
|
openWindowInfo,
|
||||||
nextRemoteTabId,
|
|
||||||
name,
|
name,
|
||||||
skipLoad,
|
skipLoad,
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче