mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
WebDriver: Add a --debug-process
option
This forwards the `--debug-process` argument to the browser process launched by WebDriver.
This commit is contained in:
parent
30d915c361
commit
2528055703
Notes:
github-actions[bot]
2024-12-20 22:43:08 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/25280557032 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2886 Reviewed-by: https://github.com/gmta
1 changed files with 13 additions and 7 deletions
|
@ -33,7 +33,7 @@ static ErrorOr<Core::Process> launch_process(StringView application, ReadonlySpa
|
|||
return result;
|
||||
}
|
||||
|
||||
static Vector<ByteString> create_arguments(ByteString const& socket_path, bool force_cpu_painting)
|
||||
static Vector<ByteString> create_arguments(ByteString const& socket_path, bool force_cpu_painting, Optional<StringView> debug_process)
|
||||
{
|
||||
Vector<ByteString> arguments {
|
||||
"--webdriver-content-path"sv,
|
||||
|
@ -52,19 +52,23 @@ static Vector<ByteString> create_arguments(ByteString const& socket_path, bool f
|
|||
if (force_cpu_painting)
|
||||
arguments.append("--force-cpu-painting"sv);
|
||||
|
||||
dbgln("Debug process: {}", debug_process);
|
||||
if (debug_process.has_value())
|
||||
arguments.append(ByteString::formatted("--debug-process={}", debug_process.value()));
|
||||
|
||||
arguments.append("about:blank"sv);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
static ErrorOr<Core::Process> launch_browser(ByteString const& socket_path, bool force_cpu_painting)
|
||||
static ErrorOr<Core::Process> launch_browser(ByteString const& socket_path, bool force_cpu_painting, Optional<StringView> debug_process)
|
||||
{
|
||||
auto arguments = create_arguments(socket_path, force_cpu_painting);
|
||||
auto arguments = create_arguments(socket_path, force_cpu_painting, move(debug_process));
|
||||
return launch_process("Ladybird"sv, arguments.span());
|
||||
}
|
||||
|
||||
static ErrorOr<Core::Process> launch_headless_browser(ByteString const& socket_path, bool force_cpu_painting)
|
||||
static ErrorOr<Core::Process> launch_headless_browser(ByteString const& socket_path, bool force_cpu_painting, Optional<StringView> debug_process)
|
||||
{
|
||||
auto arguments = create_arguments(socket_path, force_cpu_painting);
|
||||
auto arguments = create_arguments(socket_path, force_cpu_painting, move(debug_process));
|
||||
return launch_process("headless-browser"sv, arguments.span());
|
||||
}
|
||||
|
||||
|
@ -76,12 +80,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
int port = 8000;
|
||||
bool force_cpu_painting = false;
|
||||
bool headless = false;
|
||||
Optional<StringView> debug_process;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");
|
||||
args_parser.add_option(port, "Port to listen on", "port", 'p', "port");
|
||||
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
|
||||
args_parser.add_option(force_cpu_painting, "Launch browser with GPU painting disabled", "force-cpu-painting");
|
||||
args_parser.add_option(debug_process, "Wait for a debugger to attach to the given process name (WebContent, RequestServer, etc.)", "debug-process", 0, "process-name");
|
||||
args_parser.add_option(headless, "Launch browser without a graphical interface", "headless");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
|
@ -121,11 +127,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
auto launch_browser_callback = [&](ByteString const& socket_path) {
|
||||
return launch_browser(socket_path, force_cpu_painting);
|
||||
return launch_browser(socket_path, force_cpu_painting, debug_process);
|
||||
};
|
||||
|
||||
auto launch_headless_browser_callback = [&](ByteString const& socket_path) {
|
||||
return launch_headless_browser(socket_path, force_cpu_painting);
|
||||
return launch_headless_browser(socket_path, force_cpu_painting, debug_process);
|
||||
};
|
||||
|
||||
auto maybe_client = WebDriver::Client::try_create(maybe_buffered_socket.release_value(), { move(launch_browser_callback), move(launch_headless_browser_callback) }, server);
|
||||
|
|
Loading…
Reference in a new issue