Skip to content

Truly independent web browser

LibWebCommon: Look for a Windows helper process by its .exe file name

sideshowbarker28c9b74ca7de
diff --git a/Libraries/LibWebCommon/WebView/Utilities.cpp b/Libraries/LibWebCommon/WebView/Utilities.cpp
index aee32f1e715..e5df9789a78 100644
--- a/Libraries/LibWebCommon/WebView/Utilities.cpp
+++ b/Libraries/LibWebCommon/WebView/Utilities.cpp
@@ -95,7 +95,12 @@ ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name
TRY(paths.try_append(LexicalPath::join(prefix.string(), libexec_path, process_name).string()));
TRY(paths.try_append(LexicalPath::join(prefix.string(), "bin"sv, process_name).string()));
#endif
+#if defined(AK_OS_WINDOWS)
+ // An executable's file name on Windows ends in .exe, so a lookup by path without it finds nothing there.
+ TRY(paths.try_append(ByteString::formatted("{}/{}.exe", application_path, process_name)));
+#else
TRY(paths.try_append(ByteString::formatted("{}/{}", application_path, process_name)));
+#endif
// NOTE: Add platform-specific paths here
return paths;
}
diff --git a/Tests/LibWebView/CMakeLists.txt b/Tests/LibWebView/CMakeLists.txt
index 230b99af642..a26d7f0b893 100644
--- a/Tests/LibWebView/CMakeLists.txt
+++ b/Tests/LibWebView/CMakeLists.txt
@@ -54,6 +54,8 @@ if (BUILD_BROWSER_TESTS_ONLY)
endif()
ladybird_test_suite(LibWebView)
+# TestHelperProcessPaths looks for these where the browser would.
+add_dependencies(TestLibWebView Compositor ImageDecoder RequestServer SystemProbe WebContent)
set(TEST_SOURCES
TestAccessibilityTreeManager.cpp
@@ -70,6 +72,7 @@ set(TEST_SOURCES
TestFaviconStore.cpp
TestForceDarkSettings.cpp
TestHelperProcessEnvironment.cpp
+ TestHelperProcessPaths.cpp
TestHistoryStore.cpp
TestHSTSStore.cpp
TestLingeringIndicator.cpp
diff --git a/Tests/LibWebView/TestHelperProcessPaths.cpp b/Tests/LibWebView/TestHelperProcessPaths.cpp
new file mode 100644
index 00000000000..026d8471046
--- /dev/null
+++ b/Tests/LibWebView/TestHelperProcessPaths.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/AnyOf.h>
+#include <LibFileSystem/FileSystem.h>
+#include <LibTest/TestCase.h>
+#include <LibWebCommon/WebView/Utilities.h>
+
+// On macOS, the helpers are in the app bundle, which this test isn't a part of. Elsewhere, the build puts them where
+// the browser looks for them from its own directory, which is this test's directory too.
+#if !defined(AK_OS_MACOS)
+TEST_CASE(each_helper_process_is_at_one_of_its_paths)
+{
+ for (auto process_name : { "Compositor"sv, "ImageDecoder"sv, "RequestServer"sv, "SystemProbe"sv, "WebContent"sv }) {
+ auto paths = TRY_OR_FAIL(WebView::get_paths_for_helper_process(process_name));
+ if (!any_of(paths, [](auto const& path) { return FileSystem::exists(path); }))
+ FAIL(ByteString::formatted("No file at any path for {}: {}", process_name, paths));
+ }
+}
+#endif