diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 86234fd54749..50731804270c 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1471,7 +1471,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, PRBool intermediateCapture = PR_FALSE; //Capturing stage evaluation - if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD) { + if (NS_EVENT_FLAG_BUBBLE != aFlags && aEvent->message != NS_PAGE_LOAD + && aEvent->message != NS_SCRIPT_LOAD) { //Initiate capturing phase. Special case first call to document if (parent) { parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus); @@ -1510,7 +1511,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, //Bubbling stage if (NS_EVENT_FLAG_CAPTURE != aFlags && mDocument && - aEvent->message != NS_PAGE_LOAD) { + aEvent->message != NS_PAGE_LOAD && + aEvent->message != NS_SCRIPT_LOAD) { if (parent) { /* * If there's a parent we pass the event to the parent... diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 6469d18c685d..9c5ac332263b 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -1342,6 +1342,7 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_close]; case NS_PAGE_LOAD: case NS_IMAGE_LOAD: + case NS_SCRIPT_LOAD: return mEventNames[eDOMEvents_load]; case NS_PAGE_UNLOAD: return mEventNames[eDOMEvents_unload]; diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 5670c46cb7a6..ba7cfd3846ca 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -191,14 +191,14 @@ nsEventListenerManager::QueryInterface(REFNSIID aIID, void** aInstancePtr) AddRef(); return NS_OK; } + if (mTarget) { + return mTarget->QueryInterface(aIID, aInstancePtr); + } if (aIID.Equals(NS_GET_IID(nsISupports))) { *aInstancePtr = (void*)(nsISupports*)(nsIEventListenerManager*)this; AddRef(); return NS_OK; } - if (mTarget) { - return mTarget->QueryInterface(aIID, aInstancePtr); - } return NS_NOINTERFACE; } @@ -981,6 +981,8 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext, if (NS_FAILED(rv)) return rv; + nsCOMPtr classInfo = do_QueryInterface(aObject); + if (NS_FAILED(rv = securityManager->CheckPropertyAccess(cx, jsobj, "EventTarget","addEventListener", nsIXPCSecurityManager::ACCESS_SET_PROPERTY))) { @@ -1762,6 +1764,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, case NS_PAGE_UNLOAD: case NS_IMAGE_LOAD: case NS_IMAGE_ERROR: + case NS_SCRIPT_LOAD: case NS_SCRIPT_ERROR: listeners = GetListenersByType(eEventArrayType_Load, nsnull, PR_FALSE); if (listeners) { @@ -1778,6 +1781,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, switch(aEvent->message) { case NS_PAGE_LOAD: case NS_IMAGE_LOAD: + case NS_SCRIPT_LOAD: ret = loadListener->Load(*aDOMEvent); break; case NS_PAGE_UNLOAD: @@ -1796,6 +1800,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, switch(aEvent->message) { case NS_PAGE_LOAD: case NS_IMAGE_LOAD: + case NS_SCRIPT_LOAD: subType = NS_EVENT_BITS_LOAD_LOAD; if (ls->mSubType & NS_EVENT_BITS_LOAD_LOAD) { correctSubType = PR_TRUE; diff --git a/content/html/content/src/nsHTMLScriptElement.cpp b/content/html/content/src/nsHTMLScriptElement.cpp index 4e441a04d17e..e02d12309833 100644 --- a/content/html/content/src/nsHTMLScriptElement.cpp +++ b/content/html/content/src/nsHTMLScriptElement.cpp @@ -296,6 +296,20 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult, PRInt32 aLineNo, const nsAString& aScript) { + nsresult rv = NS_OK; + if (!aIsInline && NS_FAILED(aResult)) { + nsCOMPtr presContext; + GetPresContext(this, getter_AddRefs(presContext)); + + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + + event.message = NS_SCRIPT_ERROR; + rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, + &status); + } + return NS_OK; } @@ -306,7 +320,21 @@ nsHTMLScriptElement::ScriptEvaluated(nsresult aResult, PRBool aIsInline, PRBool aWasPending) { - return NS_OK; + nsresult rv = NS_OK; + if (!aIsInline) { + nsCOMPtr presContext; + GetPresContext(this, getter_AddRefs(presContext)); + + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + + event.message = NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR; + rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, + &status); + } + + return rv; } NS_IMETHODIMP diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index bfdbcaa58960..6a9065b99094 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -444,7 +444,8 @@ enum nsDragDropEventStatus { #define NS_IMAGE_LOAD (NS_STREAM_EVENT_START + 2) #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3) #define NS_IMAGE_ERROR (NS_STREAM_EVENT_START + 4) - +#define NS_SCRIPT_LOAD (NS_STREAM_EVENT_START + 5) + #define NS_FORM_EVENT_START 1200 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START) #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)