X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=build%2Ftest%2Fdata%2Ftestrunner.js;h=0ff0ad50065266b9b5f2c6bfb019a69fb6562c5c;hb=b1e1d5d0c7c7eecee6e79f4530f4a7910641fd1c;hp=06d12cb291182ac7cdc54e16bf0639d2a3d00380;hpb=db621dd8ddf90259d4a170691fdd15574c2c011b;p=jquery.git diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 06d12cb..0ff0ad5 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -1,59 +1,73 @@ -var asyncTimeout = 2 // seconds for async timeout - -var fixture; -var Test; -var stats = { - all: 0, - bad: 0 +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 }; -var queue = []; -var blocking = false; -var timeout; + +$(function() { + $('#userAgent').html(navigator.userAgent); + runTest(); +}); function synchronize(callback) { - queue[queue.length] = callback; - if(!blocking) { + _config.queue[_config.queue.length] = callback; + if(!_config.blocking) { process(); } } function process() { - while(queue.length && !blocking) { - var call = queue[0]; - queue = queue.slice(1); + while(_config.queue.length && !_config.blocking) { + var call = _config.queue[0]; + _config.queue = _config.queue.slice(1); call(); } } -function stop() { - blocking = true; - timeout = setTimeout(start, asyncTimeout * 1000); +function stop(allowFailure) { + _config.blocking = true; + var handler = allowFailure ? start : function() { + ok( false, "Test timed out" ); + start(); + }; + _config.timeout = setTimeout(handler, _config.asyncTimeout * 1000); } function start() { - if(timeout) - clearTimeout(timeout); - blocking = false; + if(_config.timeout) + clearTimeout(_config.timeout); + _config.blocking = false; process(); } -function runTest(tests) { - var startTime = new Date(); - fixture = document.getElementById('main').innerHTML; - tests(); +function runTest() { + _config.blocking = false; + var time = new Date(); + _config.fixture = document.getElementById('main').innerHTML; synchronize(function() { - var runTime = new Date() - startTime; - var result = document.createElement("div"); - result.innerHTML = ['
Tests completed in ',
- runTime, ' milliseconds.
',
- stats.bad, ' tests of ', stats.all, ' failed.