Revision control

1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style>
5
6
#target {
7
width: 100px;
8
height: 100px;
9
background-color: black;
10
}
11
12
</style>
13
</head>
14
<body>
15
<script src="../resources/testharness.js"></script>
16
<script src="../resources/testharnessreport.js"></script>
17
<div id="target"></div>
18
19
<script>
20
21
function waitNFrames(numberOfFrames, continuation)
22
{
23
let elapsedFrames = 0;
24
(function rAFCallback() {
25
if (elapsedFrames++ >= numberOfFrames)
26
continuation();
27
else
28
requestAnimationFrame(rAFCallback);
29
})();
30
}
31
32
async_test(t => {
33
const target = document.getElementById("target");
34
target.animate({ transform: ["translateX(100px)", "none"] }, 1000 * 1000);
35
36
waitNFrames(3, () => {
37
const initialAnimations = internals.acceleratedAnimationsForElement(target);
38
assert_equals(initialAnimations.length, 1, "There should be a single accelerated animation before suspension.");
39
assert_object_equals(initialAnimations[0], { property: "transform", speed: 1 },
40
'The single accelerated animation before suspension should be running and targeting the "transform" property.');
41
42
internals.suspendAnimations();
43
44
waitNFrames(2, () => {
45
const suspendedAnimations = internals.acceleratedAnimationsForElement(target);
46
assert_equals(suspendedAnimations.length, 1, "There should be a single accelerated animation after suspension.");
47
assert_object_equals(suspendedAnimations[0], { property: "transform", speed: 0 },
48
'The single accelerated animation after suspension should be paused and targeting the "transform" property.');
49
internals.resumeAnimations();
50
setTimeout(() => t.done());
51
});
52
});
53
}, "Suspending animations should pause running accelerated animations.");
54
55
</script>
56
</body>
57
</html>