diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream')
3 files changed, 105 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document-close-with-pending-script.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document-close-with-pending-script.html new file mode 100644 index 0000000000..1584ca5f97 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document-close-with-pending-script.html @@ -0,0 +1,67 @@ +<!doctype html> +<meta charset=utf-8> +<title>document.close called while a script is pending</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<body> + <script> + window.t = async_test(); + // We want start a document load, create an non-blocking script load inside + // it, have the parser complete, then call document.open()/document.close() + // after the parser is done but before the non-blocking script load + // completes. After we do that, the document should reach the 'complete' + // ready state and the iframe's load event should fire. + var loadFired = false; + var i; + + var finish = t.step_func_done(() => { + assert_equals(loadFired, true, "Should have fired a load event"); + assert_equals(i.contentDocument.readyState, "complete", + "Should be fully loaded"); + }); + + var checkForLoad = t.step_func(() => { + if (loadFired) { + finish(); + } else { + i.addEventListener("load", finish); + } + }); + + window.parserDone = t.step_func(() => { + var doc = i.contentDocument; + i.onload = () => { loadFired = true; } + doc.open(); + doc.close(); + // It's not very clearly specced whether the document is + // supposed to be fully loaded at this point or not, so allow + // that to be the case, or to happen soonish. + assert_true(doc.readyState == "interactive" || + doc.readyState == "complete", "Should be almost loaded"); + if (doc.readyState == "complete") { + checkForLoad(); + } else { + doc.addEventListener("readystatechange", checkForLoad); + } + }); + + t.step(() => { + i = document.createElement("iframe"); + i.srcdoc = ` + <script> + parent.t.step(() => { + var s = document.createElement("script"); + s.src = "/common/slow.py"; + document.documentElement.appendChild(s); + // Call into the parent async, so we finish our "end of parse" + // work before it runs. + document.addEventListener( + "DOMContentLoaded", + () => parent.t.step_timeout(parent.parserDone, 0)); + }); + <\/script> + `; + document.body.appendChild(i); + }); + </script> +</body> diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document.close-01.xhtml b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document.close-01.xhtml new file mode 100644 index 0000000000..164d71d191 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/document.close-01.xhtml @@ -0,0 +1,19 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>document.close in XHTML</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#closing-the-input-stream"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id="log"></div> +<script> +test(function() { + assert_throws_dom("INVALID_STATE_ERR", function() { + document.close(); + }, "document.close in XHTML should throw an INVALID_STATE_ERR "); +}, "document.close in XHTML"); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/load-event-after-location-set-during-write.window.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/load-event-after-location-set-during-write.window.js new file mode 100644 index 0000000000..d5c8469baf --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/closing-the-input-stream/load-event-after-location-set-during-write.window.js @@ -0,0 +1,19 @@ +// Make sure that the load event for an iframe doesn't fire at the +// point when a navigation triggered by document.write() starts in it, +// but rather when that navigation completes. + +async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + const doc = frame.contentDocument; + const url = URL.createObjectURL(new Blob(["PASS"], { type: "text/html"})); + + frame.onload = t.step_func_done(() => { + assert_equals(frame.contentDocument.body.textContent, "PASS", + "Why is our load event firing before the new document loaded?"); + }); + + doc.open(); + doc.write(`FAIL<script>location = "${url}"</` + "script>"); + doc.close(); +}, "Setting location from document.write() call should not trigger load event until that load completes"); + |