summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp4
-rw-r--r--Userland/Applications/Browser/WebDriverConnection.cpp12
-rw-r--r--Userland/Applications/Browser/WebDriverConnection.h1
-rw-r--r--Userland/Applications/Browser/WebDriverEndpoints.h1
-rw-r--r--Userland/Applications/Browser/WebDriverSessionClient.ipc1
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.cpp5
-rw-r--r--Userland/Libraries/LibWebView/OutOfProcessWebView.h1
-rw-r--r--Userland/Services/WebContent/ConnectionFromClient.cpp14
-rw-r--r--Userland/Services/WebContent/ConnectionFromClient.h1
-rw-r--r--Userland/Services/WebContent/WebContentServer.ipc1
-rw-r--r--Userland/Services/WebContent/WebDriverClient.ipc1
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.cpp23
-rw-r--r--Userland/Services/WebContent/WebDriverConnection.h1
-rw-r--r--Userland/Services/WebDriver/Client.cpp3
-rw-r--r--Userland/Services/WebDriver/Session.cpp17
-rw-r--r--Userland/Services/WebDriver/Session.h1
16 files changed, 26 insertions, 61 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index dcb77be9e8..05b1ba5ee4 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -607,10 +607,6 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
return active_tab().view().take_screenshot();
};
- new_tab.webdriver_endpoints().on_serialize_source = [this]() {
- return active_tab().view().serialize_source();
- };
-
new_tab.webdriver_endpoints().on_execute_script = [this](String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) {
return active_tab().view().webdriver_execute_script(body, json_arguments, timeout, async);
};
diff --git a/Userland/Applications/Browser/WebDriverConnection.cpp b/Userland/Applications/Browser/WebDriverConnection.cpp
index d0c26bc3c1..5e0faaf9d1 100644
--- a/Userland/Applications/Browser/WebDriverConnection.cpp
+++ b/Userland/Applications/Browser/WebDriverConnection.cpp
@@ -58,18 +58,6 @@ void WebDriverConnection::forward()
browser_window->active_tab().go_forward();
}
-Messages::WebDriverSessionClient::SerializeSourceResponse WebDriverConnection::serialize_source()
-{
- dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: serialize_source");
- if (auto browser_window = m_browser_window.strong_ref()) {
- auto& tab = browser_window->active_tab();
- if (tab.webdriver_endpoints().on_serialize_source)
- return { tab.webdriver_endpoints().on_serialize_source() };
- }
-
- return { {} };
-}
-
Messages::WebDriverSessionClient::ExecuteScriptResponse WebDriverConnection::execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)
{
dbgln("WebDriverConnection: execute_script");
diff --git a/Userland/Applications/Browser/WebDriverConnection.h b/Userland/Applications/Browser/WebDriverConnection.h
index 7dbd966a39..9247eac580 100644
--- a/Userland/Applications/Browser/WebDriverConnection.h
+++ b/Userland/Applications/Browser/WebDriverConnection.h
@@ -42,7 +42,6 @@ public:
virtual void refresh() override;
virtual void back() override;
virtual void forward() override;
- virtual Messages::WebDriverSessionClient::SerializeSourceResponse serialize_source() override;
virtual Messages::WebDriverSessionClient::ExecuteScriptResponse execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) override;
virtual Messages::WebDriverSessionClient::GetAllCookiesResponse get_all_cookies() override;
virtual Messages::WebDriverSessionClient::GetNamedCookieResponse get_named_cookie(String const& name) override;
diff --git a/Userland/Applications/Browser/WebDriverEndpoints.h b/Userland/Applications/Browser/WebDriverEndpoints.h
index e59a1d2435..2f5c03ea26 100644
--- a/Userland/Applications/Browser/WebDriverEndpoints.h
+++ b/Userland/Applications/Browser/WebDriverEndpoints.h
@@ -23,7 +23,6 @@ public:
WebDriverEndpoints() = default;
~WebDriverEndpoints() = default;
- Function<String()> on_serialize_source;
Function<Messages::WebContentServer::WebdriverExecuteScriptResponse(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)> on_execute_script;
};
diff --git a/Userland/Applications/Browser/WebDriverSessionClient.ipc b/Userland/Applications/Browser/WebDriverSessionClient.ipc
index 759c4ba81f..1b38fa717d 100644
--- a/Userland/Applications/Browser/WebDriverSessionClient.ipc
+++ b/Userland/Applications/Browser/WebDriverSessionClient.ipc
@@ -18,7 +18,6 @@ endpoint WebDriverSessionClient {
refresh() =|
back() =|
forward() =|
- serialize_source() => (String source)
execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
get_all_cookies() => (Vector<Web::Cookie::Cookie> cookies)
get_named_cookie(String name) => (Optional<Web::Cookie::Cookie> cookie)
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
index 05924c6aa5..09e6d00c57 100644
--- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp
@@ -481,11 +481,6 @@ void OutOfProcessWebView::get_source()
client().async_get_source();
}
-String OutOfProcessWebView::serialize_source()
-{
- return client().serialize_source();
-}
-
void OutOfProcessWebView::inspect_dom_tree()
{
client().async_inspect_dom_tree();
diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h
index c24d37a336..9c12a30482 100644
--- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h
+++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h
@@ -37,7 +37,6 @@ public:
void debug_request(String const& request, String const& argument = {});
void get_source();
- String serialize_source();
void inspect_dom_tree();
struct DOMNodeProperties {
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp
index 7cc72c6bc4..587396e251 100644
--- a/Userland/Services/WebContent/ConnectionFromClient.cpp
+++ b/Userland/Services/WebContent/ConnectionFromClient.cpp
@@ -263,20 +263,6 @@ void ConnectionFromClient::get_source()
}
}
-Messages::WebContentServer::SerializeSourceResponse ConnectionFromClient::serialize_source()
-{
- if (auto* doc = page().top_level_browsing_context().active_document()) {
- auto result = doc->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes);
- if (!result.is_error())
- return { result.release_value() };
-
- auto source = MUST(doc->serialize_fragment(Web::DOMParsing::RequireWellFormed::No));
- return { move(source) };
- }
-
- return { {} };
-}
-
void ConnectionFromClient::inspect_dom_tree()
{
if (auto* doc = page().top_level_browsing_context().active_document()) {
diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h
index 8ae5606c34..6be1f74d70 100644
--- a/Userland/Services/WebContent/ConnectionFromClient.h
+++ b/Userland/Services/WebContent/ConnectionFromClient.h
@@ -64,7 +64,6 @@ private:
virtual void remove_backing_store(i32) override;
virtual void debug_request(String const&, String const&) override;
virtual void get_source() override;
- virtual Messages::WebContentServer::SerializeSourceResponse serialize_source() override;
virtual void inspect_dom_tree() override;
virtual Messages::WebContentServer::InspectDomNodeResponse inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> const& pseudo_element) override;
virtual Messages::WebContentServer::GetHoveredNodeIdResponse get_hovered_node_id() override;
diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc
index 6e08649eb5..38c159f02c 100644
--- a/Userland/Services/WebContent/WebContentServer.ipc
+++ b/Userland/Services/WebContent/WebContentServer.ipc
@@ -35,7 +35,6 @@ endpoint WebContentServer
debug_request(String request, String argument) =|
get_source() =|
- serialize_source() => (String source)
inspect_dom_tree() =|
inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element) => (bool has_style, String specified_style, String computed_style, String custom_properties, String node_box_sizing)
get_hovered_node_id() => (i32 node_id)
diff --git a/Userland/Services/WebContent/WebDriverClient.ipc b/Userland/Services/WebContent/WebDriverClient.ipc
index 7b9d3cc3d0..78852f2da9 100644
--- a/Userland/Services/WebContent/WebDriverClient.ipc
+++ b/Userland/Services/WebContent/WebDriverClient.ipc
@@ -21,6 +21,7 @@ endpoint WebDriverClient {
get_element_tag_name(String element_id) => (Web::WebDriver::Response response)
get_element_rect(String element_id) => (Web::WebDriver::Response response)
is_element_enabled(String element_id) => (Web::WebDriver::Response response)
+ get_source() => (Web::WebDriver::Response response)
take_screenshot() => (Web::WebDriver::Response response)
take_element_screenshot(String element_id) => (Web::WebDriver::Response response)
}
diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp
index cd2c58d8a8..f2b6a450b2 100644
--- a/Userland/Services/WebContent/WebDriverConnection.cpp
+++ b/Userland/Services/WebContent/WebDriverConnection.cpp
@@ -731,6 +731,29 @@ Messages::WebDriverClient::IsElementEnabledResponse WebDriverConnection::is_elem
return make_success_response(enabled);
}
+// 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source
+Messages::WebDriverClient::GetSourceResponse WebDriverConnection::get_source()
+{
+ // 1. If the current 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.
+
+ auto* document = m_page_host.page().top_level_browsing_context().active_document();
+ Optional<String> source;
+
+ // 3. Let source be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing true for the require well-formed flag. If this causes an exception to be thrown, let source be null.
+ if (auto result = document->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes); !result.is_error())
+ source = result.release_value();
+
+ // 4. Let source be the result of serializing to string the current browsing context active document, if source is null.
+ if (!source.has_value())
+ source = MUST(document->serialize_fragment(Web::DOMParsing::RequireWellFormed::No));
+
+ // 5. Return success with data source.
+ return make_success_response(source.release_value());
+}
+
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
Messages::WebDriverClient::TakeScreenshotResponse WebDriverConnection::take_screenshot()
{
diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h
index ea1459bee0..bce9e68265 100644
--- a/Userland/Services/WebContent/WebDriverConnection.h
+++ b/Userland/Services/WebContent/WebDriverConnection.h
@@ -51,6 +51,7 @@ private:
virtual Messages::WebDriverClient::GetElementTagNameResponse get_element_tag_name(String const& element_id) override;
virtual Messages::WebDriverClient::GetElementRectResponse get_element_rect(String const& element_id) override;
virtual Messages::WebDriverClient::IsElementEnabledResponse is_element_enabled(String const& element_id) override;
+ virtual Messages::WebDriverClient::GetSourceResponse get_source() override;
virtual Messages::WebDriverClient::TakeScreenshotResponse take_screenshot() override;
virtual Messages::WebDriverClient::TakeElementScreenshotResponse take_element_screenshot(String const& element_id) override;
diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp
index c8e26377a9..be69280e2f 100644
--- a/Userland/Services/WebDriver/Client.cpp
+++ b/Userland/Services/WebDriver/Client.cpp
@@ -726,8 +726,7 @@ Web::WebDriver::Response Client::handle_get_source(Vector<StringView> const& par
{
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/source");
auto* session = TRY(find_session_with_id(parameters[0]));
- auto result = TRY(session->get_source());
- return make_json_value(result);
+ return session->web_content_connection().get_source();
}
// 13.2.1 Execute Script, https://w3c.github.io/webdriver/#dfn-execute-script
diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp
index a69e9fffee..6a677dcc5a 100644
--- a/Userland/Services/WebDriver/Session.cpp
+++ b/Userland/Services/WebDriver/Session.cpp
@@ -297,23 +297,6 @@ Web::WebDriver::Response Session::get_window_handles() const
return JsonValue { handles };
}
-// 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source
-Web::WebDriver::Response Session::get_source()
-{
- // 1. If the current 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 source be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing true for the require well-formed flag. If this causes an exception to be thrown, let source be null.
- // 4. Let source be the result of serializing to string the current browsing context active document, if source is null.
- // NOTE: Both of the above cases are handled in the remote WebContent process.
- auto source = m_browser_connection->serialize_source();
-
- // 5. Return success with data source.
- return JsonValue { source };
-}
-
struct ScriptArguments {
String script;
JsonArray const& arguments;
diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h
index 891bd718c6..bfe53e0d6e 100644
--- a/Userland/Services/WebDriver/Session.h
+++ b/Userland/Services/WebDriver/Session.h
@@ -58,7 +58,6 @@ public:
Web::WebDriver::Response get_window_handle();
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();
Web::WebDriver::Response get_window_handles() const;
- Web::WebDriver::Response get_source();
Web::WebDriver::Response execute_script(JsonValue const& payload);
Web::WebDriver::Response execute_async_script(JsonValue const& payload);
Web::WebDriver::Response get_all_cookies();