Truly independent web browser
LibWeb: Allow scripts to run before a new document's scripts may run
Andreas Klinge86640eada29
diff --git a/Libraries/LibWeb/HTML/HTMLOrSVGScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLOrSVGScriptElement.cppindex 547ffeabd1b..f70a8d2a09a 100644--- a/Libraries/LibWeb/HTML/HTMLOrSVGScriptElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLOrSVGScriptElement.cpp@@ -117,10 +117,6 @@ void HTMLOrSVGScriptElement::execute_script()return;}- // 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.- VERIFY(document->ready_to_run_scripts());-// 3. Unblock rendering on el.element.unblock_rendering();diff --git a/Tests/LibWeb/Crash/HTML/script-inserted-into-new-iframe-document-before-scripts-may-run.html b/Tests/LibWeb/Crash/HTML/script-inserted-into-new-iframe-document-before-scripts-may-run.htmlnew file mode 100644index 00000000000..b03eb5c901d--- /dev/null+++ b/Tests/LibWeb/Crash/HTML/script-inserted-into-new-iframe-document-before-scripts-may-run.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<iframe id="frame" srcdoc="<p>child"></iframe>+<script>+ // The iframe's new document becomes its active document a task before scripts may run for it.+ // Keep a task queued so that we look at the iframe in between.+ const initialDocument = frame.contentDocument;+ let loaded = false;+ window.onload = () => { loaded = true; };+ window.onmessage = () => {+ const newDocument = frame.contentDocument;+ if (newDocument && newDocument !== initialDocument) {+ const script = newDocument.createElement("script");+ script.textContent = "1";+ newDocument.appendChild(script);+ return;+ }+ if (!loaded)+ postMessage("poll");+ };+ postMessage("poll");+</script>