0

[soft navs] Tweaks to WPT task-attribution.html

This is in preparation for
https://chromium-review.googlesource.com/c/chromium/src/+/6542137

- setTimeoutForUrlUpdate was never wired up and no more useful.
- withSchedulerYield: swap order of url and ui update.

Change-Id: I85e8e13574e95de2aa22cf8216aa15996be4aa41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6580641
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1464567}
This commit is contained in:
Johannes Henkel
2025-05-22 22:28:07 -07:00
committed by Chromium LUCI CQ
parent 4deaee7946
commit a53675a266

@ -62,16 +62,6 @@
history.pushState({}, "", "/set-timeout-and-sync-url-update");
}
// A soft navigation where the click handler synchronously updates its UI
// and schedules the URL update with a setTimeout.
// https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout
function setTimeoutForUrlUpdate() {
updateUI();
setTimeout(() => {
history.pushState({}, "", "/set-timeout-for-url-update");
}, 10);
}
// A soft navigation where the click handler schedules its work with
// scheduler.postTask.
// https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask
@ -83,11 +73,11 @@
}
// A soft navigation where the click handler yields
// (using scheduler.yield) between UI update and URL update.
// (using scheduler.yield) between URL and UI update.
async function withSchedulerYield() {
updateUI();
await scheduler.yield();
history.pushState({}, "", "/with-scheduler-yield");
await scheduler.yield();
updateUI();
}
// A soft navigation where the click handler schedules its work with
@ -109,7 +99,6 @@
<div id="set-timeout-and-sync-url-update" onclick="setTimeoutAndSyncUrlUpdate()">
Click here!
</div>
<div id="set-timeout-for-url-update" onclick="setTimeoutForUrlUpdate()">Click here!</div>
<div id="with-scheduler-post-task" onclick="withSchedulerPostTask()">Click here!</div>
<div id="with-scheduler-yield" onclick="withSchedulerYield()">Click here!</div>
<div id="with-request-animation-frame" onclick="withRequestAnimationFrame()">Click here!</div>