mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 01:55:07 +00:00
Ladybird+WebContent: Add chrome command line and exe path passing
This commit is contained in:
parent
c94fc7d3b0
commit
dc2233ef7a
|
@ -25,7 +25,7 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th>Version:</th>
|
||||
<td>@browser_version@ <!-- FIXME: Add build commit hash --></td>
|
||||
<td>@browser_version@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Arch:</th>
|
||||
|
@ -39,15 +39,14 @@
|
|||
<th>User Agent:</th>
|
||||
<td>@user_agent@</td>
|
||||
</tr>
|
||||
<!-- FIXME: Add these fields
|
||||
<tr>
|
||||
<th>Command Line:</th>
|
||||
<td></td>
|
||||
<td>@command_line@</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Executable Path:</th>
|
||||
<td></td>
|
||||
</tr> -->
|
||||
<td>@executable_path@</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -68,7 +68,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (initial_urls.is_empty())
|
||||
initial_urls.append(new_tab_page_url);
|
||||
|
||||
StringBuilder command_line_builder;
|
||||
command_line_builder.join(' ', arguments.strings);
|
||||
Ladybird::WebContentOptions web_content_options {
|
||||
.command_line = MUST(command_line_builder.to_string()),
|
||||
.executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))),
|
||||
.enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No,
|
||||
.use_lagom_networking = Ladybird::UseLagomNetworking::Yes,
|
||||
.wait_for_debugger = debug_web_content ? Ladybird::WaitForDebugger::Yes : Ladybird::WaitForDebugger::No,
|
||||
|
|
|
@ -44,6 +44,10 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
|||
"--tool=callgrind"sv,
|
||||
"--instr-atstart=no"sv,
|
||||
path.bytes_as_string_view(),
|
||||
"--command-line"sv,
|
||||
web_content_options.command_line,
|
||||
"--executable-path"sv,
|
||||
web_content_options.executable_path,
|
||||
"--webcontent-fd-passing-socket"sv,
|
||||
webcontent_fd_passing_socket_string
|
||||
};
|
||||
|
|
|
@ -143,7 +143,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
initial_urls.append(ak_string_from_qstring(new_tab_page));
|
||||
}
|
||||
|
||||
StringBuilder command_line_builder;
|
||||
command_line_builder.join(' ', arguments.strings);
|
||||
Ladybird::WebContentOptions web_content_options {
|
||||
.command_line = MUST(command_line_builder.to_string()),
|
||||
.executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))),
|
||||
.enable_callgrind_profiling = enable_callgrind_profiling ? Ladybird::EnableCallgrindProfiling::Yes : Ladybird::EnableCallgrindProfiling::No,
|
||||
.enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No,
|
||||
.use_lagom_networking = enable_qt_networking ? Ladybird::UseLagomNetworking::No : Ladybird::UseLagomNetworking::Yes,
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
enum class EnableCallgrindProfiling {
|
||||
|
@ -34,6 +36,8 @@ enum class WaitForDebugger {
|
|||
};
|
||||
|
||||
struct WebContentOptions {
|
||||
String command_line;
|
||||
String executable_path;
|
||||
EnableCallgrindProfiling enable_callgrind_profiling { EnableCallgrindProfiling::No };
|
||||
EnableGPUPainting enable_gpu_painting { EnableGPUPainting::No };
|
||||
IsLayoutTestMode is_layout_test_mode { IsLayoutTestMode::No };
|
||||
|
|
|
@ -76,6 +76,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
#endif
|
||||
});
|
||||
|
||||
StringView command_line {};
|
||||
StringView executable_path {};
|
||||
int webcontent_fd_passing_socket { -1 };
|
||||
bool is_layout_test_mode = false;
|
||||
bool use_lagom_networking = false;
|
||||
|
@ -83,6 +85,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool wait_for_debugger = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(command_line, "Chrome process command line", "command-line", 0, "command_line");
|
||||
args_parser.add_option(executable_path, "Chrome process executable path", "executable-path", 0, "executable_path");
|
||||
args_parser.add_option(webcontent_fd_passing_socket, "File descriptor of the passing socket for the WebContent connection", "webcontent-fd-passing-socket", 'c', "webcontent_fd_passing_socket");
|
||||
args_parser.add_option(is_layout_test_mode, "Is layout test mode", "layout-test-mode", 0);
|
||||
args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking", 0);
|
||||
|
@ -95,6 +99,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Core::Process::wait_for_debugger_and_break();
|
||||
}
|
||||
|
||||
Web::set_chrome_process_command_line(command_line);
|
||||
Web::set_chrome_process_executable_path(executable_path);
|
||||
if (use_gpu_painting) {
|
||||
WebContent::PageClient::set_use_gpu_painter();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,16 @@
|
|||
|
||||
namespace Web {
|
||||
|
||||
void set_chrome_process_command_line(StringView command_line)
|
||||
{
|
||||
s_chrome_process_command_line = MUST(String::from_utf8(command_line));
|
||||
}
|
||||
|
||||
void set_chrome_process_executable_path(StringView executable_path)
|
||||
{
|
||||
s_chrome_process_executable_path = MUST(String::from_utf8(executable_path));
|
||||
}
|
||||
|
||||
ErrorOr<String> load_error_page(AK::URL const& url)
|
||||
{
|
||||
// Generate HTML error page from error template file
|
||||
|
@ -81,6 +91,8 @@ ErrorOr<String> load_about_version_page()
|
|||
generator.set("arch_name", CPU_STRING);
|
||||
generator.set("os_name", OS_STRING);
|
||||
generator.set("user_agent", default_user_agent);
|
||||
generator.set("command_line", s_chrome_process_command_line);
|
||||
generator.set("executable_path", s_chrome_process_executable_path);
|
||||
generator.append(template_file->data());
|
||||
return TRY(String::from_utf8(generator.as_string_view()));
|
||||
}
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
|
||||
namespace Web {
|
||||
|
||||
static String s_chrome_process_command_line {};
|
||||
static String s_chrome_process_executable_path {};
|
||||
|
||||
void set_chrome_process_command_line(StringView command_line);
|
||||
void set_chrome_process_executable_path(StringView executable_path);
|
||||
|
||||
ErrorOr<String> load_error_page(AK::URL const&);
|
||||
|
||||
ErrorOr<String> load_file_directory_page(AK::URL const&);
|
||||
|
|
|
@ -62,7 +62,7 @@ static StringView s_current_test_path;
|
|||
|
||||
class HeadlessWebContentView final : public WebView::ViewImplementation {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<HeadlessWebContentView>> create(Core::AnonymousBuffer theme, Gfx::IntSize const& window_size, StringView web_driver_ipc_path, Ladybird::IsLayoutTestMode is_layout_test_mode = Ladybird::IsLayoutTestMode::No)
|
||||
static ErrorOr<NonnullOwnPtr<HeadlessWebContentView>> create(Core::AnonymousBuffer theme, Gfx::IntSize const& window_size, String const& command_line, StringView web_driver_ipc_path, Ladybird::IsLayoutTestMode is_layout_test_mode = Ladybird::IsLayoutTestMode::No)
|
||||
{
|
||||
#if defined(AK_OS_SERENITY)
|
||||
auto database = TRY(WebView::Database::create());
|
||||
|
@ -77,9 +77,14 @@ public:
|
|||
|
||||
#if defined(AK_OS_SERENITY)
|
||||
view->m_client_state.client = TRY(WebView::WebContentClient::try_create(*view));
|
||||
(void)command_line;
|
||||
(void)is_layout_test_mode;
|
||||
#else
|
||||
Ladybird::WebContentOptions web_content_options { .is_layout_test_mode = is_layout_test_mode };
|
||||
Ladybird::WebContentOptions web_content_options {
|
||||
.command_line = command_line,
|
||||
.executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))),
|
||||
.is_layout_test_mode = is_layout_test_mode,
|
||||
};
|
||||
|
||||
auto candidate_web_content_paths = TRY(get_paths_for_helper_process("WebContent"sv));
|
||||
view->m_client_state.client = TRY(launch_web_content_process(*view, candidate_web_content_paths, web_content_options));
|
||||
|
@ -616,7 +621,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
is_layout_test_mode = true;
|
||||
}
|
||||
|
||||
auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, web_driver_ipc_path, is_layout_test_mode ? Ladybird::IsLayoutTestMode::Yes : Ladybird::IsLayoutTestMode::No));
|
||||
StringBuilder command_line_builder;
|
||||
command_line_builder.join(' ', arguments.strings);
|
||||
auto view = TRY(HeadlessWebContentView::create(move(theme), window_size, MUST(command_line_builder.to_string()), web_driver_ipc_path, is_layout_test_mode ? Ladybird::IsLayoutTestMode::Yes : Ladybird::IsLayoutTestMode::No));
|
||||
|
||||
if (!test_root_path.is_empty()) {
|
||||
return run_tests(*view, test_root_path, dump_failed_ref_tests);
|
||||
|
|
Loading…
Reference in a new issue