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:
mikiubo 2025-06-04 09:44:03 +02:00 committed by Shannon Booth
parent b00e57139f
commit ff78746be1
Notes: github-actions[bot] 2025-06-25 08:50:18 +00:00
6 changed files with 36 additions and 2 deletions

View file

@ -275,6 +275,12 @@ void XMLDocumentBuilder::document_end()
// Pop all the nodes off the stack of open elements.
// NOTE: Noop.
if (!m_document->browsing_context()) {
// Parsed via DOMParser, no need to wait for load events.
m_document->update_readiness(HTML::DocumentReadyState::Complete);
return;
}
// While the list of scripts that will execute when the document has finished parsing is not empty:
while (!m_document->scripts_to_execute_when_parsing_has_finished().is_empty()) {
// Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing has its "ready to be parser-executed" flag set