mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00: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:
committed by
Jelle Raaijmakers
parent
30d915c361
commit
2528055703
@@ -33,7 +33,7 @@ static ErrorOr<Core::Process> launch_process(StringView application, ReadonlySpa
|
|||||||
return result;
|
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 {
|
Vector<ByteString> arguments {
|
||||||
"--webdriver-content-path"sv,
|
"--webdriver-content-path"sv,
|
||||||
@@ -52,19 +52,23 @@ static Vector<ByteString> create_arguments(ByteString const& socket_path, bool f
|
|||||||
if (force_cpu_painting)
|
if (force_cpu_painting)
|
||||||
arguments.append("--force-cpu-painting"sv);
|
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);
|
arguments.append("about:blank"sv);
|
||||||
return arguments;
|
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());
|
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());
|
return launch_process("headless-browser"sv, arguments.span());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +80,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
int port = 8000;
|
int port = 8000;
|
||||||
bool force_cpu_painting = false;
|
bool force_cpu_painting = false;
|
||||||
bool headless = false;
|
bool headless = false;
|
||||||
|
Optional<StringView> debug_process;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");
|
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(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(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(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.add_option(headless, "Launch browser without a graphical interface", "headless");
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
@@ -121,11 +127,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto launch_browser_callback = [&](ByteString const& socket_path) {
|
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) {
|
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);
|
auto maybe_client = WebDriver::Client::try_create(maybe_buffered_socket.release_value(), { move(launch_browser_callback), move(launch_headless_browser_callback) }, server);
|
||||||
|
|||||||
Reference in New Issue
Block a user