diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-11-11 14:28:57 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-11 22:03:23 +0000 |
commit | 04f41bda524efb1faaf3ae161f65bcde2f45c824 (patch) | |
tree | 8b90be7ec8d622c8e17b3a36ae6db9669e4e9a53 | |
parent | cb4b9108d171489611bca83149a1390d8e7027c1 (diff) | |
download | serenity-04f41bda524efb1faaf3ae161f65bcde2f45c824.zip |
WebContent+WebDriver: Move Get/Set Timeouts to WebContent
-rw-r--r-- | Userland/Services/WebContent/WebDriverClient.ipc | 2 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.cpp | 23 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.h | 6 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Client.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.cpp | 23 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.h | 6 |
6 files changed, 33 insertions, 33 deletions
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc index ca8669ebc6..fea31a636a 100644 --- a/Userland/Services/WebContent/WebDriverClient.ipc +++ b/Userland/Services/WebContent/WebDriverClient.ipc @@ -3,6 +3,8 @@ endpoint WebDriverClient { close_session() => () set_is_webdriver_active(bool active) =| + get_timeouts() => (Web::WebDriver::Response response) + set_timeouts(JsonValue payload) => (Web::WebDriver::Response response) navigate_to(JsonValue payload) => (Web::WebDriver::Response response) get_current_url() => (Web::WebDriver::Response response) back() => (Web::WebDriver::Response response) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 0afdf5d135..93d595d16f 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -241,6 +241,29 @@ void WebDriverConnection::set_is_webdriver_active(bool is_webdriver_active) m_page_host.set_is_webdriver_active(is_webdriver_active); } +// 9.1 Get Timeouts, https://w3c.github.io/webdriver/#dfn-get-timeouts +Messages::WebDriverClient::GetTimeoutsResponse WebDriverConnection::get_timeouts() +{ + // 1. Let timeouts be the timeouts object for session’s timeouts configuration + auto timeouts = Web::WebDriver::timeouts_object(m_timeouts_configuration); + + // 2. Return success with data timeouts. + return timeouts; +} + +// 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts +Messages::WebDriverClient::SetTimeoutsResponse WebDriverConnection::set_timeouts(JsonValue const& payload) +{ + // 1. Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the request’s parameters. + auto timeouts = TRY(Web::WebDriver::json_deserialize_as_a_timeouts_configuration(payload)); + + // 2. Make the session timeouts the new timeouts. + m_timeouts_configuration = move(timeouts); + + // 3. Return success with data null. + return JsonValue {}; +} + // 10.1 Navigate To, https://w3c.github.io/webdriver/#navigate-to Messages::WebDriverClient::NavigateToResponse WebDriverConnection::navigate_to(JsonValue const& payload) { diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index bcac1284dc..64c8c54fdf 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -14,6 +14,7 @@ #include <LibWeb/Forward.h> #include <LibWeb/WebDriver/ElementLocationStrategies.h> #include <LibWeb/WebDriver/Response.h> +#include <LibWeb/WebDriver/TimeoutsConfiguration.h> #include <WebContent/Forward.h> #include <WebContent/WebDriverClientEndpoint.h> #include <WebContent/WebDriverServerEndpoint.h> @@ -35,6 +36,8 @@ private: virtual void close_session() override; virtual void set_is_webdriver_active(bool) override; + virtual Messages::WebDriverClient::GetTimeoutsResponse get_timeouts() override; + virtual Messages::WebDriverClient::SetTimeoutsResponse set_timeouts(JsonValue const& payload) override; virtual Messages::WebDriverClient::NavigateToResponse navigate_to(JsonValue const& payload) override; virtual Messages::WebDriverClient::GetCurrentUrlResponse get_current_url() override; virtual Messages::WebDriverClient::BackResponse back() override; @@ -83,6 +86,9 @@ private: ConnectionFromClient& m_web_content_client; PageHost& m_page_host; + + // https://w3c.github.io/webdriver/#dfn-session-script-timeout + Web::WebDriver::TimeoutsConfiguration m_timeouts_configuration; }; } diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index 9f68aa71ad..40adf432d8 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -476,8 +476,7 @@ Web::WebDriver::Response Client::handle_get_timeouts(Vector<StringView> const& p { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session id>/timeouts"); auto* session = TRY(find_session_with_id(parameters[0])); - auto result = session->get_timeouts(); - return make_json_value(result); + return session->web_content_connection().get_timeouts(); } // 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts @@ -486,8 +485,7 @@ Web::WebDriver::Response Client::handle_set_timeouts(Vector<StringView> const& p { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session id>/timeouts"); auto* session = TRY(find_session_with_id(parameters[0])); - auto result = TRY(session->set_timeouts(payload)); - return make_json_value(result); + return session->web_content_connection().set_timeouts(payload); } // 10.1 Navigate To, https://w3c.github.io/webdriver/#dfn-navigate-to diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index f052a85089..526cb35bf7 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -131,29 +131,6 @@ Web::WebDriver::Response Session::stop() return JsonValue {}; } -// 9.1 Get Timeouts, https://w3c.github.io/webdriver/#dfn-get-timeouts -JsonObject Session::get_timeouts() -{ - // 1. Let timeouts be the timeouts object for session’s timeouts configuration - auto timeouts = Web::WebDriver::timeouts_object(m_timeouts_configuration); - - // 2. Return success with data timeouts. - return timeouts; -} - -// 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts -Web::WebDriver::Response Session::set_timeouts(JsonValue const& payload) -{ - // 1. Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the request’s parameters. - auto timeouts = TRY(Web::WebDriver::json_deserialize_as_a_timeouts_configuration(payload)); - - // 2. Make the session timeouts the new timeouts. - m_timeouts_configuration = move(timeouts); - - // 3. Return success with data null. - return JsonValue {}; -} - // 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle Web::WebDriver::Response Session::get_window_handle() { diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h index 4d27567fa3..2518d72a37 100644 --- a/Userland/Services/WebDriver/Session.h +++ b/Userland/Services/WebDriver/Session.h @@ -14,7 +14,6 @@ #include <LibCore/Promise.h> #include <LibWeb/WebDriver/Error.h> #include <LibWeb/WebDriver/Response.h> -#include <LibWeb/WebDriver/TimeoutsConfiguration.h> #include <WebDriver/WebContentConnection.h> #include <unistd.h> @@ -48,8 +47,6 @@ public: ErrorOr<void> start(); Web::WebDriver::Response stop(); - JsonObject get_timeouts(); - Web::WebDriver::Response set_timeouts(JsonValue const& payload); Web::WebDriver::Response get_window_handle(); ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window(); Web::WebDriver::Response get_window_handles() const; @@ -66,9 +63,6 @@ private: String m_current_window_handle; RefPtr<WebContentConnection> m_web_content_connection; Optional<pid_t> m_browser_pid; - - // https://w3c.github.io/webdriver/#dfn-session-script-timeout - Web::WebDriver::TimeoutsConfiguration m_timeouts_configuration; }; } |