Exceptions in event listeners triggered by dispatchEvent().

johnjbarton <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <CA+2jLuJmuzhYgj9xr1ksi1iaM+cgS0AEsDkk-pzFYSD6juskmA@mail.gmail.com>
When JS calls EventTarget dispatchEvent(evt), EventListener-s are called.
If those EventListeners throw exceptions, what should happen if the closest
enclosing try/catch block surrounds the dispatchEvent() call?

Both Chrome and Firefox currently ignore the try/catch block and report
that the exception is "uncaught". In Chrome, this EventListener is invoked
within an internal try/catch (V8::TryCatch) and any exceptions that result
are reported as uncaught before returning to the caller (eventually
returning to the caller of dispatchEvent()).

I could not find any mention in
http://www.w3.org/TR/DOM-Level-2-Events/events.html of the expected result.

I was surprised by the behavior in Chrome and reported:
https://code.google.com/p/chromium/issues/detail?id=239648
The little test case is online:
http://johnjbarton.github.io/webdev-examples/239648_TryCatchFails/uncaughtErrors.html

Thanks,
jjb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.