mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 11:39:43 +00:00
WebContent: Protect the switch-to-window endpoint against null BCs
This is one of the few endpoints that does not ensure a top-level BC is open. It's a bit of an implementation-defined endpoint, so let's protect against a non-existent BC explicitly.
This commit is contained in:
parent
30ec88dce0
commit
c7db1204ca
Notes:
github-actions[bot]
2024-09-16 23:05:36 +00:00
Author: https://github.com/trflynn89
Commit: c7db1204ca
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1412
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 9 additions and 7 deletions
|
@ -449,15 +449,17 @@ Messages::WebDriverClient::SwitchToWindowResponse WebDriverConnection::switch_to
|
|||
// Otherwise, return error with error code no such window.
|
||||
bool found_matching_context = false;
|
||||
|
||||
current_top_level_browsing_context()->for_each_in_inclusive_subtree([&](Web::HTML::BrowsingContext& context) {
|
||||
if (handle != context.top_level_traversable()->window_handle())
|
||||
return Web::TraversalDecision::Continue;
|
||||
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;
|
||||
|
||||
m_current_browsing_context = context;
|
||||
found_matching_context = true;
|
||||
m_current_browsing_context = context;
|
||||
found_matching_context = true;
|
||||
|
||||
return Web::TraversalDecision::Break;
|
||||
});
|
||||
return Web::TraversalDecision::Break;
|
||||
});
|
||||
}
|
||||
|
||||
if (!found_matching_context)
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue