diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 5e05f97ca6..fde231d79c 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -118,11 +119,28 @@ WebIDL::ExceptionOr> TraversableNavigable { // 1. Let traversable be the result of creating a new top-level traversable given null and the empty string. auto traversable = TRY(create_a_new_top_level_traversable(page, nullptr, {})); + page->set_top_level_traversable(traversable); - // 2. Navigate traversable to initialNavigationURL using traversable's active document, with documentResource set to initialNavigationPostResource. - TRY(traversable->navigate({ .url = initial_navigation_url, - .source_document = *traversable->active_document(), - .document_resource = initial_navigation_post_resource })); + // AD-HOC: Mark the about:blank document as finished parsing if we're only going to about:blank + // Skip the initial navigation as well. This matches the behavior of the window open steps. + + if (url_matches_about_blank(initial_navigation_url)) { + Platform::EventLoopPlugin::the().deferred_invoke([traversable, initial_navigation_url] { + // FIXME: We do this other places too when creating a new about:blank document. Perhaps it's worth a spec issue? + HTML::HTMLParser::the_end(*traversable->active_document()); + + // FIXME: If we perform the URL and history update steps here, we start hanging tests and the UI process will + // try to load() the initial URLs passed on the command line before we finish processing the events here. + // However, because we call this before the PageClient is fully initialized... that gets awkward. + }); + } + + else { + // 2. Navigate traversable to initialNavigationURL using traversable's active document, with documentResource set to initialNavigationPostResource. + TRY(traversable->navigate({ .url = initial_navigation_url, + .source_document = *traversable->active_document(), + .document_resource = initial_navigation_post_resource })); + } // 3. Return traversable. return traversable; diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index a219dff7f0..5639abe8b2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -61,7 +61,7 @@ ErrorOr> SVGDecodedImageData::create(JS::R auto page_client = SVGPageClient::create(Bindings::main_thread_vm(), host_page); auto page = Page::create(Bindings::main_thread_vm(), *page_client); page_client->m_svg_page = page.ptr(); - page->set_top_level_traversable(MUST(Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(*page, AK::URL("about:blank")))); + page->set_top_level_traversable(MUST(Web::HTML::TraversableNavigable::create_a_new_top_level_traversable(*page, nullptr, {}))); JS::NonnullGCPtr navigable = page->top_level_traversable(); auto response = Fetch::Infrastructure::Response::create(navigable->vm()); response->url_list().append(url); diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index c95b06bf66..c642e50eeb 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -19,7 +19,7 @@ PageHost::PageHost(ConnectionFromClient& client) : m_client(client) { auto& first_page = create_page(); - first_page.page().set_top_level_traversable(Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), AK::URL("about:blank")).release_value_but_fixme_should_propagate_errors()); + Web::HTML::TraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), AK::URL("about:blank")).release_value_but_fixme_should_propagate_errors(); } PageClient& PageHost::create_page()