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:
The little test case is online:

Received on Sunday, 2 June 2013 17:20:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:02 UTC