diff options
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WebContent/WebDriverClient.ipc | 1 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.h | 1 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.cpp | 7 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.h | 1 |
5 files changed, 11 insertions, 5 deletions
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc index 3ae9553102..3312c823f0 100644 --- a/Userland/Services/WebContent/WebDriverClient.ipc +++ b/Userland/Services/WebContent/WebDriverClient.ipc @@ -15,6 +15,7 @@ endpoint WebDriverClient { forward() => (Web::WebDriver::Response response) refresh() => (Web::WebDriver::Response response) get_title() => (Web::WebDriver::Response response) + get_window_handle() => (String handle) close_window() => (Web::WebDriver::Response response) new_window(JsonValue payload) => (Web::WebDriver::Response response) get_window_rect() => (Web::WebDriver::Response response) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index bd157d4f70..74da18d6b5 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -522,6 +522,12 @@ Messages::WebDriverClient::GetTitleResponse WebDriverConnection::get_title() return title; } +// 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle +Messages::WebDriverClient::GetWindowHandleResponse WebDriverConnection::get_window_handle() +{ + return m_page_client.page().top_level_browsing_context().window_handle(); +} + // 11.2 Close Window, https://w3c.github.io/webdriver/#dfn-close-window Messages::WebDriverClient::CloseWindowResponse WebDriverConnection::close_window() { diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index e1bfcf2aad..ef1dbe0869 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -52,6 +52,7 @@ private: virtual Messages::WebDriverClient::ForwardResponse forward() override; virtual Messages::WebDriverClient::RefreshResponse refresh() override; 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::NewWindowResponse new_window(JsonValue const& payload) override; virtual Messages::WebDriverClient::GetWindowRectResponse get_window_rect() override; diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index 89db4b9791..674ef6f8e3 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -50,12 +50,11 @@ ErrorOr<NonnullRefPtr<Core::LocalServer>> Session::create_server(NonnullRefPtr<S dbgln("WebDriver is connected to WebContent socket"); auto web_content_connection = maybe_connection.release_value(); - auto handle_name = String::formatted("window-{}"sv, m_next_handle_id).release_value_but_fixme_should_propagate_errors(); - m_next_handle_id++; - m_windows.set(handle_name, Session::Window { handle_name, move(web_content_connection) }); + auto window_handle = web_content_connection->get_window_handle(); + m_windows.set(window_handle, Session::Window { window_handle, move(web_content_connection) }); if (m_current_window_handle.is_empty()) - m_current_window_handle = handle_name; + m_current_window_handle = window_handle; MUST(promise->resolve({})); }; diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h index 08070c170d..cea6609217 100644 --- a/Userland/Services/WebDriver/Session.h +++ b/Userland/Services/WebDriver/Session.h @@ -64,7 +64,6 @@ private: bool m_started { false }; unsigned m_id { 0 }; - unsigned m_next_handle_id = 0; HashMap<String, Window> m_windows; String m_current_window_handle; |