Bug 1566310 - Nullcheck mWindowGlobalChild prior to notifying it of beforeunload listeners, r=nika

Missed in the 1543251 refactor.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kashav Madan 2019-07-16 18:35:25 +00:00
Родитель ca45889546
Коммит cf7f0e1361
3 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,24 @@
<!doctype html>
<html>
<head>
<script type="text/javascript">
function noop() {}
function crash() {
let div = document.querySelector("div");
let ifr = document.querySelector("iframe");
// We need a reference to the iframe's window from *before* it gets detached.
let win = ifr.contentWindow;
div.appendChild(ifr);
win.addEventListener("beforeunload", noop);
win.removeEventListener("beforeunload", noop);
}
</script>
</head>
<body onload="crash()">
<div></div>
<iframe></iframe>
</body>
</html>

Просмотреть файл

@ -246,6 +246,7 @@ load 1508845.html
load 1516289.html
load 1516560.html
load 1528675.html
load 1566310.html
load structured_clone_container_throws.html
load xhr_empty_datauri.html
load xhr_html_nullresponse.html

Просмотреть файл

@ -6069,7 +6069,7 @@ void nsGlobalWindowInner::EventListenerAdded(nsAtom* aType) {
mHasVRDisplayActivateEvents = true;
}
if (aType == nsGkAtoms::onbeforeunload && mBrowserChild &&
if (aType == nsGkAtoms::onbeforeunload && mWindowGlobalChild &&
(!mDoc || !(mDoc->GetSandboxFlags() & SANDBOXED_MODALS))) {
mWindowGlobalChild->BeforeUnloadAdded();
MOZ_ASSERT(mWindowGlobalChild->BeforeUnloadListeners() > 0);
@ -6091,7 +6091,7 @@ void nsGlobalWindowInner::EventListenerAdded(nsAtom* aType) {
}
void nsGlobalWindowInner::EventListenerRemoved(nsAtom* aType) {
if (aType == nsGkAtoms::onbeforeunload && mBrowserChild &&
if (aType == nsGkAtoms::onbeforeunload && mWindowGlobalChild &&
(!mDoc || !(mDoc->GetSandboxFlags() & SANDBOXED_MODALS))) {
mWindowGlobalChild->BeforeUnloadRemoved();
MOZ_ASSERT(mWindowGlobalChild->BeforeUnloadListeners() >= 0);