mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:32:44 +00:00 
			
		
		
		
	WebContent+WebDriver: Move Get/Set Timeouts to WebContent
This commit is contained in:
		
							parent
							
								
									cb4b9108d1
								
							
						
					
					
						commit
						04f41bda52
					
				
					 6 changed files with 33 additions and 33 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
|  | @ -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) | ||||
| { | ||||
|  |  | |||
|  | @ -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; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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
 | ||||
|  |  | |||
|  | @ -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() | ||||
| { | ||||
|  |  | |||
|  | @ -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; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn