Bug 1646609: Don't assert when an inactive/OOP inner window tries to navigate an OOP BrowsingContext. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D81731
This commit is contained in:
Kris Maglione 2020-06-30 22:19:56 +00:00
Родитель 9c264b7cf2
Коммит d646c6cbe9
3 изменённых файлов: 42 добавлений и 6 удалений

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

@ -1578,12 +1578,7 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
win->GetCurrentInnerWindow()->GetWindowGlobalChild()) { win->GetCurrentInnerWindow()->GetWindowGlobalChild()) {
wgc->SendLoadURI(this, aLoadState, aSetNavigating); wgc->SendLoadURI(this, aLoadState, aSetNavigating);
} }
} else { } else if (XRE_IsParentProcess()) {
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
if (!XRE_IsParentProcess()) {
return NS_ERROR_UNEXPECTED;
}
if (Canonical()->LoadInParent(aLoadState, aSetNavigating)) { if (Canonical()->LoadInParent(aLoadState, aSetNavigating)) {
return NS_OK; return NS_OK;
} }
@ -1616,6 +1611,13 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
} }
}); });
} }
} else {
MOZ_DIAGNOSTIC_ASSERT(sourceBC);
if (!sourceBC) {
return NS_ERROR_UNEXPECTED;
}
// If we're in a content process and the source BC is no longer in-process,
// just fail silently.
} }
return NS_OK; return NS_OK;
} }

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

@ -116,6 +116,7 @@ support-files = file_bug675587.html
[test_framedhistoryframes.html] [test_framedhistoryframes.html]
support-files = file_framedhistoryframes.html support-files = file_framedhistoryframes.html
[test_pushState_after_document_open.html] [test_pushState_after_document_open.html]
[test_navigate_after_pagehide.html]
[test_windowedhistoryframes.html] [test_windowedhistoryframes.html]
[test_triggeringprincipal_location_seturi.html] [test_triggeringprincipal_location_seturi.html]
[test_bug1507702.html] [test_bug1507702.html]

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

@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<title>Test for navigation attempts by scripts in inactive inner window</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<iframe src="dummy_page.html" id="iframe"></iframe>
<script>
"use strict";
add_task(async function() {
let iframe = document.getElementById("iframe");
let navigate = iframe.contentWindow.eval(`(function() {
location.href = "/";
})`);
iframe.src = "http://example.com/";
await new Promise(resolve =>
iframe.addEventListener("load", resolve, { once: true })
);
// This should do nothing. But, importantly, it should especially not crash.
navigate();
ok(true, "We didn't crash");
});
</script>
</body>
</html>