var _config = { fixture: null, Test: [], stats: { all: 0, bad: 0 }, queue: [], blocking: true, timeout: null, expected: null, currentModule: null, asyncTimeout: 2 // seconds for async timeout }; $(function() { $('#userAgent').html(navigator.userAgent); runTest(); }); function synchronize(callback) { _config.queue[_config.queue.length] = callback; if(!_config.blocking) { process(); } } function process() { while(_config.queue.length && !_config.blocking) { var call = _config.queue[0]; _config.queue = _config.queue.slice(1); call(); } } function stop() { _config.blocking = true; _config.timeout = setTimeout(start, _config.asyncTimeout * 1000); } function start() { if(_config.timeout) clearTimeout(_config.timeout); _config.blocking = false; process(); } function runTest() { _config.blocking = false; var time = new Date(); _config.fixture = document.getElementById('main').innerHTML; synchronize(function() { time = new Date() - time; $("
").html(['

Tests completed in ', time, ' milliseconds.
', _config.stats.bad, ' tests of ', _config.stats.all, ' failed.

'] .join('')) .appendTo("body"); $("