From eb6771d0fd9a348d90eecaec74aeddd92f169a89 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Sun, 28 Aug 2011 05:58:43 -0400 Subject: [PATCH] Bug 682637: Restore null-check that got lost in the event handler IDLification. r=bz --- content/events/crashtests/682637-1.html | 22 +++++++++++++++++++ content/events/crashtests/crashtests.list | 1 + content/events/src/nsEventListenerManager.cpp | 4 ++++ 3 files changed, 27 insertions(+) create mode 100644 content/events/crashtests/682637-1.html diff --git a/content/events/crashtests/682637-1.html b/content/events/crashtests/682637-1.html new file mode 100644 index 00000000000..5afc123773b --- /dev/null +++ b/content/events/crashtests/682637-1.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/content/events/crashtests/crashtests.list b/content/events/crashtests/crashtests.list index 43825144d9c..da58e27aee5 100644 --- a/content/events/crashtests/crashtests.list +++ b/content/events/crashtests/crashtests.list @@ -4,5 +4,6 @@ load 135345-1.html load 422009-1.xhtml load 457776-1.html load 496308-1.html +load 682637-1.html load recursive-onload.html load recursive-DOMNodeInserted.html diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index c9610608e01..5962dce3923 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -943,7 +943,11 @@ nsEventListenerManager::SetJSEventListenerToJsval(nsIAtom *aEventName, return NS_OK; } + // We might not have a script context, e.g. if we're setting a listener + // on a dead Window. nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, aScope); + NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); + JSObject *scope = ::JS_GetGlobalForObject(cx, aScope); // Untrusted events are always permitted for non-chrome script // handlers.