<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
#frame {
position: absolute;
top: -1000px;
}
</style>
<script>
function on_subframe_load() {
// Check how many animation frames have been served to the frame after 1
// second.
setTimeout(() => {
var frame = document.querySelector('#frame');
frame.contentWindow.postMessage(null, '*');
}, 1000);
}
</script>
<iframe
id="frame"
sandbox="allow-scripts"
src="resources/raf-throttling-frame.html"
onload="on_subframe_load()"></iframe>
<script>
if (window.testRunner)
testRunner.dumpAsText();
let throttlingTest = async_test("Test requestAnimationFrame() throttling in out-of-view cross origin frames");
addEventListener('message', (e) => {
let rafCount = e.data;
// TODO(skyostil): Chrome always runs one animation frame while the layout
// test harness does none. Find out where the difference is coming from.
// Note: this test has been changed to count RAFs from the start of the
// subframe's load event, which may change things. This change was necessitary
// to support being able to put sandboxed iframes in a separate process.
throttlingTest.step(() => {
assert_less_than_equal(rafCount, 1, "requestAnimationFrame() callback count")
});
throttlingTest.done();
});
</script>