65 lines
2.7 KiB
HTML
65 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<script>
|
|
description("Tests that requestAnimationFrame is throttled in subframes that are outside the viewport");
|
|
window.jsTestIsAsync = true;
|
|
|
|
if (window.internals)
|
|
internals.setOutsideViewportThrottlingEnabled(true);
|
|
|
|
function checkSubframesThrottled()
|
|
{
|
|
shouldBeEqualToString("testFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport");
|
|
shouldBeEqualToString("grandChildFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport");
|
|
|
|
finishJSTest();
|
|
}
|
|
|
|
function scrollFrameOutOfView()
|
|
{
|
|
debug("Scrolling frame out of view again.");
|
|
window.scroll(0, 0);
|
|
|
|
shouldBeEqualToString("internals.requestAnimationFrameThrottlingReasons()", "[Unthrottled]");
|
|
shouldBecomeEqualToString("testFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport", checkSubframesThrottled);
|
|
}
|
|
|
|
function scrollFrameIntoView()
|
|
{
|
|
shouldBeEqualToString("internals.requestAnimationFrameThrottlingReasons()", "[Unthrottled]");
|
|
shouldBeEqualToString("testFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport");
|
|
shouldBeEqualToString("grandChildFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport");
|
|
|
|
debug("Scrolling frame into view.");
|
|
window.internals.scrollElementToRect(testFrame, 0, 0, 300, 300);
|
|
|
|
debug("RequestAnimationFrame should no longer be throttled");
|
|
shouldBeEqualToString("internals.requestAnimationFrameThrottlingReasons()", "[Unthrottled]");
|
|
shouldBeEqualToString("grandChildFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "[Unthrottled]");
|
|
shouldBeEqualToString("testFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "[Unthrottled]");
|
|
|
|
scrollFrameOutOfView();
|
|
}
|
|
|
|
function runTest()
|
|
{
|
|
testFrame = document.getElementById("testFrame");
|
|
grandChildFrame = testFrame.contentDocument.getElementById("grandChildFrame");
|
|
debug("Frame is initially outside the viewport so requestAnimationFrame should be throttled");
|
|
shouldBecomeEqualToString("testFrame.contentWindow.internals.requestAnimationFrameThrottlingReasons()", "OutsideViewport", scrollFrameIntoView);
|
|
}
|
|
|
|
var i = 0;
|
|
requestAnimationFrame(function() {
|
|
i++;
|
|
});
|
|
</script>
|
|
<div style="position: relative; width: 1600px; height: 2400px; background-color: green;">
|
|
<iframe id="testFrame" src="resources/requestAnimationFrame-frame.html" style="position:absolute; left: 600px; top: 800px;" onload="runTest()"></iframe>
|
|
</div>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|