mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb: Implement MessageEvent.initMessageEvent
This fixes wpt/html/webappapis/scripting/events/messageevent-constructor.https.html
This commit is contained in:
parent
4e7558c88b
commit
ffb3a28684
Notes:
sideshowbarker
2024-07-16 18:26:46 +09:00
Author: https://github.com/jamierocks
Commit: ffb3a28684
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/539
3 changed files with 31 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -75,4 +76,30 @@ JS::NonnullGCPtr<JS::Object> MessageEvent::ports() const
|
|||
return *m_ports_array;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-initmessageevent
|
||||
void MessageEvent::init_message_event(String const& type, bool bubbles, bool cancelable, JS::Value data, String const& origin, String const& last_event_id, Optional<MessageEventSource> source, Vector<JS::Handle<MessagePort>> const& ports)
|
||||
{
|
||||
// The initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) method must initialize the event in a
|
||||
// manner analogous to the similarly-named initEvent() method.
|
||||
|
||||
// 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_data = data;
|
||||
m_origin = origin;
|
||||
m_last_event_id = last_event_id;
|
||||
m_source = source;
|
||||
m_ports.clear();
|
||||
m_ports.ensure_capacity(ports.size());
|
||||
for (auto const& port : ports) {
|
||||
VERIFY(port);
|
||||
m_ports.unchecked_append(static_cast<JS::Object&>(*port));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue