diff --git a/dom/src/events/nsJSEventListener.cpp b/dom/src/events/nsJSEventListener.cpp index 17fedc7f2df8..cd9b88f40504 100644 --- a/dom/src/events/nsJSEventListener.cpp +++ b/dom/src/events/nsJSEventListener.cpp @@ -81,14 +81,16 @@ nsJSEventListener::nsJSEventListener(nsIScriptContext *aContext, : nsIJSEventListener(aContext, aScopeObject, aTarget), mReturnResult(nsReturnResult_eNotSet) { - // mScopeObject is the "script global" for a context - this - // does not need explicit memory management so long we we don't - // outlive the context - which we don't. + // aScopeObject is the inner window's JS object, which we need to lock + // until we are done with it. + NS_ASSERTION(aScopeObject && aContext, + "EventListener with no context or scope?"); + aContext->HoldScriptObject(aScopeObject); } nsJSEventListener::~nsJSEventListener() { - // as above, no need to "drop" our reference... + mContext->DropScriptObject(mScopeObject); } NS_INTERFACE_MAP_BEGIN(nsJSEventListener) @@ -201,9 +203,9 @@ nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent) iargv = do_QueryInterface(tempargv); } - // XXX [The JSContext inside mContext] doesn't seem like the correct - // context on which to execute the event handler. Might need to get one - // from the JS thread context stack. + // FIXME: bug 347480 - [The JSContext inside mContext] doesn't seem like + // the correct context on which to execute the event handler. Might need to + // get one from the JS thread context stack. nsCOMPtr vrv; rv = mContext->CallEventHandler(mTarget, mScopeObject, funcval, iargv, getter_AddRefs(vrv));