Bug 761448, be more strict when to allow docshell loads, r=bz, a=akeybl
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 08 Jan 2013 19:12:41 +0200
changeset 127305 b88a7f9585925d6912a857ca47e6dfe692e4c442
parent 127304 13a8dd1531dab6687b5e9c1ebd76e9aa59144fe2
child 127306 0abbd04b2dc9948db8a523aab4498dbda3263ebe
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, akeybl
bugs761448
milestone20.0a2
Bug 761448, be more strict when to allow docshell loads, r=bz, a=akeybl
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8689,16 +8689,18 @@ nsDocShell::InternalLoad(nsIURI * aURI,
     //
     // Load is being targetted at this docshell so return an error if the
     // docshell is in the process of being destroyed.
     //
     if (mIsBeingDestroyed) {
         return NS_ERROR_FAILURE;
     }
 
+    NS_ENSURE_STATE(!HasUnloadedParent());
+
     rv = CheckLoadingPermissions();
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     // If this docshell is owned by a frameloader, make sure to cancel
     // possible frameloader initialization before loading a new page.
     nsCOMPtr<nsIDocShellTreeItem> parent;
@@ -12476,8 +12478,28 @@ nsDocShell::GetAsyncPanZoomEnabled(bool*
 {
     if (TabChild* tabChild = GetTabChildFrom(this)) {
         *aOut = tabChild->IsAsyncPanZoomEnabled();
         return NS_OK;
     }
     *aOut = false;
     return NS_OK;
 }
+
+bool
+nsDocShell::HasUnloadedParent()
+{
+    nsCOMPtr<nsIDocShellTreeItem> currentTreeItem = this;
+    while (currentTreeItem) {
+        nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
+        currentTreeItem->GetParent(getter_AddRefs(parentTreeItem));
+        nsCOMPtr<nsIDocShell> parent = do_QueryInterface(parentTreeItem);
+        if (parent) {
+            bool inUnload = false;
+            parent->GetIsInUnload(&inUnload);
+            if (inUnload) {
+                return true;
+            }
+        }
+        currentTreeItem.swap(parentTreeItem);
+    }
+    return false;
+}
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -670,16 +670,18 @@ protected:
     enum FrameType {
         eFrameTypeRegular,
         eFrameTypeBrowser,
         eFrameTypeApp
     };
 
     FrameType GetInheritedFrameType();
 
+    bool HasUnloadedParent();
+
     // hash of session storages, keyed by domain
     nsInterfaceHashtable<nsCStringHashKey, nsIDOMStorage> mStorages;
 
     // Dimensions of the docshell
     nsIntRect                  mBounds;
     nsString                   mName;
     nsString                   mTitle;