LibWebView+WebContent: Create a different console client for DevTools

Our existing WebContentConsoleClient is very specific to our home-grown
Inspector. It renders console output to an HTML string. For DevTools, we
will not want this behavior; we will want to send representations of raw
JS values.

This patch makes WebContentConsoleClient a base class to handle console
input from the user, either from the Inspector or from DevTools. It then
moves the HTML rendering needed for the Inspector to a new class,
InspectorConsoleClient. And we add a DevToolsConsoleClient (currently
just stubbed) to handle needs specific to DevTools.

We choose at runtime which console client to install, based on the
--devtools command line flag.
This commit is contained in:
Timothy Flynn 2025-02-24 09:48:13 -05:00 committed by Andreas Kling
commit 37f07c176a
Notes: github-actions[bot] 2025-02-28 12:09:47 +00:00
12 changed files with 419 additions and 229 deletions

View file

@ -107,6 +107,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool collect_garbage_on_every_allocation = false;
bool is_headless = false;
bool disable_scrollbar_painting = false;
bool devtools = false;
StringView echo_server_port_string_view {};
Core::ArgsParser args_parser;
@ -129,6 +130,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(disable_scrollbar_painting, "Don't paint horizontal or vertical viewport scrollbars", "disable-scrollbar-painting");
args_parser.add_option(echo_server_port_string_view, "Echo server port used in test internals", "echo-server-port", 0, "echo_server_port");
args_parser.add_option(is_headless, "Report that the browser is running in headless mode", "headless");
args_parser.add_option(devtools, "Report that the browser is running with Firefox DevTools support", "devtools");
args_parser.parse(arguments);
@ -155,6 +157,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
WebContent::PageClient::set_use_skia_painter(force_cpu_painting ? WebContent::PageClient::UseSkiaPainter::CPUBackend : WebContent::PageClient::UseSkiaPainter::GPUBackendIfAvailable);
WebContent::PageClient::set_is_headless(is_headless);
WebContent::PageClient::set_devtools_enabled(devtools);
if (enable_http_cache) {
Web::Fetch::Fetching::g_http_cache_enabled = true;