W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

Exceptions in event listeners triggered by dispatchEvent().

From: johnjbarton <johnjbarton@chromium.org>
Date: Fri, 31 May 2013 13:28:50 -0700
Message-ID: <CA+2jLuJmuzhYgj9xr1ksi1iaM+cgS0AEsDkk-pzFYSD6juskmA@mail.gmail.com>
To: www-dom@w3.org
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
Received on Sunday, 2 June 2013 17:20:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC