From a69f8cc71bd1c56d651a76fed02f12a464b9610b Mon Sep 17 00:00:00 2001 From: Kashav Madan Date: Thu, 25 Mar 2021 15:59:50 +0000 Subject: [PATCH] Bug 1700719 - Discard-check both the top-level and current context before restoring, r=nika Differential Revision: https://phabricator.services.mozilla.com/D109722 --- docshell/base/CanonicalBrowsingContext.cpp | 2 ++ dom/ipc/WindowGlobalParent.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index 9fc299b21358..91d5fe9c963c 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -1745,6 +1745,8 @@ void CanonicalBrowsingContext::SetRestoreData(SessionStoreRestoreData* aData) { void CanonicalBrowsingContext::RequestRestoreTabContent( WindowGlobalParent* aWindow) { + MOZ_DIAGNOSTIC_ASSERT(IsTop()); + if (IsDiscarded() || !mRestoreData || mRestoreData->IsEmpty()) { return; } diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 80642ffaee2f..bcc832f14be0 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -1294,9 +1294,9 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvResetSessionStore( } mozilla::ipc::IPCResult WindowGlobalParent::RecvRequestRestoreTabContent() { - CanonicalBrowsingContext* bc = BrowsingContext()->Top(); - if (bc && !bc->IsDiscarded()) { - bc->RequestRestoreTabContent(this); + CanonicalBrowsingContext* bc = BrowsingContext(); + if (bc && bc->AncestorsAreCurrent()) { + bc->Top()->RequestRestoreTabContent(this); } return IPC_OK(); }