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:
parent
50ae1ad18a
commit
f7c212a19d
Notes:
sideshowbarker
2024-07-17 04:39:56 +09:00
Author: https://github.com/trflynn89
Commit: f7c212a19d
Pull-request: https://github.com/SerenityOS/serenity/pull/15981
Reviewed-by: https://github.com/linusg ✅
8 changed files with 17 additions and 10 deletions
|
@ -74,8 +74,6 @@ void ConnectionFromClient::connect_to_webdriver(String const& webdriver_ipc_path
|
||||||
// FIXME: Propogate this error back to the browser.
|
// FIXME: Propogate this error back to the browser.
|
||||||
if (auto result = m_page_host->connect_to_webdriver(webdriver_ipc_path); result.is_error())
|
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());
|
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)
|
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);
|
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)
|
void ConnectionFromClient::set_window_position(Gfx::IntPoint const& position)
|
||||||
{
|
{
|
||||||
m_page_host->set_window_position(position);
|
m_page_host->set_window_position(position);
|
||||||
|
|
|
@ -74,7 +74,6 @@ private:
|
||||||
virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override;
|
virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override;
|
||||||
virtual void set_has_focus(bool) override;
|
virtual void set_has_focus(bool) override;
|
||||||
virtual void set_is_scripting_enabled(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_position(Gfx::IntPoint const&) override;
|
||||||
virtual void set_window_size(Gfx::IntSize 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;
|
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||||
|
|
|
@ -71,7 +71,6 @@ endpoint WebContentServer
|
||||||
set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =|
|
set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =|
|
||||||
set_has_focus(bool has_focus) =|
|
set_has_focus(bool has_focus) =|
|
||||||
set_is_scripting_enabled(bool is_scripting_enabled) =|
|
set_is_scripting_enabled(bool is_scripting_enabled) =|
|
||||||
set_is_webdriver_active(bool is_webdriver_active) =|
|
|
||||||
|
|
||||||
set_window_position(Gfx::IntPoint position) =|
|
set_window_position(Gfx::IntPoint position) =|
|
||||||
set_window_size(Gfx::IntSize size) =|
|
set_window_size(Gfx::IntSize size) =|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
endpoint WebDriverClient {
|
endpoint WebDriverClient {
|
||||||
|
set_is_webdriver_active(bool active) =|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ private:
|
||||||
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, PageHost& page_host);
|
WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, PageHost& page_host);
|
||||||
|
|
||||||
virtual void die() override { }
|
virtual void die() override { }
|
||||||
|
virtual void set_is_webdriver_active(bool) override;
|
||||||
|
|
||||||
PageHost& m_page_host;
|
PageHost& m_page_host;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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()));
|
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: 8. Set the current session to session.
|
||||||
|
|
||||||
// FIXME: 9. Run any WebDriver new session algorithm defined in external specifications,
|
// 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:
|
// FIXME: 12. Initialize the following from capabilities:
|
||||||
// NOTE: See spec for steps
|
// 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
|
// FIXME: 14. Set the current top-level browsing context for session with the top-level browsing context
|
||||||
// of the UA’s current browsing context.
|
// of the UA’s current browsing context.
|
||||||
|
|
|
@ -41,6 +41,12 @@ public:
|
||||||
ErrorOr<void, Web::WebDriver::Error> check_for_open_top_level_browsing_context_or_return_error();
|
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; }
|
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> start();
|
||||||
ErrorOr<void> stop();
|
ErrorOr<void> stop();
|
||||||
JsonObject get_timeouts();
|
JsonObject get_timeouts();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue