Files
sousa-gecko/testing/web-platform/tests/domparsing/tentative/stream-html-run-scripts-option.html
T
Noam Rosenthal 7f4d406d0c Bug 2022903 [wpt PR 58450] - Separate between HTML streaming and <template for> patching, a=testonly
Automatic update from web-platform-tests
Separate between HTML streaming and <template for> patching

HTML streaming, as well as the new positional methods, receive a
"NewHTMLSettingMethods" runtime flag, and move to domparsing/tentative,
to separate them from the somewhat orthogonal <template for> patching.

Bug: 491743369
Change-Id: Ic411e1af7c5644be3062564683d039d6847427b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7657845
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@google.com>
Cr-Commit-Position: refs/heads/main@{#1598305}

--

wpt-commits: f132f6179b468268083f40463abc93b3242b989e
wpt-pr: 58450
2026-03-16 10:13:01 +00:00

57 lines
2.5 KiB
HTML

<!DOCTYPE HTML>
<meta charset="utf-8" />
<title>streamAppendHTMLUnsafe with scripts</title>
<link rel=help href="https://github.com/WICG/declarative-partial-updates">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="placeholder"></div>
<script>
for (const method of ["streamAppendHTMLUnsafe", "streamHTMLUnsafe"]) {
promise_test(async t => {
const placeholder = document.getElementById("placeholder");
const writable = placeholder[method]({runScripts: true});
const writer = writable.getWriter();
t.add_cleanup(() => { window.did_run = false });
await writer.write("<script>window.did_run = true;</" + "script>");
await writer.close();
assert_true(window.did_run);
}, `element.${method} with runScripts: true`);
promise_test(async t => {
const placeholder = document.getElementById("placeholder");
const writable = placeholder[method]({runScripts: false});
const writer = writable.getWriter();
t.add_cleanup(() => { window.did_run = false });
await writer.write("<script>window.did_run = true;</" + "script>");
await writer.close();
assert_false(window.did_run);
}, `element.${method} with runScripts: false`);
promise_test(async t => {
const placeholder = document.getElementById("placeholder");
const element = document.createElement("div");
placeholder.append(element);
t.add_cleanup(() => element.remove());
const shadowRoot = element.attachShadow({mode: "open"});
const writer = shadowRoot[method]({runScripts: false}).getWriter();
window.did_run = false;
await writer.write("<script>window.did_run = true;<" + "/script>");
await writer.close();
assert_false(window.did_run);
}, `shadowRoot.${method} with runScripts: false`);
promise_test(async t => {
const placeholder = document.getElementById("placeholder");
const element = document.createElement("div");
placeholder.append(element);
t.add_cleanup(() => element.remove());
const shadowRoot = element.attachShadow({mode: "open"});
const writer = shadowRoot[method]({runScripts: true}).getWriter();
window.did_run = false;
await writer.write("<script>window.did_run = true;<" + "/script>");
await writer.close();
assert_true(window.did_run);
}, `shadowRoot.${method} with runScripts: true`);
}
</script>