tor-browser

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

commit 89367db5a3f0388f28a250681b575c8dfbba4602
parent 4afff5c59b6107facb9e91fde3ad65b0c5c42ccc
Author: Scott Haseley <shaseley@chromium.org>
Date:   Tue, 16 Dec 2025 08:46:04 +0000

Bug 2005367 [wpt PR 56666] - [soft navs] Attribute direct text node modifications, a=testonly

Automatic update from web-platform-tests
[soft navs] Attribute direct text node modifications

DOM TextNodes can be directly modified by script using .nodeValue or
.data, and such changes aren't attributed by soft nav detection.
Changing an <input> element's value attribute, which can also change
visible text, also escapes detection. This CL fixes these detection
issues by notifying SoftNavigationHeuristics about these modifications,
and marking the appropriate container as modified in the paint tracking
layer.

Fixed: 467713998
Change-Id: Iceacdbe9404a3528a6b61fd081207c0719769ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7248299
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Johannes Henkel <johannes@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1557493}

--

wpt-commits: 772172e38414d4e9cc1d8f8009438da1ef2e28f3
wpt-pr: 56666

Diffstat:
Atesting/web-platform/tests/soft-navigation-heuristics/detection/tentative/text-node-modifications.html | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/soft-navigation-heuristics/detection/tentative/text-node-modifications.html b/testing/web-platform/tests/soft-navigation-heuristics/detection/tentative/text-node-modifications.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/soft-navigation-heuristics/resources/soft-navigation-test-helper.js"></script> + +<div id="divTarget">Initial Text</div> +<div><input type="button" value="Initial Input Text" id="inputTarget" style="width: 300px"></input></div> +<div><button id="navigateButton">Navigate!</button></div> + +<script> + const textNode = divTarget.childNodes[0]; + + async function runTest(t, url, modifyText, targetId) { + navigateButton.addEventListener('click', () => { + modifyText(); + history.pushState({}, '', url); + }, {once: true}); + + // Set up the PerformanceObservers before clicking to avoid races. + const softNavPromise = + SoftNavigationTestHelper.getPerformanceEntries('soft-navigation'); + const icpPromise = + SoftNavigationTestHelper.getPerformanceEntries('interaction-contentful-paint'); + + if (test_driver) { + test_driver.click(navigateButton); + } + + const helper = new SoftNavigationTestHelper(t); + + const softNavs = await helper.withTimeoutMessage( + softNavPromise, 'Soft navigation not detected.', /*timeout=*/ 3000); + assert_equals(softNavs.length, 1, 'Expected exactly one soft navigation.'); + assert_true( + softNavs[0].name.endsWith(url), + `Unexpected Soft Navigation URL. Expected url to end with ${url} but got ${softNavs[0].name}`); + + const icps = await helper.withTimeoutMessage( + icpPromise, 'ICP not detected.', /*timeout=*/ 3000); + assert_equals(icps.length, 1, 'Expected exactly one ICP entry.'); + assert_equals(icps[0].id, targetId, `Expected ICP candidate to be "${targetId}"`); + } + + promise_test(t => { + const url = '/nodeValue'; + const modifyText = () => { + textNode.nodeValue = "New text set via .nodeValue"; + }; + return runTest(t, url, modifyText, 'divTarget'); + }, 'Soft Navigation Detection supports replacing node text via .nodeValue'); + + promise_test(t => { + const url = '/data'; + const modifyText = () => { + textNode.data= 'New text set via .data'; + }; + return runTest(t, url, modifyText, 'divTarget'); + }, 'Soft Navigation Detection supports replacing node text via .data'); + + promise_test(t => { + const url = '/textContent'; + const modifyText = () => { + textNode.textContent = 'New text set via .textContent'; + }; + return runTest(t, url, modifyText, 'divTarget'); + }, 'Soft Navigation Detection supports replacing node text via .textContent'); + + promise_test(t => { + const url = '/value'; + const modifyText = () => { + inputTarget.value = 'Input text set via .value'; + }; + return runTest(t, url, modifyText, 'inputTarget'); + }, 'Soft Navigation Detection supports replacing input text via .input'); + + promise_test(t => { + const url = '/value-attribute'; + const modifyText = () => { + inputTarget.setAttribute('value', 'Input text set via .value (attr)'); + }; + return runTest(t, url, modifyText, 'inputTarget'); + }, 'Soft Navigation Detection supports replacing input text via setAttribute(value)'); +</script>