From 9f0660c8f0dc32444669c3d5129a2f8a9b3e85fc Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 15 Dec 2024 22:11:19 +1300 Subject: [PATCH] LibWeb/HTML: Start MessagePort's port messsge queue in onmessage setter ...Which doesn't do anything given start() itself doesn't do anything, but this is a subtle enough point of the spec that it seems worthwhile to implement now for whenever this does become meaningful. --- Libraries/LibWeb/HTML/MessagePort.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/LibWeb/HTML/MessagePort.cpp b/Libraries/LibWeb/HTML/MessagePort.cpp index 10b0b920277..fecaee14b52 100644 --- a/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Libraries/LibWeb/HTML/MessagePort.cpp @@ -454,6 +454,11 @@ GC::Ptr MessagePort::onmessageerror() void MessagePort::set_onmessage(GC::Ptr value) { set_event_handler_attribute(EventNames::message, value); + + // https://html.spec.whatwg.org/multipage/web-messaging.html#message-ports:handler-messageeventtarget-onmessage + // The first time a MessagePort object's onmessage IDL attribute is set, the port's port message queue must be enabled, + // as if the start() method had been called. + start(); } // https://html.spec.whatwg.org/multipage/web-messaging.html#handler-messageeventtarget-onmessage