Bug 947778, return early from SetEventHandler when ELM can't find the global jsobject, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 06 Jan 2014 15:36:10 +0200
changeset 162181 1b021e8fc5cc547287627872bf61986a0d88a144
parent 162180 93fe56269382e012a6b28ea1eb6c90ae90130584
child 162182 bafaf8d078d8e0c2f61973b54231ef23ac3c7571
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs947778
milestone29.0a1
Bug 947778, return early from SetEventHandler when ELM can't find the global jsobject, r=bz
content/events/src/nsEventListenerManager.cpp
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -715,16 +715,18 @@ nsEventListenerManager::SetEventHandler(
   if (NS_FAILED(global->EnsureScriptEnvironment())) {
     NS_WARNING("Failed to setup script environment for this language");
     // but fall through and let the inevitable failure below handle it.
   }
 
   nsIScriptContext* context = global->GetScriptContext();
   NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
 
+  NS_ENSURE_STATE(global->GetGlobalJSObject());
+
   JSAutoRequest ar(context->GetNativeContext());
   JS::Rooted<JSObject*> scope(context->GetNativeContext(),
                               global->GetGlobalJSObject());
 
   nsListenerStruct* ls = SetEventHandlerInternal(scope, aName,
                                                  EmptyString(),
                                                  nsEventHandler(),
                                                  aPermitUntrustedEvents);