tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b304f70dad00e537e08a132bd67aeca6df298fd2
parent ee96e7d006ef2824cc4aa89e24fe583e0da4a1b3
Author: Noam Rosenthal <nrosenthal@chromium.org>
Date:   Thu,  9 Oct 2025 20:33:34 +0000

Bug 1992161 [wpt PR 55177] - Enable scripting as a result of a patch., a=testonly

Automatic update from web-platform-tests
Enable scripting as a result of a patch.

WHATWG discussion about this is ongoing, considering to at least allow
opting into this using a flag.

This exposed a bug when nesting <script> inside <template patchfor>,
which broke the tokenizer state machine.

Fixed by keeping the tokenizer at RAWTEXT when inside a patch,
even when exiting a script.

See https://github.com/whatwg/html/issues/11669

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

--

wpt-commits: 9d2d277f38479702f4c6b8f2ca3d58029fb8792e
wpt-pr: 55177

Diffstat:
Atesting/web-platform/tests/html/dom/partial-updates/tentative/patch-self-scripting.html | 32++++++++++++++++++++++++++++++++
Atesting/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting-nested.html | 21+++++++++++++++++++++
Atesting/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting.html | 22++++++++++++++++++++++
3 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/html/dom/partial-updates/tentative/patch-self-scripting.html b/testing/web-platform/tests/html/dom/partial-updates/tentative/patch-self-scripting.html @@ -0,0 +1,31 @@ +<!DOCTYPE HTML> +<meta charset="utf-8" /> +<title>HTML partial updates - executing scripts during streaming</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> +promise_test(async t => { + const placeholder = document.querySelector("#placeholder"); + const writable = placeholder.patchSelf(); + assert_true(writable instanceof WritableStream, "node.patchSelf() returns a writable stream"); + const response = new Response("Content", {headers: {"Content-Type": "text/html"}}); + window.script_executed = false; + const did_write_promise = writable.getWriter().write(` + <br id=before> + <script> + assert_not_equals(document.querySelector("#before"), null); + assert_equals(document.querySelector("#after"), null); + window.script_executed = true; + <` + `/script> + <br id=after>`); + assert_false(window.script_executed, "script should not execute before write() resolves"); + await did_write_promise; + assert_not_equals(document.querySelector("#before"), null); + assert_not_equals(document.querySelector("#after"), null); + assert_true(window.script_executed, "script should execute immediately upon being written"); +}, "Patches should execute scripts as soon as they are written"); + +</script> +\ No newline at end of file diff --git a/testing/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting-nested.html b/testing/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting-nested.html @@ -0,0 +1,20 @@ +<!DOCTYPE HTML> +<meta charset="utf-8" /> +<title>HTML partial updates - a script inside a template inside a patch should not execute</title> +<link rel=help href="https://github.com/WICG/declarative-partial-updates"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<section id="placeholder"> + <script> + window.state = "init"; + </script> +</section> +<template patchfor="placeholder"><template><script>window.state = 'patched';</script></template></template> +<script> +test(() => { + assert_not_equals(document.querySelector("#placeholder").firstElementChild, null); + assert_equals(window.state, "init"); +}); + +</script> +\ No newline at end of file diff --git a/testing/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting.html b/testing/web-platform/tests/html/dom/partial-updates/tentative/template-patchfor-scripting.html @@ -0,0 +1,21 @@ +<!DOCTYPE HTML> +<meta charset="utf-8" /> +<title>HTML partial updates - a script inside a patch should execute</title> +<link rel=help href="https://github.com/WICG/declarative-partial-updates"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<section id="placeholder"> + <script> + window.state = "init"; + </script> +</section> +<template patchfor="placeholder"><script>window.state = 'patched';</script></template> +<script> +test(() => { + assert_not_equals(document.querySelector("#placeholder").firstElementChild, null); + assert_equals(document.querySelector("#placeholder").firstElementChild.textContent, "window.state = 'patched';"); + assert_equals(window.state, "patched"); +}); + +</script> +\ No newline at end of file