X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=build%2Ftest%2Fdata%2Ftestrunner.js;h=e73fd671d096d67d7dae09b57d9589066cd9b4b3;hb=c6a893b68001be9b9389de5e2c5ea58c1a28c742;hp=86a16d5c069da5d115625499d2f626dfe9ed1449;hpb=6b8ffe79f4e616d6179f6b16099e7c25e7ae5cb1;p=jquery.git diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js index 86a16d5..e73fd67 100644 --- a/build/test/data/testrunner.js +++ b/build/test/data/testrunner.js @@ -15,6 +15,8 @@ var _config = { $(function() { $('#userAgent').html(navigator.userAgent); + if($.browser.safari) + $("h1").append(" - Slowed down for Safari to prevent crashes"); runTest(); }); @@ -33,12 +35,13 @@ function process() { } } -function stop() { +function stop(allowFailure) { _config.blocking = true; - _config.timeout = setTimeout(function() { + var handler = allowFailure ? start : function() { ok( false, "Test timed out" ); start(); - }, _config.asyncTimeout * 1000); + }; + _config.timeout = setTimeout(handler, _config.asyncTimeout * 1000); } function start() { if(_config.timeout) @@ -62,9 +65,18 @@ function runTest() { }); } -function test(name, callback) { +function test(name, callback, nowait) { + // safari seems to have some memory problems, so we need to slow it down + if($.browser.safari && !nowait) { + test("", function() { + stop(); + setTimeout(start, 250); + }, true); + } + if(_config.currentModule) name = _config.currentModule + " module: " + name; + synchronize(function() { _config.Test = []; try { @@ -81,6 +93,9 @@ function test(name, callback) { synchronize(function() { reset(); + // don't output pause tests + if(nowait) return; + if(_config.expected && _config.expected != _config.Test.length) { _config.Test.push( [ false, "Expected " + _config.expected + " assertions, but " + _config.Test.length + " were run" ] ); } @@ -190,4 +205,17 @@ function t(a,b,c) { for ( var i = 0; i < f.length; i++ ) s += (s && ",") + '"' + f[i].id + '"'; isSet(f, q.apply(q,c), a + " (" + b + ")"); +} + +/** + * Add random number to url to stop IE from caching + * + * @example url("data/test.html") + * @result "data/test.html?10538358428943" + * + * @example url("data/test.php?foo=bar") + * @result "data/test.php?foo=bar&10538358345554" + */ +function url(value) { + return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); } \ No newline at end of file