mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb+WebDriver: Add an IPC-transferable Web::WebDriver::Response class
This is essentially an ErrorOr<JsonValue, Web::WebDriver::Error> class. Unfortunately, that ErrorOr would not be default-constructible, which is required for the generated IPC classes. So this is a thin wrapper around a Variant<JsonValue, Web::WebDriver::Error> to emulate ErrorOr.
This commit is contained in:
parent
0246abec80
commit
8ae10ba0fd
Notes:
sideshowbarker
2024-07-17 06:51:40 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8ae10ba0fd Pull-request: https://github.com/SerenityOS/serenity/pull/15981 Reviewed-by: https://github.com/linusg ✅
7 changed files with 291 additions and 160 deletions
|
@ -440,6 +440,7 @@ set(SOURCES
|
|||
WebAssembly/WebAssemblyTablePrototype.cpp
|
||||
WebDriver/Error.cpp
|
||||
WebDriver/ExecuteScript.cpp
|
||||
WebDriver/Response.cpp
|
||||
WebGL/WebGLContextAttributes.cpp
|
||||
WebGL/WebGLContextEvent.cpp
|
||||
WebGL/WebGLRenderingContext.cpp
|
||||
|
|
76
Userland/Libraries/LibWeb/WebDriver/Response.cpp
Normal file
76
Userland/Libraries/LibWeb/WebDriver/Response.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibWeb/WebDriver/Response.h>
|
||||
|
||||
enum class ResponseType : u8 {
|
||||
Success,
|
||||
Error,
|
||||
};
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
Response::Response(JsonValue&& value)
|
||||
: m_value_or_error(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
Response::Response(Error&& error)
|
||||
: m_value_or_error(move(error))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IPC::encode(Encoder& encoder, Web::WebDriver::Response const& response)
|
||||
{
|
||||
response.visit(
|
||||
[](Empty) { VERIFY_NOT_REACHED(); },
|
||||
[&](JsonValue const& value) {
|
||||
encoder << ResponseType::Success;
|
||||
encoder << value;
|
||||
},
|
||||
[&](Web::WebDriver::Error const& error) {
|
||||
encoder << ResponseType::Error;
|
||||
encoder << error.http_status;
|
||||
encoder << error.error;
|
||||
encoder << error.message;
|
||||
encoder << error.data;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<void> IPC::decode(Decoder& decoder, Web::WebDriver::Response& response)
|
||||
{
|
||||
ResponseType type {};
|
||||
TRY(decoder.decode(type));
|
||||
|
||||
switch (type) {
|
||||
case ResponseType::Success: {
|
||||
JsonValue value;
|
||||
TRY(decoder.decode(value));
|
||||
|
||||
response = move(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case ResponseType::Error: {
|
||||
Web::WebDriver::Error error {};
|
||||
TRY(decoder.decode(error.http_status));
|
||||
TRY(decoder.decode(error.error));
|
||||
TRY(decoder.decode(error.message));
|
||||
TRY(decoder.decode(error.data));
|
||||
|
||||
response = move(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
52
Userland/Libraries/LibWeb/WebDriver/Response.h
Normal file
52
Userland/Libraries/LibWeb/WebDriver/Response.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibWeb/WebDriver/Error.h>
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
// FIXME: Ideally, this could be `using Response = ErrorOr<JsonValue, Error>`, but that won't be
|
||||
// default-constructible, which is a requirement for the generated IPC.
|
||||
struct Response {
|
||||
Response() = default;
|
||||
Response(JsonValue&&);
|
||||
Response(Error&&);
|
||||
|
||||
JsonValue& value() { return m_value_or_error.template get<JsonValue>(); }
|
||||
JsonValue const& value() const { return m_value_or_error.template get<JsonValue>(); }
|
||||
|
||||
Error& error() { return m_value_or_error.template get<Error>(); }
|
||||
Error const& error() const { return m_value_or_error.template get<Error>(); }
|
||||
|
||||
bool is_error() const { return m_value_or_error.template has<Error>(); }
|
||||
|
||||
JsonValue release_value() { return move(value()); }
|
||||
Error release_error() { return move(error()); }
|
||||
|
||||
template<typename... Visitors>
|
||||
decltype(auto) visit(Visitors&&... visitors) const
|
||||
{
|
||||
return m_value_or_error.visit(forward<Visitors>(visitors)...);
|
||||
}
|
||||
|
||||
private:
|
||||
// Note: Empty is only a possible state until the Response has been decoded by IPC.
|
||||
Variant<Empty, JsonValue, Error> m_value_or_error;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
bool encode(Encoder&, Web::WebDriver::Response const&);
|
||||
ErrorOr<void> decode(Decoder&, Web::WebDriver::Response&);
|
||||
|
||||
}
|
|
@ -352,7 +352,7 @@ JsonValue Client::make_json_value(JsonValue const& value)
|
|||
|
||||
// 8.1 New Session, https://w3c.github.io/webdriver/#dfn-new-sessions
|
||||
// POST /session
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_new_session(Vector<StringView> const&, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_new_session(Vector<StringView> const&, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session");
|
||||
|
||||
|
@ -418,7 +418,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_new_session(Vector<Stri
|
|||
|
||||
// 8.2 Delete Session, https://w3c.github.io/webdriver/#dfn-delete-session
|
||||
// DELETE /session/{session id}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_session(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_delete_session(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/<session_id>");
|
||||
|
||||
|
@ -435,7 +435,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_session(Vector<S
|
|||
|
||||
// 8.3 Status, https://w3c.github.io/webdriver/#dfn-status
|
||||
// GET /status
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_status(Vector<StringView> const&, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_status(Vector<StringView> const&, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /status");
|
||||
|
||||
|
@ -450,12 +450,12 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_status(Vector<Strin
|
|||
body.set("message", "Ready to start some sessions!");
|
||||
|
||||
// 2. Return success with data body.
|
||||
return body;
|
||||
return JsonValue { body };
|
||||
}
|
||||
|
||||
// 9.1 Get Timeouts, https://w3c.github.io/webdriver/#dfn-get-timeouts
|
||||
// GET /session/{session id}/timeouts
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_timeouts(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_timeouts(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session id>/timeouts");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -465,7 +465,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_timeouts(Vector<Str
|
|||
|
||||
// 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts
|
||||
// POST /session/{session id}/timeouts
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_set_timeouts(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_set_timeouts(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session id>/timeouts");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -475,7 +475,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_set_timeouts(Vector<Str
|
|||
|
||||
// 10.1 Navigate To, https://w3c.github.io/webdriver/#dfn-navigate-to
|
||||
// POST /session/{session id}/url
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_navigate_to(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_navigate_to(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/url");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -485,7 +485,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_navigate_to(Vector<Stri
|
|||
|
||||
// 10.2 Get Current URL, https://w3c.github.io/webdriver/#dfn-get-current-url
|
||||
// GET /session/{session id}/url
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_current_url(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_current_url(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/url");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -495,7 +495,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_current_url(Vector<
|
|||
|
||||
// 10.3 Back, https://w3c.github.io/webdriver/#dfn-back
|
||||
// POST /session/{session id}/back
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_back(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_back(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/back");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -505,7 +505,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_back(Vector<StringView>
|
|||
|
||||
// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
|
||||
// POST /session/{session id}/forward
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_forward(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_forward(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/forward");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -515,7 +515,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_forward(Vector<StringVi
|
|||
|
||||
// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
|
||||
// POST /session/{session id}/refresh
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_refresh(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_refresh(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/refresh");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -525,7 +525,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_refresh(Vector<StringVi
|
|||
|
||||
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title
|
||||
// GET /session/{session id}/title
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_title(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_title(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/title");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -535,7 +535,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_title(Vector<String
|
|||
|
||||
// 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle
|
||||
// GET /session/{session id}/window
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_handle(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_window_handle(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/window");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -545,7 +545,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_handle(Vecto
|
|||
|
||||
// 11.2 Close Window, https://w3c.github.io/webdriver/#dfn-close-window
|
||||
// DELETE /session/{session id}/window
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_close_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_close_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/<session_id>/window");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -555,7 +555,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_close_window(Vector<Str
|
|||
|
||||
// 11.4 Get Window Handles, https://w3c.github.io/webdriver/#dfn-get-window-handles
|
||||
// GET /session/{session id}/window/handles
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_handles(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_window_handles(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/window/handles");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -565,7 +565,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_handles(Vect
|
|||
|
||||
// 11.8.1 Get Window Rect, https://w3c.github.io/webdriver/#dfn-get-window-rect
|
||||
// GET /session/{session id}/window/rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_rect(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_window_rect(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/window/rect");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -575,7 +575,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_window_rect(Vector<
|
|||
|
||||
// 11.8.2 Set Window Rect, https://w3c.github.io/webdriver/#dfn-set-window-rect
|
||||
// POST /session/{session id}/window/rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_set_window_rect(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_set_window_rect(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/window/rect");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -585,7 +585,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_set_window_rect(Vector<
|
|||
|
||||
// 11.8.3 Maximize Window, https://w3c.github.io/webdriver/#dfn-maximize-window
|
||||
// POST /session/{session id}/window/maximize
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_maximize_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_maximize_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/window/maximize");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -595,7 +595,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_maximize_window(Vector<
|
|||
|
||||
// 11.8.4 Minimize Window, https://w3c.github.io/webdriver/#minimize-window
|
||||
// POST /session/{session id}/window/minimize
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_minimize_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_minimize_window(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/window/minimize");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -605,7 +605,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_minimize_window(Vector<
|
|||
|
||||
// 12.3.2 Find Element, https://w3c.github.io/webdriver/#dfn-find-element
|
||||
// POST /session/{session id}/element
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_find_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/element");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -615,7 +615,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_element(Vector<Str
|
|||
|
||||
// 12.3.3 Find Elements, https://w3c.github.io/webdriver/#dfn-find-elements
|
||||
// POST /session/{session id}/elements
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_elements(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_find_elements(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/elements");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -625,7 +625,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_elements(Vector<St
|
|||
|
||||
// 12.3.4 Find Element From Element, https://w3c.github.io/webdriver/#dfn-find-element-from-element
|
||||
// POST /session/{session id}/element/{element id}/element
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_element_from_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_find_element_from_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/element/<element_id>/element");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -635,7 +635,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_element_from_eleme
|
|||
|
||||
// 12.3.5 Find Elements From Element, https://w3c.github.io/webdriver/#dfn-find-elements-from-element
|
||||
// POST /session/{session id}/element/{element id}/elements
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_elements_from_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_find_elements_from_element(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/element/<element_id>/elements");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -645,7 +645,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_find_elements_from_elem
|
|||
|
||||
// 12.4.1 Is Element Selected, https://w3c.github.io/webdriver/#dfn-is-element-selected
|
||||
// GET /session/{session id}/element/{element id}/selected
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_is_element_selected(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_is_element_selected(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/selected");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -655,7 +655,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_is_element_selected(Vec
|
|||
|
||||
// 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute
|
||||
// GET /session/{session id}/element/{element id}/attribute/{name}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_attribute(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_attribute(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/attribute/<name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -665,7 +665,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_attribute(V
|
|||
|
||||
// 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property
|
||||
// GET /session/{session id}/element/{element id}/property/{name}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_property(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_property(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/property/<name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -675,7 +675,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_property(Ve
|
|||
|
||||
// 12.4.4 Get Element CSS Value, https://w3c.github.io/webdriver/#dfn-get-element-css-value
|
||||
// GET /session/{session id}/element/{element id}/css/{property name}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_css_value(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_css_value(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/css/<property_name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -685,7 +685,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_css_value(V
|
|||
|
||||
// 12.4.5 Get Element Text, https://w3c.github.io/webdriver/#dfn-get-element-text
|
||||
// GET /session/{session id}/element/{element id}/text
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_text(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_text(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/text");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -695,7 +695,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_text(Vector
|
|||
|
||||
// 12.4.6 Get Element Tag Name, https://w3c.github.io/webdriver/#dfn-get-element-tag-name
|
||||
// GET /session/{session id}/element/{element id}/name
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_tag_name(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_get_element_tag_name(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/name");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -705,7 +705,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_tag_name(Ve
|
|||
|
||||
// 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect
|
||||
// GET /session/{session id}/element/{element id}/rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_rect(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_element_rect(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/rect");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -715,7 +715,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_element_rect(Vector
|
|||
|
||||
// 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled
|
||||
// GET /session/{session id}/element/{element id}/enabled
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_is_element_enabled(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_is_element_enabled(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/enabled");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -725,7 +725,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_is_element_enabled(Vect
|
|||
|
||||
// 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source
|
||||
// GET /session/{session id}/source
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_source(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_source(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/source");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -735,7 +735,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_source(Vector<Strin
|
|||
|
||||
// 13.2.1 Execute Script, https://w3c.github.io/webdriver/#dfn-execute-script
|
||||
// POST /session/{session id}/execute/sync
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_execute_script(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_execute_script(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/execute/sync");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -745,7 +745,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_execute_script(Vector<S
|
|||
|
||||
// 13.2.2 Execute Async Script, https://w3c.github.io/webdriver/#dfn-execute-async-script
|
||||
// POST /session/{session id}/execute/async
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_execute_async_script(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_execute_async_script(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/execute/async");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -755,7 +755,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_execute_async_script(Ve
|
|||
|
||||
// 14.1 Get All Cookies, https://w3c.github.io/webdriver/#dfn-get-all-cookies
|
||||
// GET /session/{session id}/cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_all_cookies(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_all_cookies(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/cookie");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -765,7 +765,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_all_cookies(Vector<
|
|||
|
||||
// 14.2 Get Named Cookie, https://w3c.github.io/webdriver/#dfn-get-named-cookie
|
||||
// GET /session/{session id}/cookie/{name}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_named_cookie(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_get_named_cookie(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/cookie/<name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -775,7 +775,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_get_named_cookie(Vector
|
|||
|
||||
// 14.3 Add Cookie, https://w3c.github.io/webdriver/#dfn-adding-a-cookie
|
||||
// POST /session/{session id}/cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_add_cookie(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
Web::WebDriver::Response Client::handle_add_cookie(Vector<StringView> const& parameters, JsonValue const& payload)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/cookie");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -785,7 +785,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_add_cookie(Vector<Strin
|
|||
|
||||
// 14.4 Delete Cookie, https://w3c.github.io/webdriver/#dfn-delete-cookie
|
||||
// DELETE /session/{session id}/cookie/{name}
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_cookie(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_delete_cookie(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/<session_id>/cookie/<name>");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -795,7 +795,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_cookie(Vector<St
|
|||
|
||||
// 14.5 Delete All Cookies, https://w3c.github.io/webdriver/#dfn-delete-all-cookies
|
||||
// DELETE /session/{session id}/cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_all_cookies(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_delete_all_cookies(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/<session_id>/cookie");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -805,7 +805,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_delete_all_cookies(Vect
|
|||
|
||||
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
|
||||
// GET /session/{session id}/screenshot
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_take_screenshot(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_take_screenshot(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/screenshot");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
@ -815,7 +815,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_take_screenshot(Vector<
|
|||
|
||||
// 17.2 Take Element Screenshot, https://w3c.github.io/webdriver/#dfn-take-element-screenshot
|
||||
// GET /session/{session id}/element/{element id}/screenshot
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Client::handle_take_element_screenshot(Vector<StringView> const& parameters, JsonValue const&)
|
||||
Web::WebDriver::Response Client::handle_take_element_screenshot(Vector<StringView> const& parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/screenshot");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <LibHTTP/Forward.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
#include <LibWeb/WebDriver/Error.h>
|
||||
#include <LibWeb/WebDriver/Response.h>
|
||||
#include <WebDriver/Session.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
@ -35,7 +36,7 @@ private:
|
|||
void die();
|
||||
void log_response(unsigned code, HTTP::HttpRequest const&);
|
||||
|
||||
using RouteHandler = ErrorOr<JsonValue, Web::WebDriver::Error> (Client::*)(Vector<StringView> const&, JsonValue const&);
|
||||
using RouteHandler = Web::WebDriver::Response (Client::*)(Vector<StringView> const&, JsonValue const&);
|
||||
struct Route {
|
||||
HTTP::HttpRequest::Method method;
|
||||
Vector<String> path;
|
||||
|
@ -48,46 +49,46 @@ private:
|
|||
};
|
||||
|
||||
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);
|
||||
Web::WebDriver::Response handle_new_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_delete_session(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_status(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_set_timeouts(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_navigate_to(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_current_url(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_back(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_forward(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_refresh(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_title(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_window_handle(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_close_window(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_window_handles(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_window_rect(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_set_window_rect(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_maximize_window(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_minimize_window(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_find_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_find_elements(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_find_element_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_find_elements_from_element(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_is_element_selected(Vector<StringView> const& parameters, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_attribute(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_property(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_css_value(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_text(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_tag_name(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_element_rect(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_is_element_enabled(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_source(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_execute_script(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_execute_async_script(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_get_named_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_add_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_delete_cookie(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_delete_all_cookies(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response handle_take_screenshot(Vector<StringView> const&, JsonValue const& payload);
|
||||
Web::WebDriver::Response 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&);
|
||||
|
|
|
@ -107,7 +107,7 @@ JsonObject Session::get_timeouts()
|
|||
}
|
||||
|
||||
// 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::set_timeouts(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::set_timeouts(JsonValue const& payload)
|
||||
{
|
||||
// 1. Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the request’s parameters.
|
||||
auto timeouts = TRY(json_deserialize_as_a_timeouts_configuration(payload));
|
||||
|
@ -120,7 +120,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::set_timeouts(JsonValue const&
|
|||
}
|
||||
|
||||
// 10.1 Navigate To, https://w3c.github.io/webdriver/#dfn-navigate-to
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::navigate_to(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::navigate_to(JsonValue const& payload)
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -154,7 +154,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::navigate_to(JsonValue const&
|
|||
}
|
||||
|
||||
// 10.2 Get Current URL, https://w3c.github.io/webdriver/#dfn-get-current-url
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_current_url()
|
||||
Web::WebDriver::Response Session::get_current_url()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -169,7 +169,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_current_url()
|
|||
}
|
||||
|
||||
// 10.3 Back, https://w3c.github.io/webdriver/#dfn-back
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::back()
|
||||
Web::WebDriver::Response Session::back()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -190,7 +190,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::back()
|
|||
}
|
||||
|
||||
// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::forward()
|
||||
Web::WebDriver::Response Session::forward()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -211,7 +211,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::forward()
|
|||
}
|
||||
|
||||
// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::refresh()
|
||||
Web::WebDriver::Response Session::refresh()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -234,7 +234,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::refresh()
|
|||
}
|
||||
|
||||
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_title()
|
||||
Web::WebDriver::Response Session::get_title()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -247,13 +247,13 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_title()
|
|||
}
|
||||
|
||||
// 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_window_handle()
|
||||
Web::WebDriver::Response Session::get_window_handle()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
||||
// 2. Return success with data being the window handle associated with the current top-level browsing context.
|
||||
return m_current_window_handle;
|
||||
return JsonValue { m_current_window_handle };
|
||||
}
|
||||
|
||||
// 11.2 Close Window, https://w3c.github.io/webdriver/#dfn-close-window
|
||||
|
@ -277,7 +277,7 @@ ErrorOr<void, Variant<Web::WebDriver::Error, Error>> Session::close_window()
|
|||
}
|
||||
|
||||
// 11.4 Get Window Handles, https://w3c.github.io/webdriver/#dfn-get-window-handles
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_window_handles() const
|
||||
Web::WebDriver::Response Session::get_window_handles() const
|
||||
{
|
||||
// 1. Let handles be a JSON List.
|
||||
auto handles = JsonArray {};
|
||||
|
@ -287,10 +287,10 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_window_handles() const
|
|||
handles.append(window_handle);
|
||||
|
||||
// 3. Return success with data handles.
|
||||
return handles;
|
||||
return JsonValue { handles };
|
||||
}
|
||||
|
||||
static JsonObject serialize_rect(Gfx::IntRect const& rect)
|
||||
static JsonValue serialize_rect(Gfx::IntRect const& rect)
|
||||
{
|
||||
JsonObject serialized_rect = {};
|
||||
serialized_rect.set("x", rect.x());
|
||||
|
@ -302,7 +302,7 @@ static JsonObject serialize_rect(Gfx::IntRect const& rect)
|
|||
}
|
||||
|
||||
// 11.8.1 Get Window Rect, https://w3c.github.io/webdriver/#dfn-get-window-rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_window_rect()
|
||||
Web::WebDriver::Response Session::get_window_rect()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -314,7 +314,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_window_rect()
|
|||
}
|
||||
|
||||
// 11.8.2 Set Window Rect, https://w3c.github.io/webdriver/#dfn-set-window-rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::set_window_rect(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::set_window_rect(JsonValue const& payload)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
|
||||
|
@ -386,7 +386,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::set_window_rect(JsonValue con
|
|||
}
|
||||
|
||||
// 11.8.3 Maximize Window, https://w3c.github.io/webdriver/#dfn-maximize-window
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::maximize_window()
|
||||
Web::WebDriver::Response Session::maximize_window()
|
||||
{
|
||||
// 1. If the remote end does not support the Maximize Window command for the current top-level browsing context for any reason, return error with error code unsupported operation.
|
||||
|
||||
|
@ -407,7 +407,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::maximize_window()
|
|||
}
|
||||
|
||||
// 11.8.4 Minimize Window, https://w3c.github.io/webdriver/#minimize-window
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::minimize_window()
|
||||
Web::WebDriver::Response Session::minimize_window()
|
||||
{
|
||||
// 1. If the remote end does not support the Minimize Window command for the current top-level browsing context for any reason, return error with error code unsupported operation.
|
||||
|
||||
|
@ -561,7 +561,7 @@ ErrorOr<Vector<Session::LocalElement>, Web::WebDriver::Error> Session::locator_s
|
|||
}
|
||||
|
||||
// 12.3.2 Find Element, https://w3c.github.io/webdriver/#dfn-find-element
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_element(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::find_element(JsonValue const& payload)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
|
||||
|
@ -616,7 +616,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_element(JsonValue const&
|
|||
}
|
||||
|
||||
// 12.3.3 Find Elements, https://w3c.github.io/webdriver/#dfn-find-elements
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_elements(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::find_elements(JsonValue const& payload)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
|
||||
|
@ -666,7 +666,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_elements(JsonValue const
|
|||
}
|
||||
|
||||
// 12.3.4 Find Element From Element, https://w3c.github.io/webdriver/#dfn-find-element-from-element
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_element_from_element(JsonValue const& payload, StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::find_element_from_element(JsonValue const& payload, StringView parameter_element_id)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
|
||||
|
@ -715,7 +715,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_element_from_element(Jso
|
|||
}
|
||||
|
||||
// 12.3.5 Find Elements From Element, https://w3c.github.io/webdriver/#dfn-find-elements-from-element
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_elements_from_element(JsonValue const& payload, StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::find_elements_from_element(JsonValue const& payload, StringView parameter_element_id)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload is not a JSON object");
|
||||
|
@ -759,7 +759,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::find_elements_from_element(Js
|
|||
}
|
||||
|
||||
// 12.4.1 Is Element Selected, https://w3c.github.io/webdriver/#dfn-is-element-selected
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::is_element_selected(StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::is_element_selected(StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -779,11 +779,11 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::is_element_selected(StringVie
|
|||
auto selected = m_browser_connection->is_element_selected(element_id);
|
||||
|
||||
// 5. Return success with data selected.
|
||||
return selected;
|
||||
return JsonValue { selected };
|
||||
}
|
||||
|
||||
// 12.4.2 Get Element Attribute, https://w3c.github.io/webdriver/#dfn-get-element-attribute
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_attribute(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
Web::WebDriver::Response Session::get_element_attribute(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -811,7 +811,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_attribute(JsonVal
|
|||
}
|
||||
|
||||
// 12.4.3 Get Element Property, https://w3c.github.io/webdriver/#dfn-get-element-property
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_property(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
Web::WebDriver::Response Session::get_element_property(JsonValue const&, StringView parameter_element_id, StringView name)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -833,7 +833,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_property(JsonValu
|
|||
}
|
||||
|
||||
// 12.4.4 Get Element CSS Value, https://w3c.github.io/webdriver/#dfn-get-element-css-value
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_css_value(JsonValue const&, StringView parameter_element_id, StringView property_name)
|
||||
Web::WebDriver::Response Session::get_element_css_value(JsonValue const&, StringView parameter_element_id, StringView property_name)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -859,7 +859,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_css_value(JsonVal
|
|||
}
|
||||
|
||||
// 12.4.5 Get Element Text, https://w3c.github.io/webdriver/#dfn-get-element-text
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_text(JsonValue const&, StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::get_element_text(JsonValue const&, StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -882,7 +882,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_text(JsonValue co
|
|||
}
|
||||
|
||||
// 12.4.6 Get Element Tag Name, https://w3c.github.io/webdriver/#dfn-get-element-tag-name
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_tag_name(JsonValue const&, StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::get_element_tag_name(JsonValue const&, StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -900,7 +900,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_tag_name(JsonValu
|
|||
}
|
||||
|
||||
// 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_rect(StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::get_element_rect(StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -930,7 +930,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_element_rect(StringView p
|
|||
}
|
||||
|
||||
// 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::is_element_enabled(StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::is_element_enabled(StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -946,11 +946,11 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::is_element_enabled(StringView
|
|||
auto enabled = m_browser_connection->is_element_enabled(element_id);
|
||||
|
||||
// 7. Return success with data enabled.
|
||||
return enabled;
|
||||
return JsonValue { enabled };
|
||||
}
|
||||
|
||||
// 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_source()
|
||||
Web::WebDriver::Response Session::get_source()
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -963,7 +963,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_source()
|
|||
auto source = m_browser_connection->serialize_source();
|
||||
|
||||
// 5. Return success with data source.
|
||||
return source;
|
||||
return JsonValue { source };
|
||||
}
|
||||
|
||||
struct ScriptArguments {
|
||||
|
@ -999,7 +999,7 @@ static ErrorOr<ScriptArguments, Web::WebDriver::Error> extract_the_script_argume
|
|||
}
|
||||
|
||||
// 13.2.1 Execute Script, https://w3c.github.io/webdriver/#dfn-execute-script
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::execute_script(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::execute_script(JsonValue const& payload)
|
||||
{
|
||||
// 1. Let body and arguments be the result of trying to extract the script arguments from a request with argument parameters.
|
||||
auto const& [body, arguments] = TRY(extract_the_script_arguments_from_a_request(payload));
|
||||
|
@ -1040,7 +1040,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::execute_script(JsonValue cons
|
|||
}
|
||||
|
||||
// 13.2.2 Execute Async Script, https://w3c.github.io/webdriver/#dfn-execute-async-script
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::execute_async_script(JsonValue const& parameters)
|
||||
Web::WebDriver::Response Session::execute_async_script(JsonValue const& parameters)
|
||||
{
|
||||
// 1. Let body and arguments by the result of trying to extract the script arguments from a request with argument parameters.
|
||||
auto [body, arguments] = TRY(extract_the_script_arguments_from_a_request(parameters));
|
||||
|
@ -1096,7 +1096,7 @@ static JsonObject serialize_cookie(Web::Cookie::Cookie const& cookie)
|
|||
}
|
||||
|
||||
// 14.1 Get All Cookies, https://w3c.github.io/webdriver/#dfn-get-all-cookies
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_all_cookies()
|
||||
Web::WebDriver::Response Session::get_all_cookies()
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1120,7 +1120,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_all_cookies()
|
|||
}
|
||||
|
||||
// 14.2 Get Named Cookie, https://w3c.github.io/webdriver/#dfn-get-named-cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_named_cookie(String const& name)
|
||||
Web::WebDriver::Response Session::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(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1141,7 +1141,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::get_named_cookie(String const
|
|||
}
|
||||
|
||||
// 14.3 Add Cookie, https://w3c.github.io/webdriver/#dfn-adding-a-cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::add_cookie(JsonValue const& payload)
|
||||
Web::WebDriver::Response Session::add_cookie(JsonValue const& payload)
|
||||
{
|
||||
// 1. Let data be the result of getting a property named cookie from the parameters argument.
|
||||
if (!payload.is_object() || !payload.as_object().has_object("cookie"sv))
|
||||
|
@ -1277,7 +1277,7 @@ void Session::delete_cookies(Optional<StringView> const& name)
|
|||
}
|
||||
|
||||
// 14.4 Delete Cookie, https://w3c.github.io/webdriver/#dfn-delete-cookie
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::delete_cookie(StringView name)
|
||||
Web::WebDriver::Response Session::delete_cookie(StringView name)
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1292,7 +1292,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::delete_cookie(StringView name
|
|||
}
|
||||
|
||||
// 14.5 Delete All Cookies, https://w3c.github.io/webdriver/#dfn-delete-all-cookies
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::delete_all_cookies()
|
||||
Web::WebDriver::Response Session::delete_all_cookies()
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1333,7 +1333,7 @@ static ErrorOr<String, Web::WebDriver::Error> encode_bitmap_as_canvas_element(Gf
|
|||
}
|
||||
|
||||
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::take_screenshot()
|
||||
Web::WebDriver::Response Session::take_screenshot()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1351,11 +1351,11 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::take_screenshot()
|
|||
auto encoded_string = TRY(encode_bitmap_as_canvas_element(*screenshot.bitmap()));
|
||||
|
||||
// 3. Return success with data encoded string.
|
||||
return encoded_string;
|
||||
return JsonValue { encoded_string };
|
||||
}
|
||||
|
||||
// 17.2 Take Element Screenshot, https://w3c.github.io/webdriver/#dfn-take-element-screenshot
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> Session::take_element_screenshot(StringView parameter_element_id)
|
||||
Web::WebDriver::Response Session::take_element_screenshot(StringView parameter_element_id)
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
@ -1381,7 +1381,7 @@ ErrorOr<JsonValue, Web::WebDriver::Error> Session::take_element_screenshot(Strin
|
|||
auto encoded_string = TRY(encode_bitmap_as_canvas_element(*screenshot.bitmap()));
|
||||
|
||||
// 6. Return success with data encoded string.
|
||||
return encoded_string;
|
||||
return JsonValue { encoded_string };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/JsonValue.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibWeb/WebDriver/Error.h>
|
||||
#include <LibWeb/WebDriver/Response.h>
|
||||
#include <WebDriver/BrowserConnection.h>
|
||||
#include <WebDriver/TimeoutsConfiguration.h>
|
||||
#include <unistd.h>
|
||||
|
@ -41,42 +42,42 @@ public:
|
|||
ErrorOr<void> start();
|
||||
ErrorOr<void> stop();
|
||||
JsonObject get_timeouts();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> set_timeouts(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> navigate_to(JsonValue const& url);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_current_url();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> back();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> forward();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> refresh();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_title();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_handle();
|
||||
Web::WebDriver::Response set_timeouts(JsonValue const& payload);
|
||||
Web::WebDriver::Response navigate_to(JsonValue const& url);
|
||||
Web::WebDriver::Response get_current_url();
|
||||
Web::WebDriver::Response back();
|
||||
Web::WebDriver::Response forward();
|
||||
Web::WebDriver::Response refresh();
|
||||
Web::WebDriver::Response get_title();
|
||||
Web::WebDriver::Response get_window_handle();
|
||||
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_handles() const;
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_window_rect();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> set_window_rect(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> maximize_window();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> minimize_window();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> find_element(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> find_elements(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> find_element_from_element(JsonValue const& payload, StringView parameter_element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> find_elements_from_element(JsonValue const& payload, StringView parameter_element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> is_element_selected(StringView element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_attribute(JsonValue const& payload, StringView element_id, StringView name);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_property(JsonValue const& payload, StringView element_id, StringView name);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_css_value(JsonValue const& payload, StringView element_id, StringView property_name);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_text(JsonValue const& payload, StringView element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_tag_name(JsonValue const& payload, StringView element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_element_rect(StringView element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> is_element_enabled(StringView element_id);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_source();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> execute_script(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> execute_async_script(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_all_cookies();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> get_named_cookie(String const& name);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> add_cookie(JsonValue const& payload);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> delete_cookie(StringView name);
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> delete_all_cookies();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> take_screenshot();
|
||||
ErrorOr<JsonValue, Web::WebDriver::Error> take_element_screenshot(StringView element_id);
|
||||
Web::WebDriver::Response get_window_handles() const;
|
||||
Web::WebDriver::Response get_window_rect();
|
||||
Web::WebDriver::Response set_window_rect(JsonValue const& payload);
|
||||
Web::WebDriver::Response maximize_window();
|
||||
Web::WebDriver::Response minimize_window();
|
||||
Web::WebDriver::Response find_element(JsonValue const& payload);
|
||||
Web::WebDriver::Response find_elements(JsonValue const& payload);
|
||||
Web::WebDriver::Response find_element_from_element(JsonValue const& payload, StringView parameter_element_id);
|
||||
Web::WebDriver::Response find_elements_from_element(JsonValue const& payload, StringView parameter_element_id);
|
||||
Web::WebDriver::Response is_element_selected(StringView element_id);
|
||||
Web::WebDriver::Response get_element_attribute(JsonValue const& payload, StringView element_id, StringView name);
|
||||
Web::WebDriver::Response get_element_property(JsonValue const& payload, StringView element_id, StringView name);
|
||||
Web::WebDriver::Response get_element_css_value(JsonValue const& payload, StringView element_id, StringView property_name);
|
||||
Web::WebDriver::Response get_element_text(JsonValue const& payload, StringView element_id);
|
||||
Web::WebDriver::Response get_element_tag_name(JsonValue const& payload, StringView element_id);
|
||||
Web::WebDriver::Response get_element_rect(StringView element_id);
|
||||
Web::WebDriver::Response is_element_enabled(StringView element_id);
|
||||
Web::WebDriver::Response get_source();
|
||||
Web::WebDriver::Response execute_script(JsonValue const& payload);
|
||||
Web::WebDriver::Response execute_async_script(JsonValue const& payload);
|
||||
Web::WebDriver::Response get_all_cookies();
|
||||
Web::WebDriver::Response get_named_cookie(String const& name);
|
||||
Web::WebDriver::Response add_cookie(JsonValue const& payload);
|
||||
Web::WebDriver::Response delete_cookie(StringView name);
|
||||
Web::WebDriver::Response delete_all_cookies();
|
||||
Web::WebDriver::Response take_screenshot();
|
||||
Web::WebDriver::Response take_element_screenshot(StringView element_id);
|
||||
|
||||
private:
|
||||
void delete_cookies(Optional<StringView> const& name = {});
|
||||
|
|
Loading…
Reference in a new issue