[Web Animations] DocumentTimeline::updateAnimations() is called endlessly
[WebKit-https.git] / LayoutTests / webanimations / accelerated-animation-interruption-display-none.html
1 <!DOCTYPE html><!-- webkit-test-runner [ experimental:WebAnimationsCSSIntegrationEnabled=true ] -->
2 <html>
3 <head>
4 <style>
5
6 #target {
7     width: 100px;
8     height: 100px;
9     background-color: black;
10     animation: foo linear 10s;
11 }
12
13 @keyframes foo {
14     from { transform: "translateX(100px)" };
15     to { transform: "none" };
16 }
17
18 </style>
19 </head>
20 <body>
21 <script src="../resources/testharness.js"></script>
22 <script src="../resources/testharnessreport.js"></script>
23 <div id="target"></div>
24
25 <script>
26
27 function waitNFrames(numberOfFrames, continuation)
28 {
29     let elapsedFrames = 0;
30     (function rAFCallback() {
31         if (elapsedFrames++ >= numberOfFrames)
32             continuation();
33         else
34             requestAnimationFrame(rAFCallback);
35     })();
36 }
37
38 async_test(t => {
39     const initialNumberOfTimelineInvalidations = internals.numberOfAnimationTimelineInvalidations();
40     waitNFrames(3, () => {
41         assert_greater_than(internals.numberOfAnimationTimelineInvalidations(), initialNumberOfTimelineInvalidations, "There should be updates made to the timeline as an animation is set up.");
42
43         document.getElementById("target").style.display = "none";
44
45         waitNFrames(2, () => {
46             const numberOfTimelineInvalidationsAfterInterruption = internals.numberOfAnimationTimelineInvalidations();
47             requestAnimationFrame(() => {
48                 assert_equals(internals.numberOfAnimationTimelineInvalidations(), numberOfTimelineInvalidationsAfterInterruption, "There should not be any updates made to the timeline after interrupting the single running animation.");
49                 t.done();
50             });
51         });
52     });
53 }, "Interrupting an animation by setting 'display: none' should stop invalidating the animation timeline.");
54
55 </script>
56 </body>
57 </html>