W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

Re: [Bug 11348] New: [IndexedDB] Overhaul of the event model

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 7 Feb 2011 09:15:04 -0800
Message-ID: <AANLkTik1gf7DuP05PDrxY10p2avBUoMRq7jNv7DPmAWk@mail.gmail.com>
To: Simon Pieters <simonp@opera.com>
Cc: Jeremy Orlow <jorlow@chromium.org>, public-webapps@w3.org
On Mon, Feb 7, 2011 at 2:22 AM, Simon Pieters <simonp@opera.com> wrote:
> On Wed, 02 Feb 2011 23:28:56 +0100, Jonas Sicking <jonas@sicking.cc> wrote:
>
>> On Wed, Feb 2, 2011 at 2:10 PM, Jeremy Orlow <jorlow@chromium.org> wrote:
>>>
>>> Just to confirm, we don't want the events to propagate to the window
>>> itself,
>>> right?
>>
>> Correct. Sort of. Here's what we did in gecko:
>>
>> The event propagation path is request->transaction->database. This
>> goes for both "success" and "error" events. However "success" doesn't
>> bubble so "normal" event handlers doesn't fire on the transaction or
>> database for "success". But if you really want you can attach a
>> capturing listener using .addEventListener and listen to them there.
>> This matches events fired on nodes.
>>
>> For "abort" events the propagation path is just transaction->database
>> since the target of "abort" events is the transaction.
>>
>> So far this matches what you said.
>>
>> However, we also wanted to integrate the window.onerror feature in
>> HTML5. So after we've fired an "error" event, if .preventDefault() was
>> never called on the event, we fire an error event on the window (can't
>> remember if this happens before or after we abort the transaction).
>> This is a separate event, which for example means that even if you
>> attach a capturing "error" handler on window, you won't see any events
>> unless an error really went unhandled. And you also can't call
>> .preventDefault on the error event fired on the window in order to
>> prevent the transaction from being aborted. It's purely there for
>> error reporting and distinctly different from the event propagating to
>> the window.
>
> Hmm. I'm not sure what to think of IndexedDB using window.onerror.
> window.onerror is used for catching JS syntax errors and uncaught exceptions
> in scripts. Also, window.onerror is invoked directly without firing an
> actual event.

Not just syntax errors. At least in firefox it also fires for uncaught
exceptions.

So basically we fire all javascript errors which goes unhandled by the
page (there is no way to handle syntax errors so they always goes
unhandled). That is very much the case here, however since the error
reporting must be asynchronous we report it using a event rather than
an exception.

> What's the use case for firing an error event on window for IndexedDB?

What is the use case for error events? I've always thought of it as a
choke point where pages can catch JS errors and either display to the
user or report back to the server for debugging. If that is the case
then this is just another case where errors can arise.

Do you have another use case in mind?

>> This is similar to how "error" events are handled in workers.
>
> Not really. Workers have their own onerror handler in the worker script
> itself, and if the error is still "not handled", an error event is fired on
> the worker object, but it stops there; an error event is never fired on
> window.

That's not the case in the gecko implementation. But I see the spec
doesn't call for this yet. I'll file a bug on the spec.

/ Jonas
Received on Monday, 7 February 2011 17:16:00 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:43 GMT