1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:25:08 +00:00

LibWeb: Add MessageEvent.source

This commit is contained in:
Luke Wilde 2023-11-06 20:11:58 +00:00 committed by Andreas Kling
parent eaa3b85864
commit 1607b2c978
3 changed files with 21 additions and 2 deletions

View file

@ -24,6 +24,7 @@ MessageEvent::MessageEvent(JS::Realm& realm, FlyString const& event_name, Messag
, m_data(event_init.data)
, m_origin(event_init.origin)
, m_last_event_id(event_init.last_event_id)
, m_source(event_init.source)
{
}
@ -41,4 +42,12 @@ void MessageEvent::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_data);
}
Variant<JS::Handle<WindowProxy>, JS::Handle<MessagePort>, Empty> MessageEvent::source() const
{
if (!m_source.has_value())
return Empty {};
return m_source.value().downcast<JS::Handle<WindowProxy>, JS::Handle<MessagePort>>();
}
}