diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
index cf261533d7..a9fd24b15f 100644
--- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
+++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include
#include
#include
@@ -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, Empty> MessageEvent::s
return m_source.value().downcast, JS::Handle>();
}
+JS::NonnullGCPtr MessageEvent::ports() const
+{
+ if (!m_ports_array) {
+ Vector 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;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h
index d4077ee9ff..9a2a5a5071 100644
--- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h
+++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h
@@ -20,6 +20,7 @@ struct MessageEventInit : public DOM::EventInit {
String origin {};
String last_event_id {};
Optional source;
+ Vector> ports;
};
class MessageEvent : public DOM::Event {
@@ -36,6 +37,7 @@ public:
JS::Value data() const { return m_data; }
String const& origin() const { return m_origin; }
String const& last_event_id() const { return m_last_event_id; }
+ JS::NonnullGCPtr ports() const;
Variant, JS::Handle, Empty> source() const;
private:
@@ -46,6 +48,8 @@ private:
String m_origin;
String m_last_event_id;
Optional m_source;
+ Vector> m_ports;
+ mutable JS::GCPtr m_ports_array;
};
}
diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.idl b/Userland/Libraries/LibWeb/HTML/MessageEvent.idl
index 0b3168a09d..f54c2187fc 100644
--- a/Userland/Libraries/LibWeb/HTML/MessageEvent.idl
+++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.idl
@@ -14,6 +14,7 @@ interface MessageEvent : Event {
readonly attribute DOMString lastEventId;
readonly attribute MessageEventSource? source;
// FIXME: readonly attribute FrozenArray ports;
+ readonly attribute any ports;
};
dictionary MessageEventInit : EventInit {
@@ -22,4 +23,5 @@ dictionary MessageEventInit : EventInit {
DOMString lastEventId = "";
MessageEventSource? source = null;
// FIXME: sequence ports = [];
+ sequence