Bug 936604, null check event handler in event listener service, r=bz

This commit is contained in:
Olli Pettay 2014-01-18 19:50:08 +02:00
Родитель b90e87e13b
Коммит 9ba15f226b
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -94,7 +94,7 @@ nsEventListenerInfo::GetJSVal(JSContext* aCx,
}
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);

Просмотреть файл

@ -60,6 +60,14 @@ function runTests() {
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)");