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
This commit is contained in:
joki%netscape.com
1999-07-27 20:51:39 +00:00
parent 51f98f0dad
commit 28053ad905

View File

@@ -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);
}