[Web Animations] Expose Web Animations CSS integration as an experimental feature
[WebKit-https.git] / LayoutTests / animations / animation-callback-timestamp.html
1 <!DOCTYPE HTML><!-- webkit-test-runner [ enableWebAnimationsCSSIntegration=true ] -->
2 <html>
3 <head>
4     <script src="../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7     <script>
8         var currentFrame = 0;
9         var failed = false;
10
11         function finishTest()
12         {
13             if (failed)
14                 testFailed("Some of the requestAnimationFrame() callback timestamps were larger than Performance.now() by more than 3ms.");
15             else
16                 testPassed("All the differences between requestAnimationFrame() callback timestamps and Performance.now() were within 3ms.")
17             finishJSTest();
18         }
19         
20         function doAnimation(timestamp)
21         {
22             const Tolerance = 3;
23             const WarmupFrames = 5;
24
25             var performanceNow = window.performance.now();
26             if (++currentFrame > WarmupFrames && Math.abs(timestamp - performanceNow) >= Tolerance) {
27                 debug("requestAnimationFrame() timestamp = " + timestamp + ", window.performance.now() = " + performanceNow);
28                 failed = true;
29             }
30
31             const MaxFrames = 25;
32             if (currentFrame == MaxFrames)
33                 finishTest();
34             else
35                 requestAnimationFrame(doAnimation);
36         }
37         
38         window.jsTestIsAsync = true;
39         requestAnimationFrame(doAnimation);
40     </script>
41     <script src="../resources/js-test-post.js"></script>
42 </body>
43 </html>