diff --git a/Libraries/LibWeb/WebDriver/Actions.cpp b/Libraries/LibWeb/WebDriver/Actions.cpp index e99ab6b822c94..0968601459b78 100644 --- a/Libraries/LibWeb/WebDriver/Actions.cpp +++ b/Libraries/LibWeb/WebDriver/Actions.cpp @@ -1346,8 +1346,8 @@ class ActionExecutor final : public JS::Cell { GC_DEFINE_ALLOCATOR(ActionExecutor); -// https://w3c.github.io/webdriver/#dfn-dispatch-actions -GC::Ref dispatch_actions(InputState& input_state, Vector> actions_by_tick, HTML::BrowsingContext& browsing_context, ActionsOptions actions_options, OnActionsComplete on_complete) +// https://w3c.github.io/webdriver/#dfn-wait-for-an-action-queue-token +void wait_for_an_action_queue_token(InputState& input_state) { // 1. Let token be a new unique identifier. auto token = MUST(Crypto::generate_random_uuid()); @@ -1359,19 +1359,25 @@ GC::Ref dispatch_actions(InputState& input_state, Vector dispatch_actions(InputState& input_state, Vector> actions_by_tick, HTML::BrowsingContext& browsing_context, ActionsOptions actions_options, OnActionsComplete on_complete) +{ + // 1. Wait for an action queue token with input state. + wait_for_an_action_queue_token(input_state); - // 4. Let actions result be the result of dispatch actions inner with input state, actions by tick, browsing + // 2. Let actions result be the result of dispatch actions inner with input state, actions by tick, browsing // context, and actions options. auto action_executor = browsing_context.heap().allocate(input_state, move(actions_by_tick), browsing_context, move(actions_options), on_complete); action_executor->process_next_tick(); - // 5. Dequeue input state's actions queue. + // 3. Dequeue input state's actions queue. + // Assert: this returns token + // NOTE: We can't assert because `token` isn't defined here, it exists in `wait_for_an_action_queue_token()` instead. auto executed_token = input_state.actions_queue.take_first(); - // 6. Assert: this returns token - VERIFY(executed_token == token); - - // 7. Return actions result. + // 4. Return actions result. return action_executor; } diff --git a/Libraries/LibWeb/WebDriver/Actions.h b/Libraries/LibWeb/WebDriver/Actions.h index 7f144d2e9298d..881ba41f4995c 100644 --- a/Libraries/LibWeb/WebDriver/Actions.h +++ b/Libraries/LibWeb/WebDriver/Actions.h @@ -128,6 +128,7 @@ using OnActionsComplete = GC::Ref>; ErrorOr>, WebDriver::Error> extract_an_action_sequence(InputState&, JsonValue const&, ActionsOptions const&); +void wait_for_an_action_queue_token(InputState&); GC::Ref dispatch_actions(InputState&, Vector>, HTML::BrowsingContext&, ActionsOptions, OnActionsComplete); ErrorOr dispatch_tick_actions(InputState&, ReadonlySpan, AK::Duration, HTML::BrowsingContext&, ActionsOptions const&); GC::Ref dispatch_list_of_actions(InputState&, Vector, HTML::BrowsingContext&, ActionsOptions, OnActionsComplete);