зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1562264 - Propagate remote/fission flags from parent to child for content window.open() calls, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D40836 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
315c6b5efc
Коммит
05d450499e
|
@ -4696,11 +4696,10 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
|
|||
|
||||
{
|
||||
// The content process should never be in charge of computing whether or
|
||||
// not a window should be private or remote - the parent will do that.
|
||||
// not a window should be private - the parent will do that.
|
||||
const uint32_t badFlags = nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME |
|
||||
nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
|
||||
if (!!(aChromeFlags & badFlags)) {
|
||||
return IPC_FAIL(this, "Forbidden aChromeFlags passed");
|
||||
}
|
||||
|
@ -4709,6 +4708,20 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
|
|||
BrowserHost* thisBrowserHost =
|
||||
thisBrowserParent ? thisBrowserParent->GetBrowserHost() : nullptr;
|
||||
MOZ_ASSERT(!thisBrowserParent == !thisBrowserHost);
|
||||
|
||||
// The content process should not have set its remote or fission flags if the
|
||||
// parent doesn't also have these set.
|
||||
if (thisBrowserHost) {
|
||||
nsCOMPtr<nsILoadContext> context = thisBrowserHost->GetLoadContext();
|
||||
|
||||
if (context->UseRemoteTabs() !=
|
||||
!!(aChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW) ||
|
||||
context->UseRemoteSubframes() !=
|
||||
!!(aChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW)) {
|
||||
return IPC_FAIL(this, "Unexpected aChromeFlags passed");
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> frame;
|
||||
if (thisBrowserParent) {
|
||||
frame = thisBrowserParent->GetOwnerElement();
|
||||
|
|
|
@ -691,6 +691,20 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
|||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
|
||||
}
|
||||
|
||||
// Propagate the remote & fission status of the parent window, if available,
|
||||
// to the child.
|
||||
if (parentWindow) {
|
||||
auto* docShell = nsDocShell::Cast(parentWindow->GetDocShell());
|
||||
|
||||
if (docShell->UseRemoteTabs()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
|
||||
}
|
||||
|
||||
if (docShell->UseRemoteSubframes()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_FISSION_WINDOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SizeSpec sizeSpec;
|
||||
|
@ -2472,6 +2486,7 @@ int32_t nsWindowWatcher::GetWindowOpenLocation(nsPIDOMWindowOuter* aParent,
|
|||
// which might have been automatically flipped by Gecko.
|
||||
int32_t uiChromeFlags = aChromeFlags;
|
||||
uiChromeFlags &= ~(nsIWebBrowserChrome::CHROME_REMOTE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_FISSION_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW |
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
|
||||
|
|
|
@ -282,9 +282,17 @@ add_task(async function test_new_remote_window_flags() {
|
|||
// as part of the BrowserChild, so we have to check those too.
|
||||
let contentChromeFlags = await getContentChromeFlags(win);
|
||||
assertContentFlags(contentChromeFlags);
|
||||
Assert.ok(
|
||||
!(contentChromeFlags & Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW),
|
||||
"Should not be remote in the content process."
|
||||
|
||||
Assert.equal(
|
||||
parentChromeFlags & Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW,
|
||||
contentChromeFlags & Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW,
|
||||
"Should have matching remote value in parent and content"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
parentChromeFlags & Ci.nsIWebBrowserChrome.CHROME_FISSION_WINDOW,
|
||||
contentChromeFlags & Ci.nsIWebBrowserChrome.CHROME_FISSION_WINDOW,
|
||||
"Should have matching fission value in parent and content"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
|
|
Загрузка…
Ссылка в новой задаче