Revision control

1
<div id="target" style="width: 100px; height: 100px; background-color: black;"></div>
2
<script src="../resources/js-test.js"></script>
3
<script>
4
5
const element = document.getElementById("target");
6
const timing = { duration: 1000, iterations: Infinity };
7
8
const shouldBecomeEqualAsync = async (actual, expected) => new Promise(resolve => shouldBecomeEqual(actual, expected, resolve));
9
10
(async () => {
11
if (!window.testRunner || !window.internals) {
12
debug("This test should be run in a test runner.");
13
return;
14
}
15
16
testRunner.waitUntilDone();
17
18
// First, start a transform-related animation that can be accelerated.
19
element.animate({ scale: [1, 2] }, timing);
20
await shouldBecomeEqualAsync("internals.acceleratedAnimationsForElement(element).length", "1");
21
22
// Now, start another transform-related animation that can also be accelerated.
23
const rotationAnimation = element.animate({ rotate: ["30deg", "60deg"] }, timing);
24
await shouldBecomeEqualAsync("internals.acceleratedAnimationsForElement(element).length", "2");
25
26
// Now, update the last transform-related animation to a state that cannot be accelerated anymore
27
// due to using a steps() timing function. This should not only prevent this animation from
28
// running accelerated, but also make the first animation revert to a non-accelerated state.
29
rotationAnimation.effect.updateTiming({ easing: "steps(60)" });
30
await shouldBecomeEqualAsync("internals.acceleratedAnimationsForElement(element).length", "0");
31
32
testRunner.notifyDone();
33
})();
34
35
</script>