diff --git a/Tests/LibWeb/Text/expected/HTML/set-innerHTML-with-script.txt b/Tests/LibWeb/Text/expected/HTML/set-innerHTML-with-script.txt new file mode 100644 index 0000000000..5df6241a8b --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/set-innerHTML-with-script.txt @@ -0,0 +1 @@ + PASS diff --git a/Tests/LibWeb/Text/input/HTML/set-innerHTML-with-script.html b/Tests/LibWeb/Text/input/HTML/set-innerHTML-with-script.html new file mode 100644 index 0000000000..46301fc433 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/set-innerHTML-with-script.html @@ -0,0 +1,9 @@ + +
+ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 79b413e6e2..65b2f523c1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -71,6 +71,11 @@ void HTMLScriptElement::begin_delaying_document_load_event(DOM::Document& docume // https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block void HTMLScriptElement::execute_script() { + // https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-html + // Before any script execution occurs, the user agent must wait for scripts may run for the newly-created document to be true for document. + if (!m_document->ready_to_run_scripts()) + main_thread_event_loop().spin_until([&] { return m_document->ready_to_run_scripts(); }); + // 1. Let document be el's node document. JS::NonnullGCPtr