Re: Throwing an error in an event listener

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 UTC