зеркало из https://github.com/mozilla/pjs.git
Fix issues with ScriptAvailable() not firing for some scripts. Bug 214081, r+sr=jst
This commit is contained in:
Родитель
140c6a5314
Коммит
db19c4b681
|
@ -324,20 +324,8 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement,
|
|||
aObserver);
|
||||
}
|
||||
|
||||
// See if script evaluation is enabled.
|
||||
PRBool scriptsEnabled = PR_TRUE;
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
if (globalObject)
|
||||
{
|
||||
nsCOMPtr<nsIScriptContext> context;
|
||||
if (NS_SUCCEEDED(globalObject->GetContext(getter_AddRefs(context)))
|
||||
&& context)
|
||||
context->GetScriptsEnabled(&scriptsEnabled);
|
||||
}
|
||||
|
||||
// If scripts aren't enabled there's no point in going on.
|
||||
if (!scriptsEnabled) {
|
||||
if (!mDocument->IsScriptEnabled()) {
|
||||
return FireErrorNotification(NS_ERROR_NOT_AVAILABLE, aElement, aObserver);
|
||||
}
|
||||
|
||||
|
@ -421,6 +409,8 @@ 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));
|
||||
|
|
|
@ -645,8 +645,7 @@ nsHTMLScriptElement::GetLineNumber(PRUint32* aLineNumber)
|
|||
void
|
||||
nsHTMLScriptElement::MaybeProcessScript()
|
||||
{
|
||||
if (mIsEvaluated || mEvaluating || !mDocument || !mParent ||
|
||||
!mDocument->IsScriptEnabled()) {
|
||||
if (mIsEvaluated || mEvaluating || !mDocument || !mParent) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5518,7 +5518,7 @@ HTMLContentSink::ScriptAvailable(nsresult aResult,
|
|||
// Mark the current script as loaded
|
||||
mNeedToBlockParser = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(aResult)) {
|
||||
if (NS_SUCCEEDED(aResult) && aResult != NS_CONTENT_SCRIPT_IS_EVENTHANDLER) {
|
||||
PreEvaluateScript();
|
||||
} else {
|
||||
mScriptElements->RemoveElementAt(count - 1);
|
||||
|
@ -5602,17 +5602,6 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Determine whether the script is really an event handler.
|
||||
// Event handler scripts are NOT immediately evaluated.
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement = do_QueryInterface(element);
|
||||
PRBool bIsEventHandler = PR_FALSE;
|
||||
nsAutoString forString;
|
||||
|
||||
scriptElement->GetHtmlFor(forString);
|
||||
if (!forString.IsEmpty()) {
|
||||
bIsEventHandler = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDTD> dtd;
|
||||
mParser->GetDTD(getter_AddRefs(dtd));
|
||||
NS_ENSURE_TRUE(dtd, NS_ERROR_FAILURE);
|
||||
|
@ -5660,11 +5649,9 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
// Assume that we're going to block the parser with a script load.
|
||||
// If it's an inline script, we'll be told otherwise in the call
|
||||
// to our ScriptAvailable method.
|
||||
//
|
||||
// However, if this script is an event handler, then DO NOT block the
|
||||
// parser because it will NOT be executed now.
|
||||
mNeedToBlockParser = !bIsEventHandler;
|
||||
mNeedToBlockParser = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement = do_QueryInterface(element);
|
||||
mScriptElements->AppendElement(scriptElement);
|
||||
}
|
||||
|
||||
|
|
|
@ -1445,7 +1445,7 @@ nsXMLContentSink::ScriptAvailable(nsresult aResult,
|
|||
// Mark the current script as loaded
|
||||
mNeedToBlockParser = PR_FALSE;
|
||||
|
||||
if (NS_FAILED(aResult)) {
|
||||
if (NS_FAILED(aResult) || aResult == NS_CONTENT_SCRIPT_IS_EVENTHANDLER) {
|
||||
mScriptElements.RemoveObjectAt(count-1);
|
||||
|
||||
if(mParser && aWasPending){
|
||||
|
|
Загрузка…
Ссылка в новой задаче