blob: 0a5c1f5fb23b1135ad6f0b5660ac14850f26677c [file] [log] [blame]
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: waitUntil allows animation manipulation</title>
<link rel="help" href="https://www.w3.org/TR/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="view-transition-waituntil-animation-manipulation-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
:root { view-transition-name: none }
#target {
width: 100px;
height: 100px;
background: green;
view-transition-name: target;
}
#target.after {
background: red;
}
::view-transition { background: lightpink; }
::view-transition-group(*) {
animation-duration: 1ms;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
failIfNot(ViewTransition.prototype.waitUntil, "ViewTransition.waitUntil is not available");
async function runTest() {
const transition = document.startViewTransition(() => target.classList.add("after"));
transition.waitUntil(new Promise(() => {}));
transition.ready.then(async () => {
// Let the animation run to the end.
const animations = document.getAnimations();
animations.forEach(a => {
a.currentTime = 1;
});
// Wait a few frames.
await new Promise(requestAnimationFrame);
await new Promise(requestAnimationFrame);
await new Promise(requestAnimationFrame);
// Now, rewind the animation and take a screenshot.
requestAnimationFrame(() => {
animations.forEach(a => {
a.play();
a.pause();
a.currentTime = 0;
});
takeScreenshot();
});
});
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>