mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +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:
		
							parent
							
								
									889b903e40
								
							
						
					
					
						commit
						53273e2037
					
				
					 3 changed files with 24 additions and 6 deletions
				
			
		|  | @ -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; | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ ErrorOr<JS::NonnullGCPtr<SVGDecodedImageData>> 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<HTML::Navigable> navigable = page->top_level_traversable(); | ||||
|     auto response = Fetch::Infrastructure::Response::create(navigable->vm()); | ||||
|     response->url_list().append(url); | ||||
|  |  | |||
|  | @ -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() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Kaster
						Andrew Kaster