<!DOCTYPE html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<div style="position: relative; width: 1600px; height: 2400px; background-color: green;">
  <div style="position:absolute; left: 600px; top: 800px;">
    <div id="testElement">TEST</div>
  </div>
</div>
<script>
description("Tests that a repeating timer changing the height of an element outside viewport does not get throttled.");
jsTestIsAsync = true;

var testElement = document.getElementById('testElement');
var iterationCount = 0;
var timeoutId;

function timerCallback()
{
  ++iterationCount;

  // Change the height of the element while it is outside viewport.
  testElement.style["height"] = "" + iterationCount;

  // 5 iterations should be sufficient to throttle the timer.
  if (iterationCount == 5) {
    // Do not use shouldBeTrue() because it would cause a DOM tree mutation
    // and unthrottle the timer.
    shouldBeFalse("internals.isTimerThrottled(timeoutId)");
    clearInterval(timeoutId);
    finishJSTest();
  }
}

timeoutId = setInterval(timerCallback, 10);
shouldBeFalse("internals.isTimerThrottled(timeoutId)");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
