LibWeb: Check for closed browsing contexts before dispatching actions

See: https://github.com/w3c/webdriver/commit/0ac18fa
This commit is contained in:
Timothy Flynn 2025-02-03 09:30:02 -05:00 committed by Sam Atkins
parent 28fb30b22f
commit 0a46b5cbb1
Notes: github-actions[bot] 2025-02-05 11:34:49 +00:00

View file

@ -20,6 +20,7 @@
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/WebDriver/Actions.h>
#include <LibWeb/WebDriver/Contexts.h>
#include <LibWeb/WebDriver/ElementReference.h>
#include <LibWeb/WebDriver/InputState.h>
#include <LibWeb/WebDriver/Properties.h>
@ -1294,16 +1295,22 @@ public:
auto const& tick_actions = m_actions_by_tick[m_current_tick++];
// 1. Let tick duration be the result of computing the tick duration with argument tick actions.
// 1. If browsing context is no longer open, return error with error code no such window.
if (auto result = WebDriver::ensure_browsing_context_is_open(m_browsing_context); result.is_error()) {
m_on_complete->function()(result.release_error());
return;
}
// 2. Let tick duration be the result of computing the tick duration with argument tick actions.
auto tick_duration = compute_tick_duration(tick_actions);
// 2. Try to dispatch tick actions with input state, tick actions, tick duration, browsing context, and actions options.
// 3. Try to dispatch tick actions with input state, tick actions, tick duration, browsing context, and actions options.
if (auto result = dispatch_tick_actions(m_input_state, tick_actions, tick_duration, m_browsing_context, m_actions_options); result.is_error()) {
m_on_complete->function()(result.release_error());
return;
}
// 3. Wait until the following conditions are all met:
// 4. Wait until the following conditions are all met:
// * There are no pending asynchronous waits arising from the last invocation of the dispatch tick actions
// steps.
// * The user agent event loop has spun enough times to process the DOM events generated by the last