WebDriver: Add boilerplate for endpoint 15.7 Perform Actions
Some checks are pending
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

Following the structure of the ReleaseActions endpoints, define
analogous classes and methods for PerformActions
This commit is contained in:
Noah Bright 2024-09-02 14:41:24 -04:00 committed by Sam Atkins
parent 3ae4ea7b10
commit ee352e59db
Notes: github-actions[bot] 2024-09-09 13:12:24 +00:00
7 changed files with 33 additions and 0 deletions

View file

@ -101,6 +101,7 @@ static constexpr auto s_webdriver_endpoints = Array {
ROUTE(POST, "/session/:session_id/cookie"sv, add_cookie),
ROUTE(DELETE, "/session/:session_id/cookie/:name"sv, delete_cookie),
ROUTE(DELETE, "/session/:session_id/cookie"sv, delete_all_cookies),
ROUTE(POST, "/session/:session_id/actions"sv, perform_actions),
ROUTE(DELETE, "/session/:session_id/actions"sv, release_actions),
ROUTE(POST, "/session/:session_id/alert/dismiss"sv, dismiss_alert),
ROUTE(POST, "/session/:session_id/alert/accept"sv, accept_alert),

View file

@ -100,6 +100,7 @@ public:
virtual Response delete_all_cookies(Parameters parameters, JsonValue payload) = 0;
// 15. Actions, https://w3c.github.io/webdriver/#actions
virtual Response perform_actions(Parameters parameters, JsonValue payload) = 0;
virtual Response release_actions(Parameters parameters, JsonValue payload) = 0;
// 16. User prompts, https://w3c.github.io/webdriver/#user-prompts

View file

@ -56,6 +56,7 @@ endpoint WebDriverClient {
add_cookie(JsonValue payload) => (Web::WebDriver::Response response)
delete_cookie(String name) => (Web::WebDriver::Response response)
delete_all_cookies() => (Web::WebDriver::Response response)
perform_actions() => (Web::WebDriver::Response response)
release_actions() => (Web::WebDriver::Response response)
dismiss_alert() => (Web::WebDriver::Response response)
accept_alert() => (Web::WebDriver::Response response)

View file

@ -2069,6 +2069,25 @@ Messages::WebDriverClient::DeleteAllCookiesResponse WebDriverConnection::delete_
return JsonValue {};
}
// 15.7 Perform Actions, https://w3c.github.io/webdriver/#perform-actions
Messages::WebDriverClient::PerformActionsResponse WebDriverConnection::perform_actions()
{
// FIXME: 1. Let input state be the result of get the input state with session and session's current top-level browsing context.
// FIXME: 2.Let actions options be a new actions options with the is element origin steps set to represents a web element, and the get element origin steps set to get a WebElement origin.
// FIXME: 3.Let actions by tick be the result of trying to extract an action sequence with input state, parameters, and actions options.
// FIXME: 4. If session's current browsing context is no longer open, return error with error code no such window.
// FIXME: 5. Try to handle any user prompts with session.
// FIXME: 6. Dispatch actions with input state, actions by tick, current browsing context, and actions options. If this results in an error return that error.
// 7. Return success with data null.
return JsonValue {};
}
// 15.8 Release Actions, https://w3c.github.io/webdriver/#release-actions
Messages::WebDriverClient::ReleaseActionsResponse WebDriverConnection::release_actions()
{

View file

@ -93,6 +93,7 @@ private:
virtual Messages::WebDriverClient::AddCookieResponse add_cookie(JsonValue const& payload) override;
virtual Messages::WebDriverClient::DeleteCookieResponse delete_cookie(String const& name) override;
virtual Messages::WebDriverClient::DeleteAllCookiesResponse delete_all_cookies() override;
virtual Messages::WebDriverClient::PerformActionsResponse perform_actions() override;
virtual Messages::WebDriverClient::ReleaseActionsResponse release_actions() override;
virtual Messages::WebDriverClient::DismissAlertResponse dismiss_alert() override;
virtual Messages::WebDriverClient::AcceptAlertResponse accept_alert() override;

View file

@ -677,6 +677,15 @@ Web::WebDriver::Response Client::delete_all_cookies(Web::WebDriver::Parameters p
return session->web_content_connection().delete_all_cookies();
}
// 15.7 Perform Actions, https://w3c.github.io/webdriver/#perform-actions
// POST /session/{session id}/actions
Web::WebDriver::Response Client::perform_actions(Web::WebDriver::Parameters parameters, JsonValue)
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/actions");
auto session = TRY(find_session_with_id(parameters[0]));
return session->web_content_connection().perform_actions();
}
// 15.8 Release Actions, https://w3c.github.io/webdriver/#release-actions
// DELETE /session/{session id}/actions
Web::WebDriver::Response Client::release_actions(Web::WebDriver::Parameters parameters, JsonValue)

View file

@ -90,6 +90,7 @@ private:
virtual Web::WebDriver::Response add_cookie(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response delete_cookie(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response delete_all_cookies(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response perform_actions(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response release_actions(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response dismiss_alert(Web::WebDriver::Parameters parameters, JsonValue payload) override;
virtual Web::WebDriver::Response accept_alert(Web::WebDriver::Parameters parameters, JsonValue payload) override;