On 6/23/17 7:01 AM, T.J. Crowder wrote:
On Firefox, I get

```
1
2; cancelling
dispatch complete
then
uncaught exception: 1
uncaught exception: 2
```

...where the traces point to the `dispatchEvent` line. So it seems to
store them up and then report them.

I should note that if you add this to your testcase:

  window.onerror = function(...args) {
    console.log(...args);
  }

then you will see something like this in Firefox:

1
uncaught exception: 1 foo.html 20 1 1
2; cancelling
uncaught exception: 2 foo.html 20 1 2
dispatch complete
then
uncaught exception: 1
uncaught exception: 2

where those first two "uncaught exception" lines are the logs from the error handler. So for the parts that are web-observable, Firefox does the error reporting synchronously.

The rest of what you see is because the console API and the internal error reporting use slightly different mechanisms for notifying about new messages: the former does it immediately and the latter does it after an event loop turn, because it's working with a threadsafe logging facility that always handles things via a job queued on the main event loop.

Replicating the Firefox behavior in your own `dispatchEvent` function is
fairly doable: Catch the exceptions, store them, and then fire them off
asynchronously when done (https://jsfiddle.net/gwwLkjmt/):

That won't give you the right onerror behavior.

-Boris
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to