Bug 1560313 - Add some null checks for GetDOMWindow() in ContentChild. r=farre

I couldn't reproduce the crash, but there are a few places in
ContentChild where we grab a window off of a BC without checking if
the window exists, so I added null checks.

Differential Revision: https://phabricator.services.mozilla.com/D35692

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-06-26 12:54:47 +00:00
parent de6d72c152
commit 004af4ef64

View File

@ -3931,6 +3931,13 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowClose(BrowsingContext* aContext,
}
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
if (!window) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ChildIPC: Trying to send a message to a context without a window"));
return IPC_OK();
}
nsGlobalWindowOuter::Cast(window)->CloseOuter(aTrustedCaller);
return IPC_OK();
}
@ -3944,6 +3951,12 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowFocus(
}
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
if (!window) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ChildIPC: Trying to send a message to a context without a window"));
return IPC_OK();
}
nsGlobalWindowOuter::Cast(window)->FocusOuter();
return IPC_OK();
}
@ -3957,6 +3970,12 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowBlur(
}
nsCOMPtr<nsPIDOMWindowOuter> window = aContext->GetDOMWindow();
if (!window) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ChildIPC: Trying to send a message to a context without a window"));
return IPC_OK();
}
nsGlobalWindowOuter::Cast(window)->BlurOuter();
return IPC_OK();
}
@ -3972,6 +3991,13 @@ mozilla::ipc::IPCResult ContentChild::RecvWindowPostMessage(
RefPtr<nsGlobalWindowOuter> window =
nsGlobalWindowOuter::Cast(aContext->GetDOMWindow());
if (!window) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ChildIPC: Trying to send a message to a context without a window"));
return IPC_OK();
}
nsCOMPtr<nsIPrincipal> providedPrincipal;
if (!window->GetPrincipalForPostMessage(
aData.targetOrigin(), aData.targetOriginURI(),