mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibWeb: Set readyState to complete for DOMParser documents
Documents created via DOMParser.parseFromString() are parsed synchronously and do not participate in the browsing context's loading pipeline. This patch ensures that if the document has no browsing context (i.e. was parsed via DOMParser), its readiness is set to "complete" synchronously. Fixes WPT: domparsing/xmldomparser.html
This commit is contained in:
parent
b00e57139f
commit
ff78746be1
Notes:
github-actions[bot]
2025-06-25 08:50:18 +00:00
Author: https://github.com/mikiubo
Commit: ff78746be1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4992
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/shannonbooth ✅
6 changed files with 36 additions and 2 deletions
|
@ -324,6 +324,15 @@ void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> pa
|
|||
(void)parser->m_stack_of_open_elements.pop();
|
||||
}
|
||||
|
||||
// AD-HOC: Skip remaining steps when there's no browsing context.
|
||||
// This happens when parsing HTML via DOMParser or similar mechanisms.
|
||||
// Note: This diverges from the spec, which expects more steps to follow.
|
||||
if (!document->browsing_context()) {
|
||||
// Parsed via DOMParser, no need to wait for load events.
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. While the list of scripts that will execute when the document has finished parsing is not empty:
|
||||
while (!document->scripts_to_execute_when_parsing_has_finished().is_empty()) {
|
||||
// 1. Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue