diff --git a/Libraries/LibWeb/WebDriver/Actions.cpp b/Libraries/LibWeb/WebDriver/Actions.cpp index 0968601459b..21c99396bfe 100644 --- a/Libraries/LibWeb/WebDriver/Actions.cpp +++ b/Libraries/LibWeb/WebDriver/Actions.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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