| <html><!-- webkit-test-runner [ HiddenPageDOMTimerThrottlingEnabled=true ] --> |
| <body> |
| <script src="../../resources/js-test.js"></script> |
| <script> |
| description('Tests that DOM timers gets throttled on hidden pages once they reach the max nesting level'); |
| jsTestIsAsync = true; |
| |
| let timerCount = 0; |
| const timeoutInterval = 10; |
| const maxNestingLevel = 5; |
| let timerHandle = 0; |
| |
| function testTimer() |
| { |
| ++timerCount; |
| |
| timerHandle = setTimeout(testTimer, timeoutInterval); |
| if (timerCount >= maxNestingLevel) { |
| shouldBeTrue("internals.isTimerThrottled(timerHandle)"); |
| testRunner.resetPageVisibility(); |
| clearTimeout(timerHandle); |
| finishJSTest(); |
| return; |
| } else |
| shouldBeFalse("internals.isTimerThrottled(timerHandle)"); |
| } |
| |
| function runTest() |
| { |
| if (!window.testRunner) { |
| debug('This test requires testRunner'); |
| return; |
| } |
| |
| timerHandle = setTimeout(testTimer, timeoutInterval); |
| shouldBeFalse("internals.isTimerThrottled(timerHandle)"); |
| } |
| onload = function() { |
| document.onvisibilitychange = () => { |
| if (!document.hidden) |
| return; |
| document.onvisibilitychange = null; |
| runTest(); |
| }; |
| testRunner.setPageVisibility("hidden"); |
| }; |
| </script> |
| </body> |
| </html> |