diff options
Diffstat (limited to 'Userland/Services/WebDriver/Client.h')
-rw-r--r-- | Userland/Services/WebDriver/Client.h | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/Userland/Services/WebDriver/Client.h b/Userland/Services/WebDriver/Client.h index 65820de97e..b9a9eeed7a 100644 --- a/Userland/Services/WebDriver/Client.h +++ b/Userland/Services/WebDriver/Client.h @@ -13,8 +13,8 @@ #include <LibCore/Stream.h> #include <LibHTTP/Forward.h> #include <LibHTTP/HttpRequest.h> +#include <LibWeb/WebDriver/Error.h> #include <WebDriver/Session.h> -#include <WebDriver/WebDriverError.h> namespace WebDriver { @@ -31,11 +31,11 @@ private: ErrorOr<JsonValue> read_body_as_json(HTTP::HttpRequest const&); ErrorOr<bool> handle_request(HTTP::HttpRequest const&, JsonValue const& body); ErrorOr<void> send_response(StringView content, HTTP::HttpRequest const&); - ErrorOr<void> send_error_response(WebDriverError const& error, HTTP::HttpRequest const&); + ErrorOr<void> send_error_response(Web::WebDriver::Error const& error, HTTP::HttpRequest const&); void die(); void log_response(unsigned code, HTTP::HttpRequest const&); - using RouteHandler = ErrorOr<JsonValue, WebDriverError> (Client::*)(Vector<StringView> const&, JsonValue const&); + using RouteHandler = ErrorOr<JsonValue, Web::WebDriver::Error> (Client::*)(Vector<StringView> const&, JsonValue const&); struct Route { HTTP::HttpRequest::Method method; Vector<String> path; @@ -47,70 +47,70 @@ private: Vector<StringView> parameters; }; - ErrorOr<RoutingResult, WebDriverError> match_route(HTTP::HttpRequest::Method method, String const& resource); - ErrorOr<JsonValue, WebDriverError> handle_new_session(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_delete_session(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_status(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_timeouts(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_set_timeouts(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_navigate_to(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_current_url(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_back(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_forward(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_refresh(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_title(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_window_handle(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_close_window(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_window_handles(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_window_rect(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_set_window_rect(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_maximize_window(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_minimize_window(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_find_element(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_find_elements(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_find_element_from_element(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_find_elements_from_element(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_is_element_selected(Vector<StringView> const& parameters, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_attribute(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_property(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_css_value(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_text(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_tag_name(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_element_rect(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_is_element_enabled(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_source(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_execute_script(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_execute_async_script(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_all_cookies(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_get_named_cookie(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_add_cookie(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_delete_cookie(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_delete_all_cookies(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_take_screenshot(Vector<StringView> const&, JsonValue const& payload); - ErrorOr<JsonValue, WebDriverError> handle_take_element_screenshot(Vector<StringView> const&, JsonValue const& payload); - - ErrorOr<Session*, WebDriverError> find_session_with_id(StringView session_id); + ErrorOr<RoutingResult, Web::WebDriver::Error> match_route(HTTP::HttpRequest::Method method, String const& resource); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_new_session(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_delete_session(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_status(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_timeouts(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_set_timeouts(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_navigate_to(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_current_url(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_back(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_forward(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_refresh(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_title(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_window_handle(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_close_window(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_window_handles(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_window_rect(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_set_window_rect(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_maximize_window(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_minimize_window(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_find_element(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_find_elements(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_find_element_from_element(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_find_elements_from_element(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_is_element_selected(Vector<StringView> const& parameters, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_attribute(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_property(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_css_value(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_text(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_tag_name(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_element_rect(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_is_element_enabled(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_source(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_execute_script(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_execute_async_script(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_all_cookies(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_get_named_cookie(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_add_cookie(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_delete_cookie(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_delete_all_cookies(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_take_screenshot(Vector<StringView> const&, JsonValue const& payload); + ErrorOr<JsonValue, Web::WebDriver::Error> handle_take_element_screenshot(Vector<StringView> const&, JsonValue const& payload); + + ErrorOr<Session*, Web::WebDriver::Error> find_session_with_id(StringView session_id); JsonValue make_json_value(JsonValue const&); template<typename T> - static ErrorOr<T, WebDriverError> unwrap_result(ErrorOr<T, Variant<WebDriverError, Error>> result) + static ErrorOr<T, Web::WebDriver::Error> unwrap_result(ErrorOr<T, Variant<Web::WebDriver::Error, Error>> result) { if (result.is_error()) { - Variant<WebDriverError, Error> error = result.release_error(); - if (error.has<WebDriverError>()) - return error.get<WebDriverError>(); - return WebDriverError::from_code(ErrorCode::UnsupportedOperation, error.get<Error>().string_literal()); + Variant<Web::WebDriver::Error, Error> error = result.release_error(); + if (error.has<Web::WebDriver::Error>()) + return error.get<Web::WebDriver::Error>(); + return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, error.get<Error>().string_literal()); } return result.release_value(); } - static ErrorOr<void, WebDriverError> unwrap_result(ErrorOr<void, Variant<WebDriverError, Error>> result) + static ErrorOr<void, Web::WebDriver::Error> unwrap_result(ErrorOr<void, Variant<Web::WebDriver::Error, Error>> result) { if (result.is_error()) { - Variant<WebDriverError, Error> error = result.release_error(); - if (error.has<WebDriverError>()) - return error.get<WebDriverError>(); - return WebDriverError::from_code(ErrorCode::UnsupportedOperation, error.get<Error>().string_literal()); + Variant<Web::WebDriver::Error, Error> error = result.release_error(); + if (error.has<Web::WebDriver::Error>()) + return error.get<Web::WebDriver::Error>(); + return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, error.get<Error>().string_literal()); } return {}; } |