Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f03a38dfc461b3d9a0d119c7ed67796bb281daae
      
https://github.com/WebKit/WebKit/commit/f03a38dfc461b3d9a0d119c7ed67796bb281daae
  Author: Chris Dumez <[email protected]>
  Date:   2026-06-12 (Fri, 12 Jun 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/events/window-event-restored-after-throwing-onerror-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/dom/events/window-event-restored-after-throwing-onerror.html
    M Source/WebCore/bindings/js/JSErrorHandler.cpp

  Log Message:
  -----------
  REGRESSION(309877@main): window.event not restored when a window.onerror 
handler throws
https://bugs.webkit.org/show_bug.cgi?id=316968

Reviewed by Anne van Kesteren.

JSErrorHandler::handleEvent saves the window's current event, sets it to the
error event for the duration of the onerror call, and is supposed to restore it
afterwards. 309877@main refactored this function into a lambda that returns
early when the handler throws (if (exception) return exception;), placing the
setCurrentEvent(savedEvent) restore on the success path only. As a result, when
a window.onerror handler throws, window.event is left pointing at the error
event instead of being restored to the previously current event.

Restore window.event with a makeScopeExit right after it is saved, so it runs on
both the normal and throwing paths, mirroring JSEventListener::handleEvent 
(which
has always done this and was not changed by 309877@main).

Test: 
imported/w3c/web-platform-tests/dom/events/window-event-restored-after-throwing-onerror.html

* 
LayoutTests/imported/w3c/web-platform-tests/dom/events/window-event-restored-after-throwing-onerror-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/dom/events/window-event-restored-after-throwing-onerror.html:
 Added.
* Source/WebCore/bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):

Canonical link: https://commits.webkit.org/315106@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to