diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/Browser/WebDriverConnection.cpp | 8 | ||||
-rw-r--r-- | Userland/Applications/Browser/WebDriverConnection.h | 1 | ||||
-rw-r--r-- | Userland/Applications/Browser/WebDriverSessionClient.ipc | 2 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverClient.ipc | 1 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.cpp | 15 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebDriverConnection.h | 1 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Client.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.cpp | 13 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.h | 1 |
9 files changed, 18 insertions, 27 deletions
diff --git a/Userland/Applications/Browser/WebDriverConnection.cpp b/Userland/Applications/Browser/WebDriverConnection.cpp index 64d25a49fb..97abfa50cf 100644 --- a/Userland/Applications/Browser/WebDriverConnection.cpp +++ b/Userland/Applications/Browser/WebDriverConnection.cpp @@ -27,12 +27,4 @@ void WebDriverConnection::quit() browser_window->close(); } -Messages::WebDriverSessionClient::GetTitleResponse WebDriverConnection::get_title() -{ - dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: get_title"); - if (auto browser_window = m_browser_window.strong_ref()) - return { browser_window->active_tab().title() }; - return { "" }; -} - } diff --git a/Userland/Applications/Browser/WebDriverConnection.h b/Userland/Applications/Browser/WebDriverConnection.h index 2baa106517..672939a08f 100644 --- a/Userland/Applications/Browser/WebDriverConnection.h +++ b/Userland/Applications/Browser/WebDriverConnection.h @@ -38,7 +38,6 @@ public: virtual void die() override { } virtual void quit() override; - virtual Messages::WebDriverSessionClient::GetTitleResponse get_title() override; private: WebDriverConnection(NonnullOwnPtr<Core::Stream::LocalSocket> socket, NonnullRefPtr<BrowserWindow> browser_window); diff --git a/Userland/Applications/Browser/WebDriverSessionClient.ipc b/Userland/Applications/Browser/WebDriverSessionClient.ipc index 27e31307e5..ff15f00f5e 100644 --- a/Userland/Applications/Browser/WebDriverSessionClient.ipc +++ b/Userland/Applications/Browser/WebDriverSessionClient.ipc @@ -13,6 +13,4 @@ endpoint WebDriverSessionClient { quit() =| - - get_title() => (String title) } diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc index 54d4cbf4a8..ca8669ebc6 100644 --- a/Userland/Services/WebContent/WebDriverClient.ipc +++ b/Userland/Services/WebContent/WebDriverClient.ipc @@ -8,6 +8,7 @@ endpoint WebDriverClient { back() => (Web::WebDriver::Response response) forward() => (Web::WebDriver::Response response) refresh() => (Web::WebDriver::Response response) + get_title() => (Web::WebDriver::Response response) get_window_rect() => (Web::WebDriver::Response response) set_window_rect(JsonValue payload) => (Web::WebDriver::Response response) maximize_window() => (Web::WebDriver::Response response) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 11dc0ee9d8..0afdf5d135 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -346,6 +346,21 @@ Messages::WebDriverClient::RefreshResponse WebDriverConnection::refresh() return make_success_response({}); } +// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title +Messages::WebDriverClient::GetTitleResponse WebDriverConnection::get_title() +{ + // 1. If the current top-level browsing context is no longer open, return error with error code no such window. + TRY(ensure_open_top_level_browsing_context()); + + // FIXME: 2. Handle any user prompts and return its value if it is an error. + + // 3. Let title be the initial value of the title IDL attribute of the current top-level browsing context's active document. + auto title = m_page_host.page().top_level_browsing_context().active_document()->title(); + + // 4. Return success with data title. + return make_success_response(move(title)); +} + // 11.8.1 Get Window Rect, https://w3c.github.io/webdriver/#dfn-get-window-rect Messages::WebDriverClient::GetWindowRectResponse WebDriverConnection::get_window_rect() { diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index 268d2894dc..bcac1284dc 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -40,6 +40,7 @@ private: virtual Messages::WebDriverClient::BackResponse back() override; virtual Messages::WebDriverClient::ForwardResponse forward() override; virtual Messages::WebDriverClient::RefreshResponse refresh() override; + virtual Messages::WebDriverClient::GetTitleResponse get_title() override; virtual Messages::WebDriverClient::GetWindowRectResponse get_window_rect() override; virtual Messages::WebDriverClient::SetWindowRectResponse set_window_rect(JsonValue const& payload) override; virtual Messages::WebDriverClient::MaximizeWindowResponse maximize_window() override; diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index 9ffc78be82..a1ca123bdf 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -539,8 +539,7 @@ Web::WebDriver::Response Client::handle_get_title(Vector<StringView> const& para { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/title"); auto* session = TRY(find_session_with_id(parameters[0])); - auto result = TRY(session->get_title()); - return make_json_value(result); + return session->web_content_connection().get_title(); } // 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index d78848f844..a483b3f087 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -172,19 +172,6 @@ Web::WebDriver::Response Session::set_timeouts(JsonValue const& payload) return JsonValue {}; } -// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title -Web::WebDriver::Response Session::get_title() -{ - // 1. If the current top-level browsing context is no longer open, return error with error code no such window. - TRY(check_for_open_top_level_browsing_context_or_return_error()); - - // FIXME: 2. Handle any user prompts and return its value if it is an error. - - // 3. Let title be the initial value of the title IDL attribute of the current top-level browsing context's active document. - // 4. Return success with data title. - return JsonValue(m_browser_connection->get_title()); -} - // 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle Web::WebDriver::Response Session::get_window_handle() { diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h index 967001b3b7..c43835c986 100644 --- a/Userland/Services/WebDriver/Session.h +++ b/Userland/Services/WebDriver/Session.h @@ -51,7 +51,6 @@ public: Web::WebDriver::Response stop(); JsonObject get_timeouts(); Web::WebDriver::Response set_timeouts(JsonValue const& payload); - Web::WebDriver::Response get_title(); Web::WebDriver::Response get_window_handle(); ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window(); Web::WebDriver::Response get_window_handles() const; |