Skip to content

Commit

Permalink
WIP: WebContent: Update WebDriver "Perform Actions" to latest spec
Browse files Browse the repository at this point in the history
Doesn't build. The logic for how to make this work is confusing me.
  • Loading branch information
AtkinsSJ committed Jan 31, 2025
1 parent 13a521f commit 067581a
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Services/WebContent/WebDriverConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2335,26 +2335,25 @@ Messages::WebDriverClient::DeleteAllCookiesResponse WebDriverConnection::delete_
// 15.7 Perform Actions, https://w3c.github.io/webdriver/#perform-actions
Messages::WebDriverClient::PerformActionsResponse WebDriverConnection::perform_actions(JsonValue const& payload)
{
// 4. If session's current browsing context is no longer open, return error with error code no such window.
// NOTE: We do this first so we can assume the current top-level browsing context below is non-null.
// 1. If session's current browsing context is no longer open, return error with error code no such window.
TRY(ensure_current_browsing_context_is_open());

// 1. Let input state be the result of get the input state with session and session's current top-level browsing context.
auto& input_state = Web::WebDriver::get_input_state(*current_top_level_browsing_context());
// 2. Try to handle any user prompts with session.
handle_any_user_prompts([this, payload]() mutable {
// 3. Let input state be the result of get the input state with session and session's current top-level browsing context.
auto& input_state = Web::WebDriver::get_input_state(*current_top_level_browsing_context());

// 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.
Web::WebDriver::ActionsOptions actions_options {
.is_element_origin = &Web::WebDriver::represents_a_web_element,
.get_element_origin = &Web::WebDriver::get_web_element_origin,
};
// 4. 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.
Web::WebDriver::ActionsOptions actions_options {
.is_element_origin = &Web::WebDriver::represents_a_web_element,
.get_element_origin = &Web::WebDriver::get_web_element_origin,
};

// 3. Let actions by tick be the result of trying to extract an action sequence with input state, parameters, and
// actions options.
auto actions_by_tick = TRY(Web::WebDriver::extract_an_action_sequence(input_state, payload, actions_options));
// 5. Let actions by tick be the result of trying to extract an action sequence with input state, parameters, and
// actions options.
auto actions_by_tick = TRY(Web::WebDriver::extract_an_action_sequence(input_state, payload, actions_options));

// 5. Try to handle any user prompts with session.
handle_any_user_prompts([this, &input_state, actions_options = move(actions_options), actions_by_tick = move(actions_by_tick)]() mutable {
// 6. Dispatch actions with input state, actions by tick, current browsing context, and actions options. If this
// results in an error return that error.
auto on_complete = GC::create_function(current_browsing_context().heap(), [this](Web::WebDriver::Response result) {
Expand Down

0 comments on commit 067581a

Please sign in to comment.