From 8ef08be5787e791c3f309460a06ae24b02fff8c5 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 16 Feb 2009 13:53:11 -0500 Subject: [PATCH] Bug 477700 followup. Don't fail Push() calls for an event target that has no associated script context at all. r+sr=smaug pending --- content/base/public/nsContentUtils.h | 2 +- content/base/src/nsContentUtils.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 2fc113d72462..2dd50c83a382 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1477,7 +1477,7 @@ public: // Returns PR_FALSE if something erroneous happened. PRBool Push(nsPIDOMEventTarget *aCurrentTarget); // 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); // Explicitly push a null JSContext on the the stack PRBool PushNull(); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index a6c83eae862b..d599ed143c19 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -2712,6 +2712,13 @@ nsCxPusher::Push(nsPIDOMEventTarget *aCurrentTarget) nsCOMPtr scx; nsresult rv = aCurrentTarget->GetContextForEventHandlers(getter_AddRefs(scx)); 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; if (scx) {