diff --git a/Userland/Services/WebContent/PageClient.cpp b/Userland/Services/WebContent/PageClient.cpp index ca2b9fb502d..ff2cc8ce2c8 100644 --- a/Userland/Services/WebContent/PageClient.cpp +++ b/Userland/Services/WebContent/PageClient.cpp @@ -77,6 +77,9 @@ void PageClient::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_page); + + if (m_webdriver) + m_webdriver->visit_edges(visitor); } ConnectionFromClient& PageClient::client() const diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 87cbefa4aa2..d46f5efec5e 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -199,6 +199,14 @@ WebDriverConnection::WebDriverConnection(NonnullOwnPtr socket set_current_top_level_browsing_context(page_client.page().top_level_browsing_context()); } +void WebDriverConnection::visit_edges(JS::Cell::Visitor& visitor) +{ + visitor.visit(m_current_browsing_context); + visitor.visit(m_current_parent_browsing_context); + visitor.visit(m_current_top_level_browsing_context); + visitor.visit(m_action_executor); +} + // https://w3c.github.io/webdriver/#dfn-close-the-session void WebDriverConnection::close_session() { diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index f20ac72dcc3..2d8592dda91 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -34,6 +34,8 @@ public: static ErrorOr> connect(Web::PageClient& page_client, ByteString const& webdriver_ipc_path); virtual ~WebDriverConnection() = default; + void visit_edges(JS::Cell::Visitor&); + private: WebDriverConnection(NonnullOwnPtr socket, Web::PageClient& page_client); @@ -106,10 +108,10 @@ private: void set_current_browsing_context(Web::HTML::BrowsingContext&); Web::HTML::BrowsingContext& current_browsing_context() { return *m_current_browsing_context; } - JS::GCPtr current_parent_browsing_context() { return m_current_parent_browsing_context.ptr(); } + JS::GCPtr current_parent_browsing_context() { return m_current_parent_browsing_context; } void set_current_top_level_browsing_context(Web::HTML::BrowsingContext&); - JS::GCPtr current_top_level_browsing_context() { return m_current_top_level_browsing_context.ptr(); } + JS::GCPtr current_top_level_browsing_context() { return m_current_top_level_browsing_context; } ErrorOr ensure_current_browsing_context_is_open(); ErrorOr ensure_current_top_level_browsing_context_is_open(); @@ -147,15 +149,15 @@ private: Web::WebDriver::TimeoutsConfiguration m_timeouts_configuration; // https://w3c.github.io/webdriver/#dfn-current-browsing-context - JS::Handle m_current_browsing_context; + JS::GCPtr m_current_browsing_context; // https://w3c.github.io/webdriver/#dfn-current-parent-browsing-context - JS::Handle m_current_parent_browsing_context; + JS::GCPtr m_current_parent_browsing_context; // https://w3c.github.io/webdriver/#dfn-current-top-level-browsing-context - JS::Handle m_current_top_level_browsing_context; + JS::GCPtr m_current_top_level_browsing_context; - JS::Handle m_action_executor; + JS::GCPtr m_action_executor; }; }