|
Line 0
a/LayoutTests/fast/dom/timer-throttle-on-scrolling-iframe-away.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 2 |
<body> |
| 3 |
<script src="../../resources/js-test-pre.js"></script> |
| 4 |
<script> |
| 5 |
description("Tests that a repeating timer in an iframe changing the style of an element gets throttled when scrolling the frame out of view."); |
| 6 |
jsTestIsAsync = true; |
| 7 |
|
| 8 |
function scrollFrameOutOfView() |
| 9 |
{ |
| 10 |
debug("Scrolling frame out of view."); |
| 11 |
window.scrollBy(0,800); |
| 12 |
} |
| 13 |
|
| 14 |
function timerFired(iterationCount, isThrottled) { |
| 15 |
// 5 iterations should suffice to throttle the timer. |
| 16 |
if (iterationCount == 5) { |
| 17 |
debug("Frame is inside viewport, timer should not be throttled"); |
| 18 |
isTimerThrottledBeforeScroll = isThrottled; |
| 19 |
shouldBeFalse("isTimerThrottledBeforeScroll"); |
| 20 |
scrollFrameOutOfView(); |
| 21 |
} else if (iterationCount == 7) { |
| 22 |
debug("Frame is outside viewport, timer should now be throttled"); |
| 23 |
isTimerThrottledAfterScroll = isThrottled; |
| 24 |
shouldBeTrue("isTimerThrottledAfterScroll"); |
| 25 |
finishJSTest(); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
</script> |
| 30 |
<div style="position: relative; width: 1600px; height: 2400px; background-color: green;"> |
| 31 |
<iframe id="testFrame" src="resources/timer-throttling-iframe.html" style="width: 100px; height: 100px;"></iframe> |
| 32 |
</div> |
| 33 |
<script src="../../resources/js-test-post.js"></script> |
| 34 |
</body> |