e8d11cf92bf7719446822502c3fbc0c11ffa18da
[WebKit-https.git] / LayoutTests / fast / animation / request-animation-frame-throttle-subframe-display-none.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../resources/js-test-pre.js"></script>
5 <script>
6 description("Tests that requestAnimationFrame is throttled in subframes that are display:none");
7 window.jsTestIsAsync = true;
8
9 function checkSubframeThrottled()
10 {
11     shouldBeTrue("testFrame.contentWindow.internals.isRequestAnimationFrameThrottled()");
12
13     debug("Show subframe again");
14     evalAndLog("testFrame.style.display = 'block';");
15
16     shouldBecomeEqual("testFrame.contentWindow.internals.isRequestAnimationFrameThrottled()", "false", finishJSTest);
17 }
18
19 function hideFrame()
20 {
21     shouldBeFalse("testFrame.contentWindow.internals.isRequestAnimationFrameThrottled()");
22
23     debug("Hiding subframe.");
24     evalAndLog("testFrame.style.display = 'none';");
25
26     shouldBecomeEqual("testFrame.contentWindow.internals.isRequestAnimationFrameThrottled()", "true", checkSubframeThrottled);
27 }
28
29 function runTest()
30 {
31     testFrame = document.getElementById("testFrame");
32     debug("Frame is initially visibile so requestAnimationFrame should not be throttled");
33     shouldBecomeEqual("testFrame.contentWindow.internals.isRequestAnimationFrameThrottled()", "false", hideFrame);
34 }
35
36 var i = 0;
37 requestAnimationFrame(function() {
38     i++;
39 });
40 </script>
41 <iframe id="testFrame" src="resources/requestAnimationFrame-frame.html" onload="runTest()"></iframe>
42 <script src="../../resources/js-test-post.js"></script>
43 </body>
44 </html>