From 28053ad90541e160cd2db18c4e17ea35f4f60d75 Mon Sep 17 00:00:00 2001 From: "joki%netscape.com" Date: Tue, 27 Jul 1999 20:51:39 +0000 Subject: [PATCH] Stop calling JS_ClearScope (and related methods) when leaving about:blank page. git-svn-id: svn://10.0.0.236/trunk@41314 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/base/nsGlobalWindow.cpp | 50 ++++++++++++++++++++----- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 1623c167069..8cdff03dfd7 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -281,24 +281,54 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument) return; } - ClearAllTimeouts(); + if (mDocument) { + nsIDocument* doc; + nsIURI* docURL = 0; + + if (mDocument && NS_SUCCEEDED(mDocument->QueryInterface(kIDocumentIID, (void**)&doc))) { + docURL = doc->GetDocumentURL(); + NS_RELEASE(doc); + } + + if (docURL) { +#ifdef NECKO + char* str; + docURL->GetSpec(&str); +#else + PRUnichar* str; + docURL->ToString(&str); +#endif + nsAutoString url = str; + + //about:blank URL's do not have ClearScope called on page change. + if (url != "about:blank") { + ClearAllTimeouts(); - if (mListenerManager) { - mListenerManager->RemoveAllListeners(); + if (mListenerManager) { + mListenerManager->RemoveAllListeners(); + } + + if ((nsnull != mScriptObject) && + (nsnull != mContext) /* && + (nsnull != aDocument) XXXbe why commented out? */ ) { + JS_ClearScope((JSContext *)mContext->GetNativeContext(), + (JSObject *)mScriptObject); + } + } +#ifdef NECKO + nsCRT::free(str); +#else + delete[] str; +#endif + } } + //XXX Should this be outside the about:blank clearscope exception? if (mPrincipals && mContext) { JSPRINCIPALS_DROP((JSContext *)mContext->GetNativeContext(), mPrincipals); mPrincipals = nsnull; } - if ((nsnull != mScriptObject) && - (nsnull != mContext) /* && - (nsnull != aDocument) XXXbe why commented out? */ ) { - JS_ClearScope((JSContext *)mContext->GetNativeContext(), - (JSObject *)mScriptObject); - } - if (nsnull != mDocument) { NS_RELEASE(mDocument); }