summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-16 08:50:22 -0400
committerLinus Groh <mail@linusgroh.de>2023-03-16 15:02:41 +0000
commit700ad6bf350f9e74044c015157f8ad7072c7f04c (patch)
tree6d9957d55b42f72a7b1122ab286c34fdd8922cd0 /Userland
parent3a7257c9fe24f1c21a744a76e97f3ee7a2f42f7e (diff)
downloadserenity-700ad6bf350f9e74044c015157f8ad7072c7f04c.zip
WebContent+LibWebView: Consolidate the way browsers connect to WebDriver
Currently, on Serenity, we connect to WebDriver from the browser-side of the WebContent connection for both Browser and headless-browser. On Lagom, we connect from within the WebContent process itself, signaled by a command line flag. This patch changes Lagom browsers to connect to WebDriver the same way that Serenity browsers do. This will ensure we can do other initializers in the same order across all platforms and browsers.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWebView/ViewImplementation.cpp9
-rw-r--r--Userland/Libraries/LibWebView/ViewImplementation.h2
-rw-r--r--Userland/Services/WebContent/PageHost.cpp4
-rw-r--r--Userland/Services/WebContent/PageHost.h1
-rw-r--r--Userland/Utilities/headless-browser.cpp8
5 files changed, 12 insertions, 12 deletions
diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp
index 85332ee979..c77b8c27f9 100644
--- a/Userland/Libraries/LibWebView/ViewImplementation.cpp
+++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp
@@ -126,7 +126,7 @@ void ViewImplementation::run_javascript(StringView js_source)
#if !defined(AK_OS_SERENITY)
-ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, StringView webdriver_content_ipc_path)
+ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths)
{
int socket_fds[2] {};
TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds));
@@ -149,17 +149,12 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> ViewImplementation::launch_web
auto webcontent_fd_passing_socket_string = TRY(String::number(wc_fd_passing_fd));
- Vector<StringView> arguments {
+ auto arguments = Array {
"WebContent"sv,
"--webcontent-fd-passing-socket"sv,
webcontent_fd_passing_socket_string
};
- if (!webdriver_content_ipc_path.is_empty()) {
- TRY(arguments.try_append("--webdriver-content-path"sv));
- TRY(arguments.try_append(webdriver_content_ipc_path));
- }
-
ErrorOr<void> result;
for (auto const& path : candidate_web_content_paths) {
result = Core::System::exec(path, arguments, Core::System::SearchInPath::Yes);
diff --git a/Userland/Libraries/LibWebView/ViewImplementation.h b/Userland/Libraries/LibWebView/ViewImplementation.h
index d23e4f7ef4..d065f14c7c 100644
--- a/Userland/Libraries/LibWebView/ViewImplementation.h
+++ b/Userland/Libraries/LibWebView/ViewImplementation.h
@@ -118,7 +118,7 @@ protected:
virtual void update_zoom() = 0;
#if !defined(AK_OS_SERENITY)
- ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, StringView webdriver_content_ipc_path);
+ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths);
#endif
struct SharedBitmap {
diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp
index ae30fd7cf2..582d731735 100644
--- a/Userland/Services/WebContent/PageHost.cpp
+++ b/Userland/Services/WebContent/PageHost.cpp
@@ -93,6 +93,10 @@ ErrorOr<void> PageHost::connect_to_webdriver(DeprecatedString const& webdriver_i
{
VERIFY(!m_webdriver);
m_webdriver = TRY(WebDriverConnection::connect(*this, webdriver_ipc_path));
+
+ if (on_webdriver_connection)
+ on_webdriver_connection(*m_webdriver);
+
return {};
}
diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h
index b7f3c133c4..fafbb8f676 100644
--- a/Userland/Services/WebContent/PageHost.h
+++ b/Userland/Services/WebContent/PageHost.h
@@ -43,6 +43,7 @@ public:
Web::DevicePixelSize content_size() const { return m_content_size; }
ErrorOr<void> connect_to_webdriver(DeprecatedString const& webdriver_ipc_path);
+ Function<void(WebDriverConnection&)> on_webdriver_connection;
void alert_closed();
void confirm_closed(bool accepted);
diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp
index 498a23104f..5ce84c9c39 100644
--- a/Userland/Utilities/headless-browser.cpp
+++ b/Userland/Utilities/headless-browser.cpp
@@ -53,12 +53,9 @@ public:
#if defined(AK_OS_SERENITY)
view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
-
- if (!web_driver_ipc_path.is_empty())
- view->client().async_connect_to_webdriver(web_driver_ipc_path);
#else
auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv));
- view->m_client_state.client = TRY(view->launch_web_content_process(candidate_web_content_paths, web_driver_ipc_path));
+ view->m_client_state.client = TRY(view->launch_web_content_process(candidate_web_content_paths));
#endif
view->client().async_update_system_theme(move(theme));
@@ -67,6 +64,9 @@ public:
view->client().async_set_viewport_rect({ { 0, 0 }, window_size });
view->client().async_set_window_size(window_size);
+ if (!web_driver_ipc_path.is_empty())
+ view->client().async_connect_to_webdriver(web_driver_ipc_path);
+
return view;
}