1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

WebContent+WebDriver: Set the navigator.webdriver flag from WebDriver

This moves setting the navigator.webdriver flag from after WebContent
creates the WebDriver connection, to its own IPC to be triggered from
WebDriver. This is closer to the spec, but mostly serves as an easy
test to validate the connection.
This commit is contained in:
Timothy Flynn 2022-11-08 10:42:12 -05:00 committed by Tim Flynn
parent 50ae1ad18a
commit f7c212a19d
Notes: sideshowbarker 2024-07-17 04:39:56 +09:00
8 changed files with 17 additions and 10 deletions

View file

@ -74,8 +74,6 @@ void ConnectionFromClient::connect_to_webdriver(String const& webdriver_ipc_path
// FIXME: Propogate this error back to the browser.
if (auto result = m_page_host->connect_to_webdriver(webdriver_ipc_path); result.is_error())
dbgln("Unable to connect to the WebDriver process: {}", result.error());
else
set_is_webdriver_active(true);
}
void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& theme_buffer)
@ -801,11 +799,6 @@ void ConnectionFromClient::set_is_scripting_enabled(bool is_scripting_enabled)
m_page_host->set_is_scripting_enabled(is_scripting_enabled);
}
void ConnectionFromClient::set_is_webdriver_active(bool is_webdriver_active)
{
m_page_host->set_is_webdriver_active(is_webdriver_active);
}
void ConnectionFromClient::set_window_position(Gfx::IntPoint const& position)
{
m_page_host->set_window_position(position);

View file

@ -74,7 +74,6 @@ private:
virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override;
virtual void set_has_focus(bool) override;
virtual void set_is_scripting_enabled(bool) override;
virtual void set_is_webdriver_active(bool) override;
virtual void set_window_position(Gfx::IntPoint const&) override;
virtual void set_window_size(Gfx::IntSize const&) override;
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;

View file

@ -71,7 +71,6 @@ endpoint WebContentServer
set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =|
set_has_focus(bool has_focus) =|
set_is_scripting_enabled(bool is_scripting_enabled) =|
set_is_webdriver_active(bool is_webdriver_active) =|
set_window_position(Gfx::IntPoint position) =|
set_window_size(Gfx::IntSize size) =|

View file

@ -1,2 +1,3 @@
endpoint WebDriverClient {
set_is_webdriver_active(bool active) =|
}

View file

@ -34,4 +34,9 @@ WebDriverConnection::WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket
{
}
void WebDriverConnection::set_is_webdriver_active(bool is_webdriver_active)
{
m_page_host.set_is_webdriver_active(is_webdriver_active);
}
}

View file

@ -28,6 +28,7 @@ private:
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, PageHost& page_host);
virtual void die() override { }
virtual void set_is_webdriver_active(bool) override;
PageHost& m_page_host;
};

View file

@ -385,6 +385,8 @@ Web::WebDriver::Response Client::handle_new_session(Vector<StringView> const&, J
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::SessionNotCreated, String::formatted("Failed to start session: {}", start_result.error().string_literal()));
}
auto& web_content_connection = session->web_content_connection();
// FIXME: 8. Set the current session to session.
// FIXME: 9. Run any WebDriver new session algorithm defined in external specifications,
@ -405,7 +407,8 @@ Web::WebDriver::Response Client::handle_new_session(Vector<StringView> const&, J
// FIXME: 12. Initialize the following from capabilities:
// NOTE: See spec for steps
// FIXME: 13. Set the webdriver-active flag to true.
// 13. Set the webdriver-active flag to true.
web_content_connection.async_set_is_webdriver_active(true);
// FIXME: 14. Set the current top-level browsing context for session with the top-level browsing context
// of the UAs current browsing context.

View file

@ -41,6 +41,12 @@ public:
ErrorOr<void, Web::WebDriver::Error> check_for_open_top_level_browsing_context_or_return_error();
String const& current_window_handle() { return m_current_window_handle; }
WebContentConnection& web_content_connection()
{
VERIFY(m_web_content_connection);
return *m_web_content_connection;
}
ErrorOr<void> start();
ErrorOr<void> stop();
JsonObject get_timeouts();