mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibWeb: Add ports attribute to MessageEvent and MessageEventInit
Still some FIXMEs left though, as the IDL generator doesn't know what a FrozenArray is, nor how to properly create a sequence of a Platform Object.
This commit is contained in:
parent
e464d484c4
commit
73697058b0
3 changed files with 21 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
|
||||
|
@ -27,6 +28,7 @@ MessageEvent::MessageEvent(JS::Realm& realm, FlyString const& event_name, Messag
|
|||
, m_origin(event_init.origin)
|
||||
, m_last_event_id(event_init.last_event_id)
|
||||
, m_source(event_init.source)
|
||||
, m_ports(event_init.ports)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -52,4 +54,17 @@ Variant<JS::Handle<WindowProxy>, JS::Handle<MessagePort>, Empty> MessageEvent::s
|
|||
return m_source.value().downcast<JS::Handle<WindowProxy>, JS::Handle<MessagePort>>();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<JS::Object> MessageEvent::ports() const
|
||||
{
|
||||
if (!m_ports_array) {
|
||||
Vector<JS::Value> port_vector;
|
||||
for (auto const& port : m_ports) {
|
||||
port_vector.append(JS::Value(port.ptr()));
|
||||
}
|
||||
m_ports_array = JS::Array::create_from(realm(), port_vector);
|
||||
MUST(m_ports_array->set_integrity_level(IntegrityLevel::Frozen));
|
||||
}
|
||||
return *m_ports_array;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue