Bug 936604, null check event handler in event listener service, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sat, 18 Jan 2014 19:50:08 +0200
changeset 164140 239b4d95624a6a9538cba0376d2fb5bc91f55757
parent 164139 cc0ba35ea087eaf6acef269938210961f3134256
child 164141 61fd0f987cf2e037ff209ce9e48a30a545dd4bf7
push id26026
push userphilringnalda@gmail.com
push dateSat, 18 Jan 2014 23:17:27 +0000
treeherdermozilla-central@61fd0f987cf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs936604
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 936604, null check event handler in event listener service, r=bz
dom/events/nsEventListenerService.cpp
dom/events/test/test_bug448602.html
--- a/dom/events/nsEventListenerService.cpp
+++ b/dom/events/nsEventListenerService.cpp
@@ -89,17 +89,17 @@ nsEventListenerInfo::GetJSVal(JSContext*
       return false;
     }
     aAc.construct(aCx, object);
     *aJSVal = OBJECT_TO_JSVAL(object);
     return true;
   }
 
   nsCOMPtr<nsIJSEventListener> jsl = do_QueryInterface(mListener);
-  if (jsl) {
+  if (jsl && jsl->GetHandler().HasEventHandler()) {
     JS::Handle<JSObject*> handler(jsl->GetHandler().Ptr()->Callable());
     if (handler) {
       aAc.construct(aCx, handler);
       *aJSVal = OBJECT_TO_JSVAL(handler);
       return true;
     }
   }
   return false;
--- a/dom/events/test/test_bug448602.html
+++ b/dom/events/test/test_bug448602.html
@@ -56,16 +56,24 @@ function runTests() {
     jsd.on();
     ok(jsd.isOn, "JSD should be running.");
   }
   var jsdvalue = infos[0].getDebugObject().QueryInterface(SpecialPowers.Ci.jsdIValue);
   is(jsdvalue.jsType, 3, "Event listener should be a function! (1)");
 */
 
   root.removeAttribute("onclick");
+  root.setAttribute("onclick", "...invalid script...");
+  SimpleTest.expectUncaughtException(true);
+  infos = els.getListenerInfoFor(root, {});
+  SimpleTest.expectUncaughtException(false);
+  is(infos.length, 1);
+  is(infos[0].listenerObject, null);
+
+  root.removeAttribute("onclick");
   infos = els.getListenerInfoFor(root, {});
   is(infos.length, 0, "Element shouldn't have listeners (2)");
 
   var l = function (e) { alert(e); };
   root.addEventListener("foo", l, true, true);
   root.addEventListener("foo", l, false, false);
   infos = els.getListenerInfoFor(root, {});
   is(infos.length, 2, "Element should have listeners (2)");