diff options
author | davidot <davidot@serenityos.org> | 2022-09-21 17:12:00 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-09-21 17:34:32 +0100 |
commit | 4912b22e3ba4b8aa5bf9cc6a8b41dda39cf44b48 (patch) | |
tree | e08683eda0589f66e620e1c0594eed55c2f6bdb6 /Userland | |
parent | 446a10a1acaf5310125c06979acd41973f52e8d9 (diff) | |
download | serenity-4912b22e3ba4b8aa5bf9cc6a8b41dda39cf44b48.zip |
LibWeb+WebContent: Setup the js console client earlier
This allows us to print messages in inline scripts. Also add an example
of this in the welcome page to test this.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/FrameLoader.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Page/Page.h | 1 | ||||
-rw-r--r-- | Userland/Services/WebContent/PageHost.cpp | 8 | ||||
-rw-r--r-- | Userland/Services/WebContent/PageHost.h | 1 |
4 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 65f438af53..ce6cdec8c1 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -398,6 +398,8 @@ void FrameLoader::resource_did_load() document->set_content_type(resource()->mime_type()); browsing_context().set_active_document(document); + if (auto* page = browsing_context().page()) + page->client().page_did_create_main_document(); if (!parse_document(*document, resource()->encoded_data())) { load_error_page(url, "Failed to parse content."); diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index e9f8b29c39..bad16da293 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -86,6 +86,7 @@ public: virtual CSS::PreferredColorScheme preferred_color_scheme() const = 0; virtual void page_did_change_title(String const&) { } virtual void page_did_start_loading(const AK::URL&) { } + virtual void page_did_create_main_document() { } virtual void page_did_finish_loading(const AK::URL&) { } virtual void page_did_change_selection() { } virtual void page_did_request_cursor_change(Gfx::StandardCursor) { } diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 883c5fa43a..dc1ee8c04e 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -187,11 +187,13 @@ void PageHost::page_did_start_loading(const URL& url) m_client.async_did_start_loading(url); } -void PageHost::page_did_finish_loading(const URL& url) +void PageHost::page_did_create_main_document() { - // FIXME: This is called after the page has finished loading, which means any log messages - // that happen *while* it is loading (such as inline <script>s) will be lost. m_client.initialize_js_console({}); +} + +void PageHost::page_did_finish_loading(const URL& url) +{ m_client.async_did_finish_loading(url); } diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 13faaa5819..6ce85c4b0b 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -57,6 +57,7 @@ private: virtual void page_did_request_context_menu(Gfx::IntPoint const&) override; virtual void page_did_request_link_context_menu(Gfx::IntPoint const&, const URL&, String const& target, unsigned modifiers) override; virtual void page_did_start_loading(const URL&) override; + virtual void page_did_create_main_document() override; virtual void page_did_finish_loading(const URL&) override; virtual void page_did_request_alert(String const&) override; virtual bool page_did_request_confirm(String const&) override; |