archives

« Bugzilla Issues Index

#110 — Tests stop or slow down when tab is in background on Firefox 5 and Chrome 11


I'm currently running the tests, on Firefox 5. When the tab is active, CPU goes up to 50% (I have two cores). When I switch tabs, CPU goes down. Up back when I switch back to the test tab. Same behavior on Chrome 11.

I think that this is due to the recent change on Firefox 5.
On https://developer.mozilla.org/en/DOM/window.setTimeout, it can be read that "timeouts are clamped to firing no more often than once per second (1000ms) in inactive tabs".
And indeed, the test loader uses setTimeout: http://hg.ecmascript.org/tests/test262/file/0e72e08e46b1/test/harness/sth.js#l293
By the way, is there a reason why 10 is the setTimeout value?

Modern browsers can implement the equivalent of a 0sec timeout using postMessage (http://caniuse.com/#feat=x-doc-messaging):
http://dbaron.org/log/20100309-faster-timeouts
http://www.nonblocking.io/2011/06/windownexttick.html

Based on http://jsperf.com/postmessage :
var nextTick = (function() {
return function(cb) {
window.onmessage = cb;
window.postMessage('', '*');
};
})();


As a short term workaround, tabs can be extracted both on Firefox and Chrome to become independent windows. Leaving the test suite tab being the active tab of this new window make tests run fast.