From aefab1de38948b0d86a6aed33647e995340859e2 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Wed, 17 Jul 2024 12:35:01 +0100 Subject: [PATCH] LibWeb: Short-circuit UIEvent.initMouseEvent if dispatched This fixes some bugs on wpt.dom/events/Event-init-while-dispatching.html, although the test still fails due to [GH-23722]. [GH-23722]: https://github.com/SerenityOS/serenity/issues/23722 --- Userland/Libraries/LibWeb/UIEvents/UIEvent.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 44f3408805f..5fa32c134ce 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -33,7 +33,16 @@ public: void init_ui_event(String const& type, bool bubbles, bool cancelable, HTML::Window* view, int detail) { - init_event(type, bubbles, cancelable); + // Initializes attributes of an UIEvent object. This method has the same behavior as initEvent(). + + // 1. If this’s dispatch flag is set, then return. + if (dispatched()) + return; + + // 2. Initialize this with type, bubbles, and cancelable. + initialize_event(type, bubbles, cancelable); + + // Implementation Defined: Initialise other values. m_view = view; m_detail = detail; }