LibWeb: Add missing visits in MessageEvent

Also change a Vector<Handle> to a Vector<NonnullGCPtr> while we're
here, since there's no need to use handles for members of a cell.

Fixes an ASAN error on the HTML/Window-postMessage.html test.
This commit is contained in:
Andreas Kling 2024-01-24 08:56:59 +01:00
parent 413eb19579
commit b84056c05b
Notes: sideshowbarker 2024-07-16 21:45:42 +09:00
2 changed files with 9 additions and 2 deletions

View file

@ -28,8 +28,12 @@ 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)
{
m_ports.ensure_capacity(event_init.ports.size());
for (auto& port : event_init.ports) {
VERIFY(port);
m_ports.unchecked_append(*port);
}
}
MessageEvent::~MessageEvent() = default;
@ -44,6 +48,9 @@ void MessageEvent::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_data);
visitor.visit(m_ports_array);
for (auto& port : m_ports)
visitor.visit(port);
}
Variant<JS::Handle<WindowProxy>, JS::Handle<MessagePort>, Empty> MessageEvent::source() const

View file

@ -48,7 +48,7 @@ private:
String m_origin;
String m_last_event_id;
Optional<MessageEventSource> m_source;
Vector<JS::Handle<JS::Object>> m_ports;
Vector<JS::NonnullGCPtr<JS::Object>> m_ports;
mutable JS::GCPtr<JS::Array> m_ports_array;
};