1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibWeb: Don't navigate() to about:blank when making a fresh Traversable

This matches the behavior of the window open steps, and should probably
be a spec issue :yakplus:
This commit is contained in:
Andrew Kaster 2024-02-07 09:03:47 -07:00 committed by Andreas Kling
parent 889b903e40
commit 53273e2037
3 changed files with 24 additions and 6 deletions

View file

@ -11,6 +11,7 @@
#include <LibWeb/HTML/DocumentState.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/SessionHistoryEntry.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/HTML/Window.h>
@ -118,11 +119,28 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> 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;