mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird: Add an option to enable internals object outside of test mode
Sometimes I like to play around with running Ladybird tests using full blown Ladybird instead of just headless browser to interactively mess around with the test page. One problem with this is that the internals object is not exposed in this mode. This commit supports this usecase by adding an option to specifically expose the internals object without needing to run headless-browser in test mode.
This commit is contained in:
parent
1ec6399c00
commit
5bf34ecc32
Notes:
sideshowbarker
2024-07-17 07:48:42 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/5bf34ecc32 Pull-request: https://github.com/SerenityOS/serenity/pull/24047
@ -59,6 +59,8 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
||||
arguments.append("--log-all-js-exceptions"sv);
|
||||
if (web_content_options.enable_idl_tracing == Ladybird::EnableIDLTracing::Yes)
|
||||
arguments.append("--enable-idl-tracing"sv);
|
||||
if (web_content_options.expose_internals_object == Ladybird::ExposeInternalsObject::Yes)
|
||||
arguments.append("--expose-internals-object"sv);
|
||||
if (auto server = mach_server_name(); server.has_value()) {
|
||||
arguments.append("--mach-server-name"sv);
|
||||
arguments.append(server.value());
|
||||
|
@ -82,6 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
bool enable_callgrind_profiling = false;
|
||||
bool disable_sql_database = false;
|
||||
bool enable_qt_networking = false;
|
||||
bool expose_internals_object = false;
|
||||
bool use_gpu_painting = false;
|
||||
bool debug_web_content = false;
|
||||
bool log_all_js_exceptions = false;
|
||||
@ -99,6 +100,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
|
||||
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
|
||||
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
|
||||
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
WebView::ProcessManager::initialize();
|
||||
@ -149,6 +151,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
.wait_for_debugger = debug_web_content ? Ladybird::WaitForDebugger::Yes : Ladybird::WaitForDebugger::No,
|
||||
.log_all_js_exceptions = log_all_js_exceptions ? Ladybird::LogAllJSExceptions::Yes : Ladybird::LogAllJSExceptions::No,
|
||||
.enable_idl_tracing = enable_idl_tracing ? Ladybird::EnableIDLTracing::Yes : Ladybird::EnableIDLTracing::No,
|
||||
.expose_internals_object = expose_internals_object ? Ladybird::ExposeInternalsObject::Yes : Ladybird::ExposeInternalsObject::No,
|
||||
};
|
||||
|
||||
Ladybird::BrowserWindow window(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path);
|
||||
|
@ -45,6 +45,11 @@ enum class EnableIDLTracing {
|
||||
Yes
|
||||
};
|
||||
|
||||
enum class ExposeInternalsObject {
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
|
||||
struct WebContentOptions {
|
||||
String command_line;
|
||||
String executable_path;
|
||||
@ -55,6 +60,7 @@ struct WebContentOptions {
|
||||
WaitForDebugger wait_for_debugger { WaitForDebugger::No };
|
||||
LogAllJSExceptions log_all_js_exceptions { LogAllJSExceptions::No };
|
||||
EnableIDLTracing enable_idl_tracing { EnableIDLTracing::No };
|
||||
ExposeInternalsObject expose_internals_object { ExposeInternalsObject::No };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
Vector<ByteString> certificates;
|
||||
int request_server_socket { -1 };
|
||||
bool is_layout_test_mode = false;
|
||||
bool expose_internals_object = false;
|
||||
bool use_lagom_networking = false;
|
||||
bool use_gpu_painting = false;
|
||||
bool wait_for_debugger = false;
|
||||
@ -105,6 +106,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_option(executable_path, "Chrome process executable path", "executable-path", 0, "executable_path");
|
||||
args_parser.add_option(request_server_socket, "File descriptor of the socket for the RequestServer connection", "request-server-socket", 'r', "request_server_socket");
|
||||
args_parser.add_option(is_layout_test_mode, "Is layout test mode", "layout-test-mode");
|
||||
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
||||
args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking");
|
||||
args_parser.add_option(use_gpu_painting, "Enable GPU painting", "use-gpu-painting");
|
||||
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
|
||||
@ -118,6 +120,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
Core::Process::wait_for_debugger_and_break();
|
||||
}
|
||||
|
||||
// Layout test mode implies internals object is exposed
|
||||
if (is_layout_test_mode)
|
||||
expose_internals_object = true;
|
||||
|
||||
Web::set_chrome_process_command_line(command_line);
|
||||
Web::set_chrome_process_executable_path(executable_path);
|
||||
if (use_gpu_painting) {
|
||||
@ -137,7 +143,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
#endif
|
||||
TRY(initialize_lagom_networking(request_server_socket));
|
||||
|
||||
Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode);
|
||||
Web::HTML::Window::set_internals_object_exposed(expose_internals_object);
|
||||
|
||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user