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.
This commit is contained in:
Shannon Booth 2024-12-15 22:11:19 +13:00 committed by Tim Flynn
parent f8df624171
commit 9f0660c8f0
Notes: github-actions[bot] 2025-01-20 12:53:52 +00:00

View file

@ -454,6 +454,11 @@ GC::Ptr<WebIDL::CallbackType> MessagePort::onmessageerror()
void MessagePort::set_onmessage(GC::Ptr<WebIDL::CallbackType> 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