jquery/jquery — pull request #1299 by orkel (2013-06-27 11:04:36+00:00)
Title: Fix test for #13937 ticket

Did you notice test for #13937 being unstable (http://swarm.jquery.org/result/394435) in FF? That test sometimes fails, reporting that some animations are still running. Did you wander why?

When jQuery#finish called, it creates new animation in order to lead all queued animations to end CSS values, those animations than gets removed from jQuery.timers array from jQuery.fx.tick method, which is called every 13ms.

QUnit method start (which is used in #13937 test) uses setTimeout method in order to "...avoid any current callbacks".

So basically it's look like this –

```js
setInterval(function() {
// clear jQuery.timers
}, 13 );

setTimeout(function() {
// check jQuery.timers
// and this is sometimes jQuery.timers.length === 1, which is wrong
}, 13 )
```

This is all happens because sometimes FF executes setInterval function later than setTimeout function, even if timeout that passed to setTimeout function is much bigger than the one that passed to setInterval function.

It always happens if tab that executes that code, is not in focus, but it sometimes happens even when tab in "focus". Which is illustrated in this example. Go to the page in FF, than immediately move focus to another tab, wait a bit, then go back and look at the console.

/cc @gibson042