From 5eb0f65cc01e8f8ec499b295a6998aa5b2ac975b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 30 Aug 2023 06:45:08 -0400 Subject: [PATCH] LibWebView: Do not block the console for the initial message request If we set m_waiting_for_messages to true for the intial message request, we might never receive a response, and block the console from requesting any more messages indefinitely. Instead, issue a non-blocking initial request, which is how the Qt and Serenity chromes behaved before the ConsoleClient abstraction. This also changes ConsoleClient::clear() to use run_javascript() rather than js_console_input(), as that is also how the chromes used to behave. --- Userland/Libraries/LibWebView/ConsoleClient.cpp | 11 +++-------- Userland/Libraries/LibWebView/ConsoleClient.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibWebView/ConsoleClient.cpp b/Userland/Libraries/LibWebView/ConsoleClient.cpp index da177d9560..59aa8cac72 100644 --- a/Userland/Libraries/LibWebView/ConsoleClient.cpp +++ b/Userland/Libraries/LibWebView/ConsoleClient.cpp @@ -34,7 +34,7 @@ ConsoleClient::ConsoleClient(ViewImplementation& content_web_view, ViewImplement // Wait until our output WebView is loaded, and then request any messages that occurred before we existed. m_console_web_view.on_load_finish = [this](auto const&) { - request_console_messages(0); + m_content_web_view.js_console_request_messages(0); }; m_console_web_view.use_native_user_style_sheet(); @@ -55,7 +55,7 @@ void ConsoleClient::execute(StringView script) void ConsoleClient::clear() { - m_console_web_view.js_console_input("document.body.innerHTML = \"\";"sv); + m_console_web_view.run_javascript("document.body.innerHTML = \"\";"sv); m_group_stack.clear(); } @@ -151,15 +151,10 @@ void ConsoleClient::print_html(StringView html) } void ConsoleClient::request_console_messages() -{ - request_console_messages(m_highest_received_message_index + 1); -} - -void ConsoleClient::request_console_messages(i32 start_index) { VERIFY(!m_waiting_for_messages); - m_content_web_view.js_console_request_messages(start_index); + m_content_web_view.js_console_request_messages(m_highest_received_message_index + 1); m_waiting_for_messages = true; } diff --git a/Userland/Libraries/LibWebView/ConsoleClient.h b/Userland/Libraries/LibWebView/ConsoleClient.h index 6f81c76d68..669a92b1a5 100644 --- a/Userland/Libraries/LibWebView/ConsoleClient.h +++ b/Userland/Libraries/LibWebView/ConsoleClient.h @@ -33,7 +33,6 @@ private: void print_html(StringView); void request_console_messages(); - void request_console_messages(i32 start_index); void begin_group(StringView label, bool start_expanded); void end_group();