W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2012

Re: Throwing an error in an event listener

From: David Bruant <bruant.d@gmail.com>
Date: Sat, 27 Oct 2012 17:04:47 +0200
Message-ID: <CAHbscB1Cir-=d9zqsNCzD9rLtNe3JAACqjUrYEOVoMpLGjc3Mg@mail.gmail.com>
To: www-dom@w3.org
Ms2ger directed me to https://www.w3.org/Bugs/Public/show_bug.cgi?id=17713
Second issue is what is expected from window.onerror. In the bug, Ms2ger
said:
" Gecko doesn't trigger window.onerror; Chrome, Opera-next and IE10 do."

I'll go with the assumption that the error should trigger an error event on
window for now (when it comes to writing tests).

David

2012/10/27 David Bruant <bruant.d@gmail.com>

> Hi,
>
> Live from Test the web forward in Paris. Here is a test case I've just
> written (don't bother):
>
>         var element = document.getElementById('bim');
>         var secondCalled = false;
>
>         element.addEventListener('click', function(){
>             throw new Error('Error from listener');
>         });
>         element.addEventListener('click', function(){ secondCalled = true;
> }, false);
>         element.click();
>
>         assert_true(secondCalled);
>
> It's unclear what's the expected behavior in the spec.
> The dispatch algorithm says:
> (Step 8) Invoke the event listeners of event's target attribute value with
> event
> Then, the invoke algorithm says:
> (Step 4.7) Call listener's callback, with the event passed to this
> algorithm as the first argument.
>
> But nothing is said about what happens if during this call an error is
> thrown. In browsers I have tested (Firefox 18, Opera 12, latest Chrome),
> the error is absorbed and the next listener is called (so the test
> succeeds).
> I think the invoke algorithm should make a mention of that somewhere.
>
> David
>
Received on Saturday, 27 October 2012 15:05:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 27 October 2012 15:05:15 GMT