mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 09:14:21 +03:00
LibWeb+WebContent+WebDriver: Port WebDriver parameters to String
This changes the parameters parsed from a WebDriver HTTP request to String for transferring over IPC. Conveniently, most locations these were ultimately passed to only need a StringView.
This commit is contained in:
parent
03d0be13e8
commit
77fbd912b7
Notes:
sideshowbarker
2024-07-17 06:29:49 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/77fbd912b7 Pull-request: https://github.com/SerenityOS/serenity/pull/17730 Reviewed-by: https://github.com/linusg
@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@ -33,7 +33,7 @@ struct Route {
|
||||
|
||||
struct MatchedRoute {
|
||||
RouteHandler handler;
|
||||
Vector<StringView> parameters;
|
||||
Vector<String> parameters;
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
@ -112,7 +112,7 @@ static ErrorOr<MatchedRoute, Error> 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<StringView> parameters;
|
||||
Vector<String> parameters;
|
||||
|
||||
auto next_segment = [](auto& path) -> Optional<StringView> {
|
||||
if (auto index = path.find('/'); index.has_value() && (*index + 1) < path.length()) {
|
||||
@ -150,14 +150,14 @@ static ErrorOr<MatchedRoute, Error> 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<void, Client::WrappedError> 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));
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibHTTP/Forward.h>
|
||||
@ -21,7 +22,7 @@
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
using Parameters = ReadonlySpan<StringView>;
|
||||
using Parameters = Vector<String>;
|
||||
|
||||
class Client : public Core::Object {
|
||||
C_OBJECT_ABSTRACT(Client);
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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<DeprecatedString> 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<DeprecatedString> 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());
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@ -11,6 +11,7 @@
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibIPC/ConnectionToServer.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/MarkedVector.h>
|
||||
@ -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<void, Web::WebDriver::Error> ensure_open_top_level_browsing_context();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* 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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/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/<session_id>/shadow/<shadow_id>/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/<session_id>/shadow/<shadow_id>/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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/attribute/<name>");
|
||||
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/<session_id>/element/<element_id>/property/<name>");
|
||||
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/<session_id>/element/<element_id>/css/<property_name>");
|
||||
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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/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/<session_id>/element/<element_id>/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/<session id>/element/<element id>/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/<session id>/element/<element id>/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/<session_id>/element/<element_id>/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/<session_id>/cookie/<name>");
|
||||
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/<session_id>/cookie/<name>");
|
||||
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/<session_id>/element/<element_id>/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
|
||||
|
Loading…
Reference in New Issue
Block a user