Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / timer-throttling-background-page-near-alignment-interval.html
blobb45abd6cdafa366f1df230d43aa1c84101c0bc0c
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <script>
5 description('<a href="http://crbug.com/259680">Bug 259680</a>: JavaScript setInterval lagging behind');
7 var jsTestIsAsync = true;
8 var intervalDuration = 1000;
9 var testDuration = 4000;
10 var expectedNumFires = 4;
11 var numFires = 0;
12 var tolerance = 1;
14 var intervalID;
15 var startTime;
17 function timerFired()
19 ++numFires;
21 var currentTime = new Date().getTime();
22 if (currentTime >= startTime + testDuration) {
23 shouldBeCloseTo("numFires", expectedNumFires, tolerance);
25 clearInterval(intervalID);
26 finishJSTest();
27 return;
31 function runTest()
33 if (!window.testRunner) {
34 debug('This test requires testRunner');
35 return;
38 testRunner.dumpAsText();
40 testRunner.setPageVisibility("hidden");
41 startTime = new Date().getTime();
42 intervalID = window.setInterval(timerFired, intervalDuration);
44 </script>
45 </head>
46 <body onload="runTest()">
47 <p>
48 This test ensures that intervals on background pages whose duration is close to the timer alignment interval don't miss every other firing.
49 </p>
50 </body>
51 </html>