Background: I'm doing some user interface tests that need to detect if people are paying attention or not. But, this question is not about the page visibility API.
Specifically, I would like to know how my Javascript code will be affected if the current tab is not active, or the browser window is not active, in different browsers. I've dug up the following so far:
- ios 5 pauses javascript when tab is not active
setInterval
andsetTimeout
delay is reduced when tabs are not active - seems like this just started appearing recently and can mess up Jasmine unit tests, around other things.requestAnimationFrame
is slowed when tab is not active (reasonable, can't think of why this would affect anyone too much)
I have the following questions:
- Other than mobile browsers, do desktop browsers ever pause JS execution when a tab is not active? When and which browsers?
- Which browsers reduce the
setInterval
repeat? Is it just reduced to a limit or by a percentage? For example, if I have a 10ms repeat versus a 5000ms repeat, how will each be affected? - Do these changes happen if the window is out of focus, as opposed to just the tab? (I imagine it would be harder to detect, as it requires the OS API.)
- Are there any other effects that would not be observed in an active tab? Could they mess things up that would otherwise execute correctly (i.e. the aforementioned Jasmine tests)?