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

Re: Throwing an error in an event listener

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sat, 27 Oct 2012 12:52:50 -0400
Message-ID: <508C1162.4070204@mit.edu>
To: www-dom@w3.org
On 10/27/12 11:04 AM, David Bruant wrote:
> 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."

It depends.

In this testcase:

   <div onclick="throw 'Inline'">Click me</div>
     window.onerror = function(file, line, text) {
       alert(file + " " + line + " " + text);
     document.querySelector("div").addEventListener("click", function() {
       throw "Added";

Gecko triggers onerror for both exceptions.

Gecko does have a bug in terms of calling window.onerror (and reporting 
to its own error console, since that uses the same mechanism) when a 
listener added via addEventListener is triggered due to an event that's 
dispatched while page script is running (e.g. if you do a manual 
dispatchEvent()).  But it's just a bug that needs fixing.

> I'll go with the assumption that the error should trigger an error event
> on window for now


Received on Saturday, 27 October 2012 16:53:19 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:19 UTC