summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Browser/Tab.cpp12
-rw-r--r--Userland/Applications/Browser/WebDriverConnection.cpp21
-rw-r--r--Userland/Applications/Browser/WebDriverConnection.h3
-rw-r--r--Userland/Applications/Browser/WebDriverSessionClient.ipc3
-rw-r--r--Userland/Services/WebContent/WebDriverClient.ipc3
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp56
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.h3
-rw-r--r--Userland/Services/WebDriver/Client.cpp9
-rw-r--r--Userland/Services/WebDriver/Session.cpp65
-rw-r--r--Userland/Services/WebDriver/Session.h3
10 files changed, 77 insertions, 101 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 9ee6866b29..e78e2c3091 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -236,6 +236,18 @@ Tab::Tab(BrowserWindow& window)
m_web_content_view->inspect_dom_tree();
};
+ view().on_navigate_back = [this]() {
+ go_back(1);
+ };
+
+ view().on_navigate_forward = [this]() {
+ go_forward(1);
+ };
+
+ view().on_refresh = [this]() {
+ reload();
+ };
+
view().on_link_click = [this](auto& url, auto& target, unsigned modifiers) {
if (target == "_blank" || modifiers == Mod_Ctrl) {
on_tab_open_request(url);
diff --git a/Userland/Applications/Browser/WebDriverConnection.cpp b/Userland/Applications/Browser/WebDriverConnection.cpp
index ea285b4e28..64d25a49fb 100644
--- a/Userland/Applications/Browser/WebDriverConnection.cpp
+++ b/Userland/Applications/Browser/WebDriverConnection.cpp
@@ -35,25 +35,4 @@ Messages::WebDriverSessionClient::GetTitleResponse WebDriverConnection::get_titl
return { "" };
}
-void WebDriverConnection::refresh()
-{
- dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: refresh");
- if (auto browser_window = m_browser_window.strong_ref())
- browser_window->active_tab().reload();
-}
-
-void WebDriverConnection::back()
-{
- dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: back");
- if (auto browser_window = m_browser_window.strong_ref())
- browser_window->active_tab().go_back();
-}
-
-void WebDriverConnection::forward()
-{
- dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: forward");
- if (auto browser_window = m_browser_window.strong_ref())
- browser_window->active_tab().go_forward();
-}
-
}
diff --git a/Userland/Applications/Browser/WebDriverConnection.h b/Userland/Applications/Browser/WebDriverConnection.h
index 55151da325..2baa106517 100644
--- a/Userland/Applications/Browser/WebDriverConnection.h
+++ b/Userland/Applications/Browser/WebDriverConnection.h
@@ -39,9 +39,6 @@ public:
virtual void quit() override;
virtual Messages::WebDriverSessionClient::GetTitleResponse get_title() override;
- virtual void refresh() override;
- virtual void back() override;
- virtual void forward() 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 62705a1fc5..27e31307e5 100644
--- a/Userland/Applications/Browser/WebDriverSessionClient.ipc
+++ b/Userland/Applications/Browser/WebDriverSessionClient.ipc
@@ -15,7 +15,4 @@ endpoint WebDriverSessionClient {
quit() =|
get_title() => (String title)
- refresh() =|
- back() =|
- forward() =|
}
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc
index 4c60c996ed..54d4cbf4a8 100644
--- a/Userland/Services/WebContent/WebDriverClient.ipc
+++ b/Userland/Services/WebContent/WebDriverClient.ipc
@@ -5,6 +5,9 @@ endpoint WebDriverClient {
set_is_webdriver_active(bool active) =|
navigate_to(JsonValue payload) => (Web::WebDriver::Response response)
get_current_url() => (Web::WebDriver::Response response)
+ back() => (Web::WebDriver::Response response)
+ forward() => (Web::WebDriver::Response response)
+ refresh() => (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 a88a6761e6..11dc0ee9d8 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -290,6 +290,62 @@ Messages::WebDriverClient::GetCurrentUrlResponse WebDriverConnection::get_curren
return make_success_response(url);
}
+// 10.3 Back, https://w3c.github.io/webdriver/#dfn-back
+Messages::WebDriverClient::BackResponse WebDriverConnection::back()
+{
+ // 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. Traverse the history by a delta –1 for the current browsing context.
+ m_web_content_client.async_did_request_navigate_back();
+
+ // FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
+ // FIXME: 5. If the previous step completed by the session page load timeout being reached, and user prompts have been handled, return error with error code timeout.
+
+ // 6. Return success with data null.
+ return make_success_response({});
+}
+
+// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
+Messages::WebDriverClient::ForwardResponse WebDriverConnection::forward()
+{
+ // 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. Traverse the history by a delta 1 for the current browsing context.
+ m_web_content_client.async_did_request_navigate_forward();
+
+ // FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
+ // FIXME: 5. If the previous step completed by the session page load timeout being reached, and user prompts have been handled, return error with error code timeout.
+
+ // 6. Return success with data null.
+ return make_success_response({});
+}
+
+// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
+Messages::WebDriverClient::RefreshResponse WebDriverConnection::refresh()
+{
+ // 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. Initiate an overridden reload of the current top-level browsing context’s active document.
+ m_web_content_client.async_did_request_refresh();
+
+ // FIXME: 4. If url is special except for file:
+ // FIXME: 1. Try to wait for navigation to complete.
+ // FIXME: 2. Try to run the post-navigation checks.
+ // FIXME: 5. Set the current browsing context with current top-level browsing context.
+
+ // 6. Return success with data null.
+ return make_success_response({});
+}
+
// 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 aa67512462..268d2894dc 100644
--- a/Userland/Services/WebContent/WebDriverConnection.h
+++ b/Userland/Services/WebContent/WebDriverConnection.h
@@ -37,6 +37,9 @@ private:
virtual void set_is_webdriver_active(bool) override;
virtual Messages::WebDriverClient::NavigateToResponse navigate_to(JsonValue const& payload) override;
virtual Messages::WebDriverClient::GetCurrentUrlResponse get_current_url() override;
+ virtual Messages::WebDriverClient::BackResponse back() override;
+ virtual Messages::WebDriverClient::ForwardResponse forward() override;
+ virtual Messages::WebDriverClient::RefreshResponse refresh() 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 b3087b86c9..9ffc78be82 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -512,8 +512,7 @@ Web::WebDriver::Response Client::handle_back(Vector<StringView> const& parameter
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/back");
auto* session = TRY(find_session_with_id(parameters[0]));
- auto result = TRY(session->back());
- return make_json_value(result);
+ return session->web_content_connection().back();
}
// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
@@ -522,8 +521,7 @@ Web::WebDriver::Response Client::handle_forward(Vector<StringView> const& parame
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/forward");
auto* session = TRY(find_session_with_id(parameters[0]));
- auto result = TRY(session->forward());
- return make_json_value(result);
+ return session->web_content_connection().forward();
}
// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
@@ -532,8 +530,7 @@ Web::WebDriver::Response Client::handle_refresh(Vector<StringView> const& parame
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/refresh");
auto* session = TRY(find_session_with_id(parameters[0]));
- auto result = TRY(session->refresh());
- return make_json_value(result);
+ return session->web_content_connection().refresh();
}
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title
diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp
index 1213e7276a..d78848f844 100644
--- a/Userland/Services/WebDriver/Session.cpp
+++ b/Userland/Services/WebDriver/Session.cpp
@@ -172,71 +172,6 @@ Web::WebDriver::Response Session::set_timeouts(JsonValue const& payload)
return JsonValue {};
}
-// 10.3 Back, https://w3c.github.io/webdriver/#dfn-back
-Web::WebDriver::Response Session::back()
-{
- // 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. Traverse the history by a delta –1 for the current browsing context.
- m_browser_connection->async_back();
-
- // FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event
- // fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
-
- // FIXME: 5. If the previous step completed by the session page load timeout being reached, and user
- // prompts have been handled, return error with error code timeout.
-
- // 6. Return success with data null.
- return JsonValue();
-}
-
-// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
-Web::WebDriver::Response Session::forward()
-{
- // 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. Traverse the history by a delta 1 for the current browsing context.
- m_browser_connection->async_forward();
-
- // FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event
- // fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
-
- // FIXME: 5. If the previous step completed by the session page load timeout being reached, and user
- // prompts have been handled, return error with error code timeout.
-
- // 6. Return success with data null.
- return JsonValue();
-}
-
-// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
-Web::WebDriver::Response Session::refresh()
-{
- // 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. Initiate an overridden reload of the current top-level browsing context’s active document.
- m_browser_connection->async_refresh();
-
- // FIXME: 4. If url is special except for file:
-
- // FIXME: 1. Try to wait for navigation to complete.
-
- // FIXME: 2. Try to run the post-navigation checks.
-
- // FIXME: 5. Set the current browsing context with current top-level browsing context.
-
- // 6. Return success with data null.
- return JsonValue();
-}
-
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title
Web::WebDriver::Response Session::get_title()
{
diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h
index 52d88f1ff6..967001b3b7 100644
--- a/Userland/Services/WebDriver/Session.h
+++ b/Userland/Services/WebDriver/Session.h
@@ -51,9 +51,6 @@ public:
Web::WebDriver::Response stop();
JsonObject get_timeouts();
Web::WebDriver::Response set_timeouts(JsonValue const& payload);
- Web::WebDriver::Response back();
- Web::WebDriver::Response forward();
- Web::WebDriver::Response refresh();
Web::WebDriver::Response get_title();
Web::WebDriver::Response get_window_handle();
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();