mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
WebContent+WebDriver: Update the current BC when switching windows
We had only implemented this step in the WebDriver process, but we need to update the remote WebContent process as well.
This commit is contained in:
parent
4a6d0e0f90
commit
5fc51b2ff9
Notes:
github-actions[bot]
2024-09-14 23:57:32 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5fc51b2ff95 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1403 Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 23 additions and 4 deletions
|
@ -17,7 +17,7 @@ endpoint WebDriverClient {
|
|||
get_title() => (Web::WebDriver::Response response)
|
||||
get_window_handle() => (String handle)
|
||||
close_window() => (Web::WebDriver::Response response)
|
||||
switch_to_window() => (Web::WebDriver::Response response)
|
||||
switch_to_window(String handle) => (Web::WebDriver::Response response)
|
||||
new_window(JsonValue payload) => (Web::WebDriver::Response response)
|
||||
switch_to_frame(JsonValue payload) => (Web::WebDriver::Response response)
|
||||
switch_to_parent_frame(JsonValue payload) => (Web::WebDriver::Response response)
|
||||
|
|
|
@ -523,8 +523,27 @@ Messages::WebDriverClient::CloseWindowResponse WebDriverConnection::close_window
|
|||
}
|
||||
|
||||
// 11.3 Switch to Window, https://w3c.github.io/webdriver/#dfn-switch-to-window
|
||||
Messages::WebDriverClient::SwitchToWindowResponse WebDriverConnection::switch_to_window()
|
||||
Messages::WebDriverClient::SwitchToWindowResponse WebDriverConnection::switch_to_window(String const& handle)
|
||||
{
|
||||
// 4. If handle is equal to the associated window handle for some top-level browsing context in the
|
||||
// current session, let context be the that browsing context, and set the current top-level
|
||||
// browsing context with context.
|
||||
// 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;
|
||||
|
||||
m_current_browsing_context = context;
|
||||
found_matching_context = true;
|
||||
|
||||
return Web::TraversalDecision::Break;
|
||||
});
|
||||
|
||||
if (!found_matching_context)
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found");
|
||||
|
||||
// 5. Update any implementation-specific state that would result from the user selecting the current
|
||||
// browsing context for interaction, without altering OS-level focus.
|
||||
current_browsing_context().page().client().page_did_request_activate_tab();
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
virtual Messages::WebDriverClient::GetTitleResponse get_title() override;
|
||||
virtual Messages::WebDriverClient::GetWindowHandleResponse get_window_handle() override;
|
||||
virtual Messages::WebDriverClient::CloseWindowResponse close_window() override;
|
||||
virtual Messages::WebDriverClient::SwitchToWindowResponse switch_to_window() override;
|
||||
virtual Messages::WebDriverClient::SwitchToWindowResponse switch_to_window(String const& handle) override;
|
||||
virtual Messages::WebDriverClient::NewWindowResponse new_window(JsonValue const& payload) override;
|
||||
virtual Messages::WebDriverClient::SwitchToFrameResponse switch_to_frame(JsonValue const& payload) override;
|
||||
virtual Messages::WebDriverClient::SwitchToParentFrameResponse switch_to_parent_frame(JsonValue const& payload) override;
|
||||
|
|
|
@ -148,7 +148,7 @@ Web::WebDriver::Response Session::switch_to_window(StringView handle)
|
|||
|
||||
// 5. Update any implementation-specific state that would result from the user selecting the current
|
||||
// browsing context for interaction, without altering OS-level focus.
|
||||
TRY(web_content_connection().switch_to_window());
|
||||
TRY(web_content_connection().switch_to_window(m_current_window_handle));
|
||||
|
||||
// 6. Return success with data null.
|
||||
return JsonValue {};
|
||||
|
|
Loading…
Reference in a new issue