From b13c376d17543af3b248d86115517159883aa151 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Fri, 9 May 2003 01:42:13 +0000 Subject: [PATCH] Fixing bug 194994. Make sure hidden iframes' die when leaving the page. r=bugmail@sicking.cc, sr=peterv@netscape.com, a=asa@mozilla.org git-svn-id: svn://10.0.0.236/trunk@142254 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsFrameLoader.cpp | 9 +++++++-- .../content/html/content/src/nsHTMLIFrameElement.cpp | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mozilla/content/base/src/nsFrameLoader.cpp b/mozilla/content/base/src/nsFrameLoader.cpp index f0e8767a2aa..87d68540bb1 100644 --- a/mozilla/content/base/src/nsFrameLoader.cpp +++ b/mozilla/content/base/src/nsFrameLoader.cpp @@ -234,8 +234,13 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell) { *aDocShell = nsnull; - nsresult rv = EnsureDocShell(); - NS_ENSURE_SUCCESS(rv, rv); + // If we have an owner, make sure we have a docshell and return + // that. If not, we're most likely in the middle of being torn down, + // then we just return null. + if (mOwnerContent) { + nsresult rv = EnsureDocShell(); + NS_ENSURE_SUCCESS(rv, rv); + } *aDocShell = mDocShell; NS_IF_ADDREF(*aDocShell); diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp index 036bf5598f4..a0e6017f993 100644 --- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -357,10 +357,20 @@ nsHTMLIFrameElement::SetDocument(nsIDocument *aDocument, PRBool aDeep, aCompileEventHandlers); NS_ENSURE_SUCCESS(rv, rv); + if (!aDocument && mFrameLoader) { + // This iframe is being taken out of the document, destroy the + // iframe's frame loader (doing that will tear down the window in + // this iframe). + + mFrameLoader->Destroy(); + + mFrameLoader = nsnull; + } + // When document is being set to null on the element's destruction, // or when the document is being set to what the document already // is, do not call LoadSrc(). - if (!mParent || !mDocument || aDocument == old_doc) { + if (!mParent || !aDocument || aDocument == old_doc) { return NS_OK; }