diff --git a/Base/res/html/misc/welcome.html b/Base/res/html/misc/welcome.html
index ceabf7b798..625131f188 100644
--- a/Base/res/html/misc/welcome.html
+++ b/Base/res/html/misc/welcome.html
@@ -41,6 +41,9 @@
column-width: 250px;
}
+
diff --git a/Base/res/html/misc/welcome.js b/Base/res/html/misc/welcome.js
index 83dcbc8886..9ba3388e12 100644
--- a/Base/res/html/misc/welcome.js
+++ b/Base/res/html/misc/welcome.js
@@ -1,3 +1,6 @@
document.addEventListener("DOMContentLoaded", function () {
+ console.log(
+ "Hello from DOMContentLoaded! There should be a message before this from an inline script"
+ );
document.getElementById("ua").innerHTML = navigator.userAgent;
});
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_create_main_document()
+{
+ m_client.initialize_js_console({});
+}
+
void PageHost::page_did_finish_loading(const URL& url)
{
- // FIXME: This is called after the page has finished loading, which means any log messages
- // that happen *while* it is loading (such as inline