mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Act as if parsing stopped when generating an error document
The user agent now acts as if it has stopped parsing when creating a document for inline content to display an error.
This commit is contained in:
parent
6d7bb074fc
commit
88884c370c
Notes:
github-actions[bot]
2024-12-07 08:39:00 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/88884c370cb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2763 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 9 additions and 1 deletions
|
@ -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".
|
||||
|
|
Loading…
Add table
Reference in a new issue