mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
WebDriver: Add option to use Qt networking
Using Qt networking when running web platform tests improves performance significantly. The time to run the subset of tests we run on CI drops from 21.9 seconds to 8.2 seconds on my machine. (cherry picked from commit ff2123a949446b834e6c3b0be7ca4c994d71f3e1)
This commit is contained in:
parent
6b06454d5d
commit
42712fd165
1 changed files with 10 additions and 2 deletions
|
@ -32,7 +32,7 @@ static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char c
|
|||
return result;
|
||||
}
|
||||
|
||||
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
|
||||
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path, bool use_qt_networking)
|
||||
{
|
||||
auto arguments = Vector {
|
||||
"--webdriver-content-path",
|
||||
|
@ -47,6 +47,8 @@ static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
|
|||
|
||||
arguments.append("--allow-popups");
|
||||
arguments.append("--force-new-process");
|
||||
if (use_qt_networking)
|
||||
arguments.append("--enable-qt-networking");
|
||||
|
||||
arguments.append("about:blank");
|
||||
|
||||
|
@ -72,11 +74,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto listen_address = "0.0.0.0"sv;
|
||||
int port = 8000;
|
||||
bool enable_qt_networking = false;
|
||||
|
||||
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(enable_qt_networking, "Launch browser with Qt networking enabled", "enable-qt-networking");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto ipv4_address = IPv4Address::from_string(listen_address);
|
||||
|
@ -112,7 +116,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
}
|
||||
|
||||
auto maybe_client = WebDriver::Client::try_create(maybe_buffered_socket.release_value(), { launch_browser, launch_headless_browser }, server);
|
||||
auto launch_browser_callback = [&](ByteString const& socket_path) {
|
||||
return launch_browser(socket_path, enable_qt_networking);
|
||||
};
|
||||
|
||||
auto maybe_client = WebDriver::Client::try_create(maybe_buffered_socket.release_value(), { move(launch_browser_callback), launch_headless_browser }, server);
|
||||
if (maybe_client.is_error()) {
|
||||
warnln("Could not create a WebDriver client: {}", maybe_client.error());
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue