commit 7156d0685138b6c9c8869b730a5871352dbcad47
parent d963d4845fe6bbe740201859e630004b470a155f
Author: Scott Haseley <shaseley@chromium.org>
Date: Mon, 17 Nov 2025 21:50:15 +0000
Bug 2000520 [wpt PR 56045] - TaskAttribution: Propagate through EventTarget::EnqueueEvent(), a=testonly
Automatic update from web-platform-tests
TaskAttribution: Propagate through EventTarget::EnqueueEvent()
EventTarget::EnqueueEvent() is used for some events to dispatch the
event asynchronously in a new task. This can be used during API calls,
e.g. HTMLMediaElement.addTextTrack(), or from misc spec algorithms, e.g.
queuing the hashchange event during a same-document navigation -- which
is a case that needs to be instrumented to support soft navigation
detection. In either case, we should propagate the current context to
match causal/disptach propagation semantics.
Fixed: 459949678
Change-Id: I94d48dd970876242c4825856c5f1613ca7412fa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7158664
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1545312}
--
wpt-commits: 03be634c471d3d441c7291cea9dcc940c53a15ba
wpt-pr: 56045
Diffstat:
1 file changed, 36 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/soft-navigation-heuristics/smoke/tentative/task-attribution-hash-change.html b/testing/web-platform/tests/soft-navigation-heuristics/smoke/tentative/task-attribution-hash-change.html
@@ -0,0 +1,36 @@
+<!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>
+
+<button id="navigateButton">Click here!</button>
+<div id="content"></div>
+
+<script>
+ promise_test(async t => {
+ navigateButton.addEventListener('click', () => {
+ window.location.hash = '#hash1';
+ }, {once: true});
+
+ window.addEventListener('hashchange', () => {
+ content.innerHTML = '<h1>Content</h1>'
+ }, {once: true});
+
+ const softNavPromise = SoftNavigationTestHelper.getPerformanceEntries(
+ /*type=*/'soft-navigation', /*min_num_entries=*/1);
+
+ if (test_driver) {
+ test_driver.click(navigateButton);
+ }
+
+ const helper = new SoftNavigationTestHelper(t);
+ const entries = await helper.withTimeoutMessage(
+ softNavPromise, 'Soft navigation entry never arrived.', 3000);
+ assert_equals(entries.length, 1, 'Expected exactly one soft navigation.');
+ assert_true(
+ entries[0].name.endsWith('#hash1'), 'Unexpected Soft Navigation URL.');
+ }, 'Soft Navigation Detection supports propagating through the hashchange event');
+</script>