diff --git a/Libraries/LibWeb/DOM/HTMLScriptElement.h b/Libraries/LibWeb/DOM/HTMLScriptElement.h index f5bfe82286..9aba63d865 100644 --- a/Libraries/LibWeb/DOM/HTMLScriptElement.h +++ b/Libraries/LibWeb/DOM/HTMLScriptElement.h @@ -44,6 +44,7 @@ public: void set_parser_document(Badge, Document&); void set_non_blocking(Badge, bool); + void set_already_started(Badge, bool b) { m_already_started = b; } void prepare_script(Badge); void execute_script(); diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 31747bf609..15b57ccfce 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -1431,6 +1431,15 @@ void HTMLDocumentParser::handle_text(HTMLToken& token) insert_character(token.codepoint()); return; } + if (token.is_end_of_file()) { + PARSE_ERROR(); + if (current_node().tag_name() == "script") + to(current_node()).set_already_started({}, true); + m_stack_of_open_elements.pop(); + m_insertion_mode = m_original_insertion_mode; + process_using_the_rules_for(m_insertion_mode, token); + return; + } if (token.is_end_tag() && token.tag_name() == "script") { NonnullRefPtr script = to(current_node()); m_stack_of_open_elements.pop();