Fix bug 214874. Script should not execute while innerHTML is being set.

r+sr=jst, a=dveditz
This commit is contained in:
bzbarsky%mit.edu 2003-08-11 18:13:16 +00:00
Родитель d62eec97b3
Коммит 2120752cbd
1 изменённых файлов: 20 добавлений и 3 удалений

Просмотреть файл

@ -324,11 +324,30 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement,
aObserver);
}
// If scripts aren't enabled there's no point in going on.
// Check whether we should be executing scripts at all for this document
if (!mDocument->IsScriptEnabled()) {
return FireErrorNotification(NS_ERROR_NOT_AVAILABLE, aElement, aObserver);
}
// Script evaluation can also be disabled in the current script
// context even though it's enabled in the document.
nsCOMPtr<nsIScriptGlobalObject> globalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
if (globalObject)
{
nsCOMPtr<nsIScriptContext> context;
if (NS_SUCCEEDED(globalObject->GetContext(getter_AddRefs(context)))
&& context) {
PRBool scriptsEnabled = PR_TRUE;
context->GetScriptsEnabled(&scriptsEnabled);
// If scripts aren't enabled in the current context, there's no
// point in going on.
if (!scriptsEnabled) {
return FireErrorNotification(NS_ERROR_NOT_AVAILABLE, aElement, aObserver);
}
}
}
PRBool isJavaScript = PR_TRUE;
const char* jsVersionString = nsnull;
nsAutoString language, type, src;
@ -409,8 +428,6 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement,
return FireErrorNotification(rv, aElement, aObserver);
}
nsCOMPtr<nsIScriptGlobalObject> globalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
// After the security manager, the content-policy stuff gets a veto
if (globalObject) {
nsCOMPtr<nsIDOMWindow> domWin(do_QueryInterface(globalObject));