Skip to content

Commit a96ba91

Browse files
trflynn89linusg
authored andcommitted
WebDriver: Activate the browser tab during the Switch To Window command
1 parent f8b6369 commit a96ba91

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

Userland/Services/WebContent/WebDriverClient.ipc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ endpoint WebDriverClient {
1717
get_title() => (Web::WebDriver::Response response)
1818
get_window_handle() => (String handle)
1919
close_window() => (Web::WebDriver::Response response)
20+
switch_to_window() => (Web::WebDriver::Response response)
2021
new_window(JsonValue payload) => (Web::WebDriver::Response response)
2122
get_window_rect() => (Web::WebDriver::Response response)
2223
set_window_rect(JsonValue payload) => (Web::WebDriver::Response response)

Userland/Services/WebContent/WebDriverConnection.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,16 @@ Messages::WebDriverClient::CloseWindowResponse WebDriverConnection::close_window
545545
return JsonValue {};
546546
}
547547

548+
// 11.3 Switch to Window, https://w3c.github.io/webdriver/#dfn-switch-to-window
549+
Messages::WebDriverClient::SwitchToWindowResponse WebDriverConnection::switch_to_window()
550+
{
551+
// 5. Update any implementation-specific state that would result from the user selecting the current
552+
// browsing context for interaction, without altering OS-level focus.
553+
m_page_client.page_did_request_activate_tab();
554+
555+
return JsonValue {};
556+
}
557+
548558
// 11.5 New Window, https://w3c.github.io/webdriver/#dfn-new-window
549559
Messages::WebDriverClient::NewWindowResponse WebDriverConnection::new_window(JsonValue const&)
550560
{

Userland/Services/WebContent/WebDriverConnection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class WebDriverConnection final
5454
virtual Messages::WebDriverClient::GetTitleResponse get_title() override;
5555
virtual Messages::WebDriverClient::GetWindowHandleResponse get_window_handle() override;
5656
virtual Messages::WebDriverClient::CloseWindowResponse close_window() override;
57+
virtual Messages::WebDriverClient::SwitchToWindowResponse switch_to_window() override;
5758
virtual Messages::WebDriverClient::NewWindowResponse new_window(JsonValue const& payload) override;
5859
virtual Messages::WebDriverClient::GetWindowRectResponse get_window_rect() override;
5960
virtual Messages::WebDriverClient::SetWindowRectResponse set_window_rect(JsonValue const& payload) override;

Userland/Services/WebDriver/Session.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ Web::WebDriver::Response Session::switch_to_window(StringView handle)
144144
else
145145
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found");
146146

147-
// FIXME: 5. Update any implementation-specific state that would result from the user selecting the current
148-
// browsing context for interaction, without altering OS-level focus.
147+
// 5. Update any implementation-specific state that would result from the user selecting the current
148+
// browsing context for interaction, without altering OS-level focus.
149+
TRY(web_content_connection().switch_to_window());
149150

150151
// 6. Return success with data null.
151152
return JsonValue {};

0 commit comments

Comments
 (0)