diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.cpp b/Userland/Libraries/LibWeb/WebDriver/Client.cpp index e3fca074fa..135523651e 100644 --- a/Userland/Libraries/LibWeb/WebDriver/Client.cpp +++ b/Userland/Libraries/LibWeb/WebDriver/Client.cpp @@ -3,7 +3,7 @@ * Copyright (c) 2022, Sam Atkins * Copyright (c) 2022, Tobias Christiansen * Copyright (c) 2022, Linus Groh - * Copyright (c) 2022, Tim Flynn + * Copyright (c) 2022-2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -33,7 +33,7 @@ struct Route { struct MatchedRoute { RouteHandler handler; - Vector parameters; + Vector parameters; }; // clang-format off @@ -112,7 +112,7 @@ static ErrorOr match_route(HTTP::HttpRequest const& request dbgln_if(WEBDRIVER_DEBUG, "match_route({}, {})", HTTP::to_deprecated_string(request.method()), request.resource()); auto request_path = request.resource().view(); - Vector parameters; + Vector parameters; auto next_segment = [](auto& path) -> Optional { if (auto index = path.find('/'); index.has_value() && (*index + 1) < path.length()) { @@ -150,14 +150,14 @@ static ErrorOr match_route(HTTP::HttpRequest const& request else if (request_segment.has_value() != route_segment.has_value()) on_failed_match(); else if (route_segment->starts_with(':')) - parameters.append(*request_segment); + TRY(parameters.try_append(TRY(String::from_utf8(*request_segment)))); else if (request_segment != route_segment) on_failed_match(); } if (*match) { dbgln_if(WEBDRIVER_DEBUG, "- Found match with parameters={}", parameters); - return MatchedRoute { route.handler, parameters }; + return MatchedRoute { route.handler, move(parameters) }; } } @@ -258,8 +258,8 @@ ErrorOr Client::handle_request(JsonValue body) dbgln("Body: {}", body.to_deprecated_string()); } - auto const& [handler, parameters] = TRY(match_route(*m_request)); - auto result = TRY((*handler)(*this, parameters, move(body))); + auto [handler, parameters] = TRY(match_route(*m_request)); + auto result = TRY((*handler)(*this, move(parameters), move(body))); return send_success_response(move(result)); } diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.h b/Userland/Libraries/LibWeb/WebDriver/Client.h index 2f5776ed29..9ae648cce9 100644 --- a/Userland/Libraries/LibWeb/WebDriver/Client.h +++ b/Userland/Libraries/LibWeb/WebDriver/Client.h @@ -1,17 +1,18 @@ /* * Copyright (c) 2022, Florent Castelli * Copyright (c) 2022, Linus Groh - * Copyright (c) 2022, Tim Flynn + * Copyright (c) 2022-2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once -#include #include -#include +#include +#include #include +#include #include #include #include @@ -21,7 +22,7 @@ namespace Web::WebDriver { -using Parameters = ReadonlySpan; +using Parameters = Vector; class Client : public Core::Object { C_OBJECT_ABSTRACT(Client); diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc index cadb84b7ce..411845071c 100644 --- a/Userland/Services/WebContent/WebDriverClient.ipc +++ b/Userland/Services/WebContent/WebDriverClient.ipc @@ -26,36 +26,36 @@ endpoint WebDriverClient { fullscreen_window() => (Web::WebDriver::Response response) find_element(JsonValue payload) => (Web::WebDriver::Response response) find_elements(JsonValue payload) => (Web::WebDriver::Response response) - find_element_from_element(JsonValue payload, DeprecatedString element_id) => (Web::WebDriver::Response response) - find_elements_from_element(JsonValue payload, DeprecatedString element_id) => (Web::WebDriver::Response response) - find_element_from_shadow_root(JsonValue payload, DeprecatedString shadow_id) => (Web::WebDriver::Response response) - find_elements_from_shadow_root(JsonValue payload, DeprecatedString shadow_id) => (Web::WebDriver::Response response) + find_element_from_element(JsonValue payload, String element_id) => (Web::WebDriver::Response response) + find_elements_from_element(JsonValue payload, String element_id) => (Web::WebDriver::Response response) + find_element_from_shadow_root(JsonValue payload, String shadow_id) => (Web::WebDriver::Response response) + find_elements_from_shadow_root(JsonValue payload, String shadow_id) => (Web::WebDriver::Response response) get_active_element() => (Web::WebDriver::Response response) - get_element_shadow_root(DeprecatedString element_id) => (Web::WebDriver::Response response) - is_element_selected(DeprecatedString element_id) => (Web::WebDriver::Response response) - get_element_attribute(DeprecatedString element_id, DeprecatedString name) => (Web::WebDriver::Response response) - get_element_property(DeprecatedString element_id, DeprecatedString name) => (Web::WebDriver::Response response) - get_element_css_value(DeprecatedString element_id, DeprecatedString name) => (Web::WebDriver::Response response) - get_element_text(DeprecatedString element_id) => (Web::WebDriver::Response response) - get_element_tag_name(DeprecatedString element_id) => (Web::WebDriver::Response response) - get_element_rect(DeprecatedString element_id) => (Web::WebDriver::Response response) - is_element_enabled(DeprecatedString element_id) => (Web::WebDriver::Response response) - get_computed_role(DeprecatedString element_id) => (Web::WebDriver::Response response) - get_computed_label(DeprecatedString element_id) => (Web::WebDriver::Response response) - element_click(DeprecatedString element_id) => (Web::WebDriver::Response response) + get_element_shadow_root(String element_id) => (Web::WebDriver::Response response) + is_element_selected(String element_id) => (Web::WebDriver::Response response) + get_element_attribute(String element_id, String name) => (Web::WebDriver::Response response) + get_element_property(String element_id, String name) => (Web::WebDriver::Response response) + get_element_css_value(String element_id, String name) => (Web::WebDriver::Response response) + get_element_text(String element_id) => (Web::WebDriver::Response response) + get_element_tag_name(String element_id) => (Web::WebDriver::Response response) + get_element_rect(String element_id) => (Web::WebDriver::Response response) + is_element_enabled(String element_id) => (Web::WebDriver::Response response) + get_computed_role(String element_id) => (Web::WebDriver::Response response) + get_computed_label(String element_id) => (Web::WebDriver::Response response) + element_click(String element_id) => (Web::WebDriver::Response response) get_source() => (Web::WebDriver::Response response) execute_script(JsonValue payload) => (Web::WebDriver::Response response) execute_async_script(JsonValue payload) => (Web::WebDriver::Response response) get_all_cookies() => (Web::WebDriver::Response response) - get_named_cookie(DeprecatedString name) => (Web::WebDriver::Response response) + get_named_cookie(String name) => (Web::WebDriver::Response response) add_cookie(JsonValue payload) => (Web::WebDriver::Response response) - delete_cookie(DeprecatedString name) => (Web::WebDriver::Response response) + delete_cookie(String name) => (Web::WebDriver::Response response) delete_all_cookies() => (Web::WebDriver::Response response) dismiss_alert() => (Web::WebDriver::Response response) accept_alert() => (Web::WebDriver::Response response) get_alert_text() => (Web::WebDriver::Response response) send_alert_text(JsonValue payload) => (Web::WebDriver::Response response) take_screenshot() => (Web::WebDriver::Response response) - take_element_screenshot(DeprecatedString element_id) => (Web::WebDriver::Response response) + take_element_screenshot(String element_id) => (Web::WebDriver::Response response) print_page() => (Web::WebDriver::Response response) } diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index bc9fcc9514..bb45dfd80f 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -833,7 +833,7 @@ Messages::WebDriverClient::FindElementsResponse WebDriverConnection::find_elemen } // 12.3.4 Find Element From Element, https://w3c.github.io/webdriver/#dfn-find-element-from-element -Messages::WebDriverClient::FindElementFromElementResponse WebDriverConnection::find_element_from_element(JsonValue const& payload, DeprecatedString const& element_id) +Messages::WebDriverClient::FindElementFromElementResponse WebDriverConnection::find_element_from_element(JsonValue const& payload, String const& element_id) { // 1. Let location strategy be the result of getting a property called "using". auto location_strategy_string = TRY(get_property(payload, "using"sv)); @@ -869,7 +869,7 @@ Messages::WebDriverClient::FindElementFromElementResponse WebDriverConnection::f } // 12.3.5 Find Elements From Element, https://w3c.github.io/webdriver/#dfn-find-elements-from-element -Messages::WebDriverClient::FindElementsFromElementResponse WebDriverConnection::find_elements_from_element(JsonValue const& payload, DeprecatedString const& element_id) +Messages::WebDriverClient::FindElementsFromElementResponse WebDriverConnection::find_elements_from_element(JsonValue const& payload, String const& element_id) { // 1. Let location strategy be the result of getting a property called "using". auto location_strategy_string = TRY(get_property(payload, "using"sv)); @@ -899,7 +899,7 @@ Messages::WebDriverClient::FindElementsFromElementResponse WebDriverConnection:: } // 12.3.6 Find Element From Shadow Root, https://w3c.github.io/webdriver/#find-element-from-shadow-root -Messages::WebDriverClient::FindElementFromShadowRootResponse WebDriverConnection::find_element_from_shadow_root(JsonValue const& payload, DeprecatedString const& shadow_id) +Messages::WebDriverClient::FindElementFromShadowRootResponse WebDriverConnection::find_element_from_shadow_root(JsonValue const& payload, String const& shadow_id) { // 1. Let location strategy be the result of getting a property called "using". auto location_strategy_string = TRY(get_property(payload, "using"sv)); @@ -935,7 +935,7 @@ Messages::WebDriverClient::FindElementFromShadowRootResponse WebDriverConnection } // 12.3.7 Find Elements From Shadow Root, https://w3c.github.io/webdriver/#find-elements-from-shadow-root -Messages::WebDriverClient::FindElementsFromShadowRootResponse WebDriverConnection::find_elements_from_shadow_root(JsonValue const& payload, DeprecatedString const& shadow_id) +Messages::WebDriverClient::FindElementsFromShadowRootResponse WebDriverConnection::find_elements_from_shadow_root(JsonValue const& payload, String const& shadow_id) { // 1. Let location strategy be the result of getting a property called "using". auto location_strategy_string = TRY(get_property(payload, "using"sv)); @@ -985,7 +985,7 @@ Messages::WebDriverClient::GetActiveElementResponse WebDriverConnection::get_act } // 12.3.9 Get Element Shadow Root, https://w3c.github.io/webdriver/#get-element-shadow-root -Messages::WebDriverClient::GetElementShadowRootResponse WebDriverConnection::get_element_shadow_root(DeprecatedString const& element_id) +Messages::WebDriverClient::GetElementShadowRootResponse WebDriverConnection::get_element_shadow_root(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1011,7 +1011,7 @@ Messages::WebDriverClient::GetElementShadowRootResponse WebDriverConnection::get } // 12.4.1 Is Element Selected, https://w3c.github.io/webdriver/#dfn-is-element-selected -Messages::WebDriverClient::IsElementSelectedResponse WebDriverConnection::is_element_selected(DeprecatedString const& element_id) +Messages::WebDriverClient::IsElementSelectedResponse WebDriverConnection::is_element_selected(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1047,7 +1047,7 @@ Messages::WebDriverClient::IsElementSelectedResponse WebDriverConnection::is_ele } // 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute -Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_element_attribute(DeprecatedString const& element_id, DeprecatedString const& name) +Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_element_attribute(String const& element_id, String const& name) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1061,16 +1061,18 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_ // 4. Let result be the result of the first matching condition: Optional result; + auto deprecated_name = name.to_deprecated_string(); + // -> If name is a boolean attribute - if (Web::HTML::is_boolean_attribute(name)) { + if (Web::HTML::is_boolean_attribute(deprecated_name)) { // "true" (string) if the element has the attribute, otherwise null. - if (element->has_attribute(name)) + if (element->has_attribute(deprecated_name)) result = "true"sv; } // -> Otherwise else { // The result of getting an attribute by name name. - result = element->get_attribute(name); + result = element->get_attribute(deprecated_name); } // 5. Return success with data result. @@ -1080,7 +1082,7 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_ } // 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property -Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_element_property(DeprecatedString const& element_id, DeprecatedString const& name) +Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_element_property(String const& element_id, String const& name) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1094,7 +1096,7 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e Optional result; // 4. Let property be the result of calling the Object.[[GetProperty]](name) on element. - if (auto property_or_error = element->get(name); !property_or_error.is_throw_completion()) { + if (auto property_or_error = element->get(name.to_deprecated_string()); !property_or_error.is_throw_completion()) { auto property = property_or_error.release_value(); // 5. Let result be the value of property if not undefined, or null. @@ -1111,7 +1113,7 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e } // 12.4.4 Get Element CSS Value, https://w3c.github.io/webdriver/#dfn-get-element-css-value -Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_element_css_value(DeprecatedString const& element_id, DeprecatedString const& name) +Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_element_css_value(String const& element_id, String const& name) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1144,7 +1146,7 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e } // 12.4.5 Get Element Text, https://w3c.github.io/webdriver/#dfn-get-element-text -Messages::WebDriverClient::GetElementTextResponse WebDriverConnection::get_element_text(DeprecatedString const& element_id) +Messages::WebDriverClient::GetElementTextResponse WebDriverConnection::get_element_text(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1163,7 +1165,7 @@ Messages::WebDriverClient::GetElementTextResponse WebDriverConnection::get_eleme } // 12.4.6 Get Element Tag Name, https://w3c.github.io/webdriver/#dfn-get-element-tag-name -Messages::WebDriverClient::GetElementTagNameResponse WebDriverConnection::get_element_tag_name(DeprecatedString const& element_id) +Messages::WebDriverClient::GetElementTagNameResponse WebDriverConnection::get_element_tag_name(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1182,7 +1184,7 @@ Messages::WebDriverClient::GetElementTagNameResponse WebDriverConnection::get_el } // 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect -Messages::WebDriverClient::GetElementRectResponse WebDriverConnection::get_element_rect(DeprecatedString const& element_id) +Messages::WebDriverClient::GetElementRectResponse WebDriverConnection::get_element_rect(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1213,7 +1215,7 @@ Messages::WebDriverClient::GetElementRectResponse WebDriverConnection::get_eleme } // 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled -Messages::WebDriverClient::IsElementEnabledResponse WebDriverConnection::is_element_enabled(DeprecatedString const& element_id) +Messages::WebDriverClient::IsElementEnabledResponse WebDriverConnection::is_element_enabled(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1239,7 +1241,7 @@ Messages::WebDriverClient::IsElementEnabledResponse WebDriverConnection::is_elem } // 12.4.9 Get Computed Role, https://w3c.github.io/webdriver/#dfn-get-computed-role -Messages::WebDriverClient::GetComputedRoleResponse WebDriverConnection::get_computed_role(DeprecatedString const& element_id) +Messages::WebDriverClient::GetComputedRoleResponse WebDriverConnection::get_computed_role(String const& element_id) { // 1. If the current top-level browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1260,7 +1262,7 @@ Messages::WebDriverClient::GetComputedRoleResponse WebDriverConnection::get_comp } // 12.4.10 Get Computed Label, https://w3c.github.io/webdriver/#get-computed-label -Messages::WebDriverClient::GetComputedLabelResponse WebDriverConnection::get_computed_label(DeprecatedString const& element_id) +Messages::WebDriverClient::GetComputedLabelResponse WebDriverConnection::get_computed_label(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1279,7 +1281,7 @@ Messages::WebDriverClient::GetComputedLabelResponse WebDriverConnection::get_com } // 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click -Messages::WebDriverClient::ElementClickResponse WebDriverConnection::element_click(DeprecatedString const& element_id) +Messages::WebDriverClient::ElementClickResponse WebDriverConnection::element_click(String const& element_id) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1521,7 +1523,7 @@ Messages::WebDriverClient::GetAllCookiesResponse WebDriverConnection::get_all_co } // 14.2 Get Named Cookie, https://w3c.github.io/webdriver/#dfn-get-named-cookie -Messages::WebDriverClient::GetNamedCookieResponse WebDriverConnection::get_named_cookie(DeprecatedString const& name) +Messages::WebDriverClient::GetNamedCookieResponse WebDriverConnection::get_named_cookie(String const& name) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1532,7 +1534,7 @@ Messages::WebDriverClient::GetNamedCookieResponse WebDriverConnection::get_named // 3. If the url variable name is equal to a cookie’s cookie name amongst all associated cookies of the current browsing context’s active document, return success with the serialized cookie as data. auto* document = m_page_client.page().top_level_browsing_context().active_document(); - if (auto cookie = m_page_client.page_did_request_named_cookie(document->url(), name); cookie.has_value()) { + if (auto cookie = m_page_client.page_did_request_named_cookie(document->url(), name.to_deprecated_string()); cookie.has_value()) { auto serialized_cookie = serialize_cookie(*cookie); return serialized_cookie; } @@ -1615,7 +1617,7 @@ Messages::WebDriverClient::AddCookieResponse WebDriverConnection::add_cookie(Jso } // 14.4 Delete Cookie, https://w3c.github.io/webdriver/#dfn-delete-cookie -Messages::WebDriverClient::DeleteCookieResponse WebDriverConnection::delete_cookie(DeprecatedString const& name) +Messages::WebDriverClient::DeleteCookieResponse WebDriverConnection::delete_cookie(String const& name) { // 1. If the current browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); @@ -1766,7 +1768,7 @@ Messages::WebDriverClient::TakeScreenshotResponse WebDriverConnection::take_scre } // 17.2 Take Element Screenshot, https://w3c.github.io/webdriver/#dfn-take-element-screenshot -Messages::WebDriverClient::TakeElementScreenshotResponse WebDriverConnection::take_element_screenshot(DeprecatedString const& element_id) +Messages::WebDriverClient::TakeElementScreenshotResponse WebDriverConnection::take_element_screenshot(String const& element_id) { // 1. If the current top-level browsing context is no longer open, return error with error code no such window. TRY(ensure_open_top_level_browsing_context()); diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index e998ebf314..3069014902 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2022, Florent Castelli * Copyright (c) 2022, Linus Groh - * Copyright (c) 2022, Tim Flynn + * Copyright (c) 2022-2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -61,37 +62,37 @@ private: virtual Messages::WebDriverClient::FullscreenWindowResponse fullscreen_window() override; virtual Messages::WebDriverClient::FindElementResponse find_element(JsonValue const& payload) override; virtual Messages::WebDriverClient::FindElementsResponse find_elements(JsonValue const& payload) override; - virtual Messages::WebDriverClient::FindElementFromElementResponse find_element_from_element(JsonValue const& payload, DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::FindElementsFromElementResponse find_elements_from_element(JsonValue const& payload, DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::FindElementFromShadowRootResponse find_element_from_shadow_root(JsonValue const& payload, DeprecatedString const& shadow_id) override; - virtual Messages::WebDriverClient::FindElementsFromShadowRootResponse find_elements_from_shadow_root(JsonValue const& payload, DeprecatedString const& shadow_id) override; + virtual Messages::WebDriverClient::FindElementFromElementResponse find_element_from_element(JsonValue const& payload, String const& element_id) override; + virtual Messages::WebDriverClient::FindElementsFromElementResponse find_elements_from_element(JsonValue const& payload, String const& element_id) override; + virtual Messages::WebDriverClient::FindElementFromShadowRootResponse find_element_from_shadow_root(JsonValue const& payload, String const& shadow_id) override; + virtual Messages::WebDriverClient::FindElementsFromShadowRootResponse find_elements_from_shadow_root(JsonValue const& payload, String const& shadow_id) override; virtual Messages::WebDriverClient::GetActiveElementResponse get_active_element() override; - virtual Messages::WebDriverClient::GetElementShadowRootResponse get_element_shadow_root(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::IsElementSelectedResponse is_element_selected(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::GetElementAttributeResponse get_element_attribute(DeprecatedString const& element_id, DeprecatedString const& name) override; - virtual Messages::WebDriverClient::GetElementPropertyResponse get_element_property(DeprecatedString const& element_id, DeprecatedString const& name) override; - virtual Messages::WebDriverClient::GetElementCssValueResponse get_element_css_value(DeprecatedString const& element_id, DeprecatedString const& name) override; - virtual Messages::WebDriverClient::GetElementTextResponse get_element_text(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::GetElementTagNameResponse get_element_tag_name(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::GetElementRectResponse get_element_rect(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::IsElementEnabledResponse is_element_enabled(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::GetComputedRoleResponse get_computed_role(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::GetComputedLabelResponse get_computed_label(DeprecatedString const& element_id) override; - virtual Messages::WebDriverClient::ElementClickResponse element_click(DeprecatedString const& element_id) override; + virtual Messages::WebDriverClient::GetElementShadowRootResponse get_element_shadow_root(String const& element_id) override; + virtual Messages::WebDriverClient::IsElementSelectedResponse is_element_selected(String const& element_id) override; + virtual Messages::WebDriverClient::GetElementAttributeResponse get_element_attribute(String const& element_id, String const& name) override; + virtual Messages::WebDriverClient::GetElementPropertyResponse get_element_property(String const& element_id, String const& name) override; + virtual Messages::WebDriverClient::GetElementCssValueResponse get_element_css_value(String const& element_id, String const& name) override; + virtual Messages::WebDriverClient::GetElementTextResponse get_element_text(String const& element_id) override; + virtual Messages::WebDriverClient::GetElementTagNameResponse get_element_tag_name(String const& element_id) override; + virtual Messages::WebDriverClient::GetElementRectResponse get_element_rect(String const& element_id) override; + virtual Messages::WebDriverClient::IsElementEnabledResponse is_element_enabled(String const& element_id) override; + virtual Messages::WebDriverClient::GetComputedRoleResponse get_computed_role(String const& element_id) override; + virtual Messages::WebDriverClient::GetComputedLabelResponse get_computed_label(String const& element_id) override; + virtual Messages::WebDriverClient::ElementClickResponse element_click(String const& element_id) override; virtual Messages::WebDriverClient::GetSourceResponse get_source() override; virtual Messages::WebDriverClient::ExecuteScriptResponse execute_script(JsonValue const& payload) override; virtual Messages::WebDriverClient::ExecuteAsyncScriptResponse execute_async_script(JsonValue const& payload) override; virtual Messages::WebDriverClient::GetAllCookiesResponse get_all_cookies() override; - virtual Messages::WebDriverClient::GetNamedCookieResponse get_named_cookie(DeprecatedString const& name) override; + virtual Messages::WebDriverClient::GetNamedCookieResponse get_named_cookie(String const& name) override; virtual Messages::WebDriverClient::AddCookieResponse add_cookie(JsonValue const& payload) override; - virtual Messages::WebDriverClient::DeleteCookieResponse delete_cookie(DeprecatedString const& name) override; + virtual Messages::WebDriverClient::DeleteCookieResponse delete_cookie(String const& name) override; virtual Messages::WebDriverClient::DeleteAllCookiesResponse delete_all_cookies() override; virtual Messages::WebDriverClient::DismissAlertResponse dismiss_alert() override; virtual Messages::WebDriverClient::AcceptAlertResponse accept_alert() override; virtual Messages::WebDriverClient::GetAlertTextResponse get_alert_text() override; virtual Messages::WebDriverClient::SendAlertTextResponse send_alert_text(JsonValue const& payload) override; virtual Messages::WebDriverClient::TakeScreenshotResponse take_screenshot() override; - virtual Messages::WebDriverClient::TakeElementScreenshotResponse take_element_screenshot(DeprecatedString const& element_id) override; + virtual Messages::WebDriverClient::TakeElementScreenshotResponse take_element_screenshot(String const& element_id) override; virtual Messages::WebDriverClient::PrintPageResponse print_page() override; ErrorOr ensure_open_top_level_browsing_context(); diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index 5556d844cc..ba352bb2c1 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -3,7 +3,7 @@ * Copyright (c) 2022, Sam Atkins * Copyright (c) 2022, Tobias Christiansen * Copyright (c) 2022, Linus Groh - * Copyright (c) 2022, Tim Flynn + * Copyright (c) 2022-2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -413,7 +413,7 @@ Web::WebDriver::Response Client::find_element_from_element(Web::WebDriver::Param { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session//element//element"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().find_element_from_element(payload, parameters[1]); + return session->web_content_connection().find_element_from_element(payload, move(parameters[1])); } // 12.3.5 Find Elements From Element, https://w3c.github.io/webdriver/#dfn-find-elements-from-element @@ -422,7 +422,7 @@ Web::WebDriver::Response Client::find_elements_from_element(Web::WebDriver::Para { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session//element//elements"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().find_elements_from_element(payload, parameters[1]); + return session->web_content_connection().find_elements_from_element(payload, move(parameters[1])); } // 12.3.6 Find Element From Shadow Root, https://w3c.github.io/webdriver/#find-element-from-shadow-root @@ -431,7 +431,7 @@ Web::WebDriver::Response Client::find_element_from_shadow_root(Web::WebDriver::P { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session//shadow//element"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().find_element_from_shadow_root(payload, parameters[1]); + return session->web_content_connection().find_element_from_shadow_root(payload, move(parameters[1])); } // 12.3.7 Find Elements From Shadow Root, https://w3c.github.io/webdriver/#find-elements-from-shadow-root @@ -440,7 +440,7 @@ Web::WebDriver::Response Client::find_elements_from_shadow_root(Web::WebDriver:: { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session//shadow//elements"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().find_elements_from_shadow_root(payload, parameters[1]); + return session->web_content_connection().find_elements_from_shadow_root(payload, move(parameters[1])); } // 12.3.8 Get Active Element, https://w3c.github.io/webdriver/#get-active-element @@ -458,7 +458,7 @@ Web::WebDriver::Response Client::get_element_shadow_root(Web::WebDriver::Paramet { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//shadow"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_shadow_root(parameters[1]); + return session->web_content_connection().get_element_shadow_root(move(parameters[1])); } // 12.4.1 Is Element Selected, https://w3c.github.io/webdriver/#dfn-is-element-selected @@ -467,7 +467,7 @@ Web::WebDriver::Response Client::is_element_selected(Web::WebDriver::Parameters { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//selected"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().is_element_selected(parameters[1]); + return session->web_content_connection().is_element_selected(move(parameters[1])); } // 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute @@ -476,7 +476,7 @@ Web::WebDriver::Response Client::get_element_attribute(Web::WebDriver::Parameter { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//attribute/"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_attribute(parameters[1], parameters[2]); + return session->web_content_connection().get_element_attribute(move(parameters[1]), move(parameters[2])); } // 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property @@ -485,7 +485,7 @@ Web::WebDriver::Response Client::get_element_property(Web::WebDriver::Parameters { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//property/"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_property(parameters[1], parameters[2]); + return session->web_content_connection().get_element_property(move(parameters[1]), move(parameters[2])); } // 12.4.4 Get Element CSS Value, https://w3c.github.io/webdriver/#dfn-get-element-css-value @@ -494,7 +494,7 @@ Web::WebDriver::Response Client::get_element_css_value(Web::WebDriver::Parameter { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//css/"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_css_value(parameters[1], parameters[2]); + return session->web_content_connection().get_element_css_value(move(parameters[1]), move(parameters[2])); } // 12.4.5 Get Element Text, https://w3c.github.io/webdriver/#dfn-get-element-text @@ -503,7 +503,7 @@ Web::WebDriver::Response Client::get_element_text(Web::WebDriver::Parameters par { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//text"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_text(parameters[1]); + return session->web_content_connection().get_element_text(move(parameters[1])); } // 12.4.6 Get Element Tag Name, https://w3c.github.io/webdriver/#dfn-get-element-tag-name @@ -512,7 +512,7 @@ Web::WebDriver::Response Client::get_element_tag_name(Web::WebDriver::Parameters { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//name"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_tag_name(parameters[1]); + return session->web_content_connection().get_element_tag_name(move(parameters[1])); } // 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect @@ -521,7 +521,7 @@ Web::WebDriver::Response Client::get_element_rect(Web::WebDriver::Parameters par { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//rect"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_element_rect(parameters[1]); + return session->web_content_connection().get_element_rect(move(parameters[1])); } // 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled @@ -530,7 +530,7 @@ Web::WebDriver::Response Client::is_element_enabled(Web::WebDriver::Parameters p { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//enabled"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().is_element_enabled(parameters[1]); + return session->web_content_connection().is_element_enabled(move(parameters[1])); } // 12.4.9 https://w3c.github.io/webdriver/#dfn-get-computed-role @@ -539,7 +539,7 @@ Web::WebDriver::Response Client::get_computed_role(Web::WebDriver::Parameters pa { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//computedrole"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_computed_role(parameters[1]); + return session->web_content_connection().get_computed_role(move(parameters[1])); } // 12.4.10 Get Computed Label, https://w3c.github.io/webdriver/#get-computed-label @@ -548,7 +548,7 @@ Web::WebDriver::Response Client::get_computed_label(Web::WebDriver::Parameters p { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//computedlabel"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_computed_label(parameters[1]); + return session->web_content_connection().get_computed_label(move(parameters[1])); } // 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click @@ -557,7 +557,7 @@ Web::WebDriver::Response Client::element_click(Web::WebDriver::Parameters parame { dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session//element//click"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().element_click(parameters[1]); + return session->web_content_connection().element_click(move(parameters[1])); } // 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source @@ -602,7 +602,7 @@ Web::WebDriver::Response Client::get_named_cookie(Web::WebDriver::Parameters par { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//cookie/"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().get_named_cookie(parameters[1]); + return session->web_content_connection().get_named_cookie(move(parameters[1])); } // 14.3 Add Cookie, https://w3c.github.io/webdriver/#dfn-adding-a-cookie @@ -620,7 +620,7 @@ Web::WebDriver::Response Client::delete_cookie(Web::WebDriver::Parameters parame { dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session//cookie/"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().delete_cookie(parameters[1]); + return session->web_content_connection().delete_cookie(move(parameters[1])); } // 14.5 Delete All Cookies, https://w3c.github.io/webdriver/#dfn-delete-all-cookies @@ -683,7 +683,7 @@ Web::WebDriver::Response Client::take_element_screenshot(Web::WebDriver::Paramet { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session//element//screenshot"); auto* session = TRY(find_session_with_id(parameters[0])); - return session->web_content_connection().take_element_screenshot(parameters[1]); + return session->web_content_connection().take_element_screenshot(move(parameters[1])); } // 18.1 Print Page, https://w3c.github.io/webdriver/#dfn-print-page