Commit b19476f
fix(events): report a throwing event listener instead of swallowing it (−2)
Per DOM "inner invoke", when an event listener callback throws, the exception
is REPORTED (HTML "report the exception" — a window `error` event + legacy
`onerror`), not propagated to the dispatchEvent() caller, and dispatch continues
to the next listener. `fireListeners` was catching a callback throw with
`logThrew` (logged + swallowed), so `window.onerror` never saw it. Route the
throw through `__csimReportCallbackError` (report on the callback's own realm,
WebIDL "invoke a callback") — same as the already-correct handleEvent-Get path
just above. The legacy `window.onerror` property handler is invoked with the
string message, as the test expects.
Add a re-entrancy guard to `reportError`: an `error` handler (`window.onerror`
or an `error` listener) that ITSELF throws is reported too, but firing another
`error` event for it would recurse unboundedly (a click → throwing listener →
report → error event → throwing error handler → report → …). While already
reporting, skip the event and just log — matching browsers, where error
reporting is not re-entrant. (Before this commit `logThrew` broke the cycle; now
that listener throws are reported, the guard is required.)
Clears Event-dispatch-throwing.html (single + multiple listeners). The inline
`on*`-attribute handler throw (line ~366) still uses `logThrew` — also reportable
per spec, but untested and out of scope here.
Gate 660/0/15, gem 1586/0/35, 0 WPT regressions. All five apps green on a clean
box: Redmine 122/0, Avo 396/0 (3m08s, baseline), Forem, Mastodon 26/0, Discourse
2052/0/67 — confirming the report-the-exception behaviour change (now firing
`error` events for throwing listeners) doesn't regress any app.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 2b66c40 commit b19476f
4 files changed
Lines changed: 36 additions & 8 deletions
File tree
- lib/capybara/simulated/js
- src
- spec/support
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3342 | 3342 | | |
3343 | 3343 | | |
3344 | 3344 | | |
3345 | | - | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
3346 | 3349 | | |
3347 | 3350 | | |
3348 | 3351 | | |
| |||
3351 | 3354 | | |
3352 | 3355 | | |
3353 | 3356 | | |
3354 | | - | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
3355 | 3361 | | |
3356 | 3362 | | |
3357 | 3363 | | |
| |||
17011 | 17017 | | |
17012 | 17018 | | |
17013 | 17019 | | |
| 17020 | + | |
17014 | 17021 | | |
| 17022 | + | |
| 17023 | + | |
| 17024 | + | |
| 17025 | + | |
| 17026 | + | |
| 17027 | + | |
| 17028 | + | |
17015 | 17029 | | |
| 17030 | + | |
17016 | 17031 | | |
17017 | 17032 | | |
17018 | 17033 | | |
| |||
17026 | 17041 | | |
17027 | 17042 | | |
17028 | 17043 | | |
| 17044 | + | |
| 17045 | + | |
17029 | 17046 | | |
17030 | 17047 | | |
17031 | 17048 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
399 | 403 | | |
400 | | - | |
| 404 | + | |
401 | 405 | | |
402 | 406 | | |
403 | 407 | | |
404 | | - | |
| 408 | + | |
405 | 409 | | |
406 | 410 | | |
407 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
362 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
363 | 372 | | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
| |||
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
377 | | - | |
| 387 | + | |
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
| |||
0 commit comments