- From: Simon Pieters <simonp@opera.com>
- Date: Fri, 07 Jun 2013 15:09:30 +0200
- To: "Glenn Maynard" <glenn@zewt.org>
- Cc: "Domenic Denicola" <domenic@domenicdenicola.com>, "John Barton" <johnjbarton@google.com>, johnjbarton <johnjbarton@chromium.org>, "www-dom@w3.org" <www-dom@w3.org>, "Anne van Kesteren" <annevk@annevk.nl>
On Wed, 05 Jun 2013 16:19:48 +0200, Glenn Maynard <glenn@zewt.org> wrote: >> No. window.onerror is invoked directly without an event. ErrorEvent is >> for >> the case when an uncaught error is fired on a Worker object (if the >> error >> wasn't handled in the worker itself). >> > > Nope. In Chrome and IE10, ErrorEvent is used for uncaught exceptions in > the UI thread too, for the "error" event fired on window. Firefox also > fires "error" event listeners (not just the event handler), but doesn't > yet > use ErrorEvent there. Well then those browsers violate the spec and the original implementation... At least Presto implements the spec. > (The spec looks incorrect here. It bypasses event dispatch entirely and > calls "onerror" directly, which forgets to fire event listeners. It also > doesn't make much sense to support error handling with event listeners in > workers but not in the UI thread. This should probably just fire an > ErrorEvent, and the window.onerror special case should probably be in the > event dispatch algorithm.) You misunderstood the worker case. Errors in workers are handled the same as in window, i.e. onerror is invoked directly. However, if a worker error is not "handled", an ErrorEvent gets fired on the Worker object. > If you want to catch an exception and have it behave as though the error > was uncaught and gets sent to onerror, you need to make sure "error" is > dispatched to event listeners. If you simply call window.onerror > directly, > event listeners won't be called. > > This works in Chrome, including calling the onerror event handler called > with its special-cased arguments: > http://zewt.org/~glenn/test-error-handler.html. Firefox doesn't handle > this yet, so you end up with the event handler called with incorrect > arguments. (IE10 doesn't seem to have any way to create an ErrorEvent > object yet; the interface exists but isn't a constructor.) I'll file a > bug > on HTML. -- Simon Pieters Opera Software
Received on Friday, 7 June 2013 13:09:07 UTC