3 <script src=
"../../resources/js-test.js"></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;
21 var currentTime
= new Date().getTime();
22 if (currentTime
>= startTime
+ testDuration
) {
23 shouldBeCloseTo("numFires", expectedNumFires
, tolerance
);
25 clearInterval(intervalID
);
33 if (!window
.testRunner
) {
34 debug('This test requires testRunner');
38 testRunner
.dumpAsText();
40 testRunner
.setPageVisibility("hidden");
41 startTime
= new Date().getTime();
42 intervalID
= window
.setInterval(timerFired
, intervalDuration
);
46 <body onload=
"runTest()">
48 This test ensures that intervals on background pages whose duration is close to the timer alignment interval don't miss every other firing.