Bug 477700 followup. Don't fail Push() calls for an event target that has no associated script context at all. r+sr=smaug pending

This commit is contained in:
Boris Zbarsky 2009-02-16 13:53:11 -05:00
parent b6cebd8f3a
commit a6fe8cb324
2 changed files with 8 additions and 1 deletions

View File

@ -1477,7 +1477,7 @@ public:
// Returns PR_FALSE if something erroneous happened. // Returns PR_FALSE if something erroneous happened.
PRBool Push(nsPIDOMEventTarget *aCurrentTarget); PRBool Push(nsPIDOMEventTarget *aCurrentTarget);
// If a null JSContext is passed to Push(), that will cause no // If a null JSContext is passed to Push(), that will cause no
// Push() to happen and an error to be returned. // push to happen and false to be returned.
PRBool Push(JSContext *cx); PRBool Push(JSContext *cx);
// Explicitly push a null JSContext on the the stack // Explicitly push a null JSContext on the the stack
PRBool PushNull(); PRBool PushNull();

View File

@ -2712,6 +2712,13 @@ nsCxPusher::Push(nsPIDOMEventTarget *aCurrentTarget)
nsCOMPtr<nsIScriptContext> scx; nsCOMPtr<nsIScriptContext> scx;
nsresult rv = aCurrentTarget->GetContextForEventHandlers(getter_AddRefs(scx)); nsresult rv = aCurrentTarget->GetContextForEventHandlers(getter_AddRefs(scx));
NS_ENSURE_SUCCESS(rv, PR_FALSE); NS_ENSURE_SUCCESS(rv, PR_FALSE);
if (!scx) {
// Nothing to do here, I guess. Have to return true so that event firing
// will still work correctly even if there is no associated JSContext
return PR_TRUE;
}
JSContext* cx = nsnull; JSContext* cx = nsnull;
if (scx) { if (scx) {