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
This commit is contained in:
Jamie Mansfield 2024-07-17 12:35:01 +01:00 committed by Tim Ledbetter
commit aefab1de38
Notes: sideshowbarker 2024-07-18 02:43:45 +09:00

View file

@ -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 thiss 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;
}