From 06af3cb460bcd60546335f63e4e4ea0661e39272 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 8 Jan 2013 19:12:41 +0200 Subject: [PATCH] Bug 761448, be more strict when to allow docshell loads, r=bz, a=akeybl --- docshell/base/nsDocShell.cpp | 22 ++++++++++++++++++++++ docshell/base/nsDocShell.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f4f10dabb37..73402ebc124 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -8651,6 +8651,8 @@ nsDocShell::InternalLoad(nsIURI * aURI, return NS_ERROR_FAILURE; } + NS_ENSURE_STATE(!HasUnloadedParent()); + rv = CheckLoadingPermissions(); if (NS_FAILED(rv)) { return rv; @@ -12440,3 +12442,23 @@ nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) *aOut = false; return NS_OK; } + +bool +nsDocShell::HasUnloadedParent() +{ + nsCOMPtr currentTreeItem = this; + while (currentTreeItem) { + nsCOMPtr parentTreeItem; + currentTreeItem->GetParent(getter_AddRefs(parentTreeItem)); + nsCOMPtr parent = do_QueryInterface(parentTreeItem); + if (parent) { + bool inUnload = false; + parent->GetIsInUnload(&inUnload); + if (inUnload) { + return true; + } + } + currentTreeItem.swap(parentTreeItem); + } + return false; +} diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 383cf2c5655..9ff0d494f24 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -675,6 +675,8 @@ protected: FrameType GetInheritedFrameType(); + bool HasUnloadedParent(); + // hash of session storages, keyed by domain nsInterfaceHashtable mStorages;