[Experiment] Implement code to detect high frequency painting
[WebKit-https.git] / LayoutTests / fast / block / block-move-frequent-paint.html
1 <html>
2 <head>
3 <script src="../../resources/js-test-pre.js"></script>
4 <script>
5 var counter = 0
6 var square
7 var debugFudge = 200;
8
9 function runTest(timestamp)
10 {
11     square = document.getElementById('square');
12     
13     if (counter == 0 && window.internals)
14         shouldBe("window.internals.isPaintingFrequently(square)", "false");
15     
16     var oldLeft = square.offsetLeft;
17     var oldTop = square.offsetTop;
18     square.style.left = (oldLeft + 1) + 'px';
19     square.style.top = (oldTop + 1) + 'px';
20     
21     counter++;
22     if (window.testRunner) {
23         // For debug builds that can't animate fast we just do a large number of increments.
24         for (var i = 0; i < debugFudge; ++i)
25             window.internals.incrementFrequentPaintCounter(square);
26     }
27
28     if (counter < 60)
29         requestAnimationFrame(runTest);
30     else if (window.internals) {
31         shouldBe("window.internals.isPaintingFrequently(square)", "true");
32         finishJSTest();
33     }
34 }
35
36 </script>
37 <body>
38 <div style="position:absolute; left:0;top:0">
39
40 <div style="position:absolute; left:0;top:0;width:2px; height:2px; background-color:green" id="square"></div>
41 </div>
42
43 <script>
44 description("This tests that we kick into high frequency painting mode properly when animating something quickly.");
45 window.jsTestIsAsync = true;
46 window.requestAnimationFrame(runTest);
47 </script>
48 <script src="../../resources/js-test-post.js"></script>
49 \13