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.
This commit is contained in:
parent
eaf2384f1c
commit
ff2123a949
Notes:
sideshowbarker
2024-07-16 18:26:46 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/ff2123a949 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/441 Reviewed-by: https://github.com/ADKaster
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…
Add table
Reference in a new issue