WebContent: Search all known navigables when WebDriver switches windows

We were only looking at the current top-level navigable and its children
when searching for the specified window handle. We need to search *all*
known navigables if the handle belongs to a window not in the current
tree.
This commit is contained in:
Timothy Flynn 2024-09-18 14:15:23 -04:00 committed by Tim Ledbetter
parent 4ce05e5ccf
commit 47e9357243
Notes: github-actions[bot] 2024-09-18 23:03:09 +00:00

View file

@ -449,16 +449,16 @@ Messages::WebDriverClient::SwitchToWindowResponse WebDriverConnection::switch_to
// Otherwise, return error with error code no such window.
bool found_matching_context = false;
if (auto browsing_context = current_top_level_browsing_context()) {
browsing_context->for_each_in_inclusive_subtree([&](Web::HTML::BrowsingContext& context) {
if (handle != context.top_level_traversable()->window_handle())
return Web::TraversalDecision::Continue;
for (auto* navigable : Web::HTML::all_navigables()) {
auto traversable = navigable->top_level_traversable();
if (!traversable || !traversable->active_browsing_context())
continue;
m_current_browsing_context = context;
if (handle == traversable->window_handle()) {
m_current_browsing_context = traversable->active_browsing_context();
found_matching_context = true;
return Web::TraversalDecision::Break;
});
break;
}
}
if (!found_matching_context)