Skip to content

Commit

Permalink
LibWeb: Act as if parsing stopped when generating an error document
Browse files Browse the repository at this point in the history
The user agent now acts as if it has stopped parsing when creating a
document for inline content to display an error.
  • Loading branch information
skyz1 authored and tcl3 committed Dec 7, 2024
1 parent 6d7bb07 commit 88884c3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Libraries/LibWeb/HTML/Navigable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,10 +1171,18 @@ WebIDL::ExceptionOr<void> Navigable::populate_session_history_entry_document(
auto error_message = navigation_params.get<NullOrError>().value_or("Unknown error"sv);

auto error_html = load_error_page(entry->url(), error_message).release_value_but_fixme_should_propagate_errors();
entry->document_state()->set_document(create_document_for_inline_content(this, navigation_id, [error_html](auto& document) {
entry->document_state()->set_document(create_document_for_inline_content(this, navigation_id, [this, error_html](auto& document) {
auto parser = HTML::HTMLParser::create(document, error_html, "utf-8"sv);
document.set_url(URL::URL("about:error"));
parser->run();

// NOTE: Once the page has been set up, the user agent must act as if it had stopped parsing.
// FIXME: Directly calling parser->the_end results in a deadlock, because it waits for the warning image to load.
// However the response is never processed when parser->the_end is called.
// Queuing a global task is a workaround for now.
queue_a_task(Task::Source::Unspecified, HTML::main_thread_event_loop(), document, GC::create_function(heap(), [&document]() {
HTMLParser::the_end(document);
}));
}));

// 2. Make document unsalvageable given entry's document state's document and "navigation-failure".
Expand Down

0 comments on commit 88884c3

Please sign in to comment.