diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index a464e3a6a1c6..203825a2a2de 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -12509,14 +12509,20 @@ nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) { } bool nsDocShell::HasUnloadedParent() { - RefPtr parent = GetInProcessParentDocshell(); - while (parent) { - bool inUnload = false; - parent->GetIsInUnload(&inUnload); - if (inUnload) { + for (WindowContext* wc = GetBrowsingContext()->GetParentWindowContext(); wc; + wc->GetParentWindowContext()) { + if (wc->IsCached() || wc->IsDiscarded() || + wc->GetBrowsingContext()->IsDiscarded()) { + // If a parent is OOP and the parent WindowContext is no + // longer current, we can assume the parent was unloaded. + return true; + } + + if (wc->GetBrowsingContext()->IsInProcess() && + (!wc->GetBrowsingContext()->GetDocShell() || + wc->GetBrowsingContext()->GetDocShell()->GetIsInUnload())) { return true; } - parent = parent->GetInProcessParentDocshell(); } return false; } diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 62c42876e063..763b73649e85 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -460,7 +460,7 @@ interface nsIDocShell : nsIDocShellTreeItem * Find out whether the docshell is currently in the middle of a page * transition. This is set just before the pagehide/unload events fire. */ - readonly attribute boolean isInUnload; + [infallible] readonly attribute boolean isInUnload; /** * Disconnects this docshell's editor from its window, and stores the