Skip to content

Commit

Permalink
Bug 1667491: Fix null pointer deref. r=nika
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaglione committed Sep 29, 2020
1 parent e3e31da commit c95f8d2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
32 changes: 32 additions & 0 deletions docshell/base/crashtests/1667491.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="UTF-8">
<script>
function go() {
const HTML = `
<script>
function go() {
document.body.appendChild(a)
window.frames[0].onbeforeunload = document.createElement("body").onload;
window.requestIdleCallback(() => {
window.close();
finish();
});
}
<\/script>
<body onload="go()">
<iframe id="a"></iframe>
<iframe></iframe>
`;

let win = window.open(`data:text/html,${encodeURIComponent(HTML)}`);
win.finish = function() {
document.documentElement.removeAttribute("class");
};
}
</script>
</head>
<body onload="go()">
</body>
</html>
1 change: 1 addition & 0 deletions docshell/base/crashtests/crashtests.list
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ load 1341657.html
load 1584467.html
load 1614211-1.html
load 1617315-1.html
pref(dom.disable_open_during_load,false) pref(security.data_uri.unique_opaque_origin,false) pref(security.data_uri.block_toplevel_data_uri_navigations,false) load 1667491.html
16 changes: 8 additions & 8 deletions layout/base/nsDocumentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,18 +1223,18 @@ nsDocumentViewer::PermitUnload(PermitUnloadAction aAction,
bool foundBlocker = false;
bool foundOOPListener = false;
bc->PreOrderWalk([&](BrowsingContext* aBC) {
if (aBC->IsInProcess()) {
nsCOMPtr<nsIContentViewer> contentViewer;
aBC->GetDocShell()->GetContentViewer(getter_AddRefs(contentViewer));
if (contentViewer &&
contentViewer->DispatchBeforeUnload() == eRequestBlockNavigation) {
foundBlocker = true;
}
} else {
if (!aBC->IsInProcess()) {
WindowContext* wc = aBC->GetCurrentWindowContext();
if (wc && wc->HasBeforeUnload()) {
foundOOPListener = true;
}
} else if (aBC->GetDocShell()) {
nsCOMPtr<nsIContentViewer> contentViewer(
aBC->GetDocShell()->GetContentViewer());
if (contentViewer &&
contentViewer->DispatchBeforeUnload() == eRequestBlockNavigation) {
foundBlocker = true;
}
}
});

Expand Down

0 comments on commit c95f8d2

Please sign in to comment.