LibWeb: Don't delay document "load" event for unclosed script tags

We previously had a bug where markup with unclosed script tags caused
the document load event to be delayed indefinitely. Fix this by only
marking script elements as delaying the load event once we encounter
the script end tag.
This commit is contained in:
Andreas Kling 2022-03-19 14:22:46 +01:00
parent 462618b68c
commit 2c9dfadb21
Notes: sideshowbarker 2024-07-17 17:07:15 +09:00
3 changed files with 10 additions and 0 deletions

View file

@ -2093,6 +2093,11 @@ void HTMLParser::handle_text(HTMLToken& token)
flush_character_insertions();
NonnullRefPtr<HTMLScriptElement> script = verify_cast<HTMLScriptElement>(current_node());
// The document's "load" event is delayed until every script becomes ready.
// See HTMLScriptElement internals for how readiness is determined.
script->begin_delaying_document_load_event({}, *m_document);
(void)m_stack_of_open_elements.pop();
m_insertion_mode = m_original_insertion_mode;
// Let the old insertion point have the same value as the current insertion point.