mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
WebDriver: Add commandline option to pass extra certificates
This is useful for running WPT
This commit is contained in:
parent
96675e61cd
commit
ff9eb62f3d
1 changed files with 17 additions and 6 deletions
|
@ -16,6 +16,8 @@
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <WebDriver/Client.h>
|
#include <WebDriver/Client.h>
|
||||||
|
|
||||||
|
static Vector<ByteString> certificates;
|
||||||
|
|
||||||
static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char const*> arguments)
|
static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char const*> arguments)
|
||||||
{
|
{
|
||||||
auto paths = TRY(get_paths_for_helper_process(application));
|
auto paths = TRY(get_paths_for_helper_process(application));
|
||||||
|
@ -32,12 +34,20 @@ static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char c
|
||||||
|
|
||||||
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
|
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
|
||||||
{
|
{
|
||||||
return launch_process("Ladybird"sv,
|
auto arguments = Vector {
|
||||||
Array {
|
|
||||||
"--webdriver-content-path",
|
"--webdriver-content-path",
|
||||||
socket_path.characters(),
|
socket_path.characters(),
|
||||||
"about:blank",
|
};
|
||||||
});
|
|
||||||
|
Vector<ByteString> certificate_args;
|
||||||
|
for (auto const& certificate : certificates) {
|
||||||
|
certificate_args.append(ByteString::formatted("--certificate={}", certificate));
|
||||||
|
arguments.append(certificate_args.last().view().characters_without_null_termination());
|
||||||
|
}
|
||||||
|
|
||||||
|
arguments.append("about:blank");
|
||||||
|
|
||||||
|
return launch_process("Ladybird"sv, arguments.span());
|
||||||
}
|
}
|
||||||
|
|
||||||
static ErrorOr<pid_t> launch_headless_browser(ByteString const& socket_path)
|
static ErrorOr<pid_t> launch_headless_browser(ByteString const& socket_path)
|
||||||
|
@ -63,6 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
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.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
auto ipv4_address = IPv4Address::from_string(listen_address);
|
auto ipv4_address = IPv4Address::from_string(listen_address);
|
||||||
|
|
Loading…
Add table
Reference in a new issue