Bug 1535388: Don't fire PageShow from nsDocumentViewer::LoadComplete, if onload caused a new viewer to replace us. r=bzbarsky

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2019-03-22 06:16:14 +00:00
Родитель 3cd07d3160
Коммит c3b4d76ce6
3 изменённых файлов: 27 добавлений и 2 удалений

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

@ -0,0 +1,18 @@
<html>
<head>
<script>
function start () {
document.location.assign('abc')
SpecialPowers.forceGC()
SpecialPowers.forceCC()
const XHR = new XMLHttpRequest()
XHR.open('GET', 'data:text/html,1', false)
XHR.send()
}
window.addEventListener('load', start)
</script>
</head>
<body>
<svg></svg>
</body>
</html>

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

@ -60,3 +60,4 @@ load 1375596-1.svg
load 1402547-1.html
load 1411963-1.html
load 1413319-1.html
load 1535388-1.html

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

@ -1116,8 +1116,14 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) {
// Notify the document that it has been shown (regardless of whether
// it was just loaded). Note: mDocument may be null now if the above
// firing of onload caused the document to unload.
if (mDocument) {
// firing of onload caused the document to unload. Or, mDocument may not be
// the "current active" document, if the above firing of onload caused our
// docshell to navigate away. NOTE: In this latter scenario, it's likely that
// we fired pagehide (when navigating away) without ever having fired
// pageshow, and that's pretty broken... Fortunately, this should be rare.
// (It requires us to spin the event loop in onload handler, e.g. via sync
// XHR, in order for the navigation-away to happen before onload completes.)
if (mDocument && mDocument->IsCurrentActiveDocument()) {
// Re-get window, since it might have changed during above firing of onload
window = mDocument->GetWindow();
if (window) {