$(function() {
$('#userAgent').html(navigator.userAgent);
- runTest();
+ if($.browser.safari)
+ $("h1").append(" - Disabled for Safari");
+ else
+ runTest();
});
function synchronize(callback) {
}
}
-function stop() {
+function stop(allowFailure) {
_config.blocking = true;
- _config.timeout = setTimeout(start, _config.asyncTimeout * 1000);
+ var handler = allowFailure ? start : function() {
+ ok( false, "Test timed out" );
+ start();
+ };
+ _config.timeout = setTimeout(handler, _config.asyncTimeout * 1000);
}
function start() {
if(_config.timeout)
_config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>']
.join(''))
.appendTo("body");
- $("<div id='banner'>").addClass(_config.stats.bad ? "fail" : "pass").insertAfter("h1");
+ $("#banner").addClass(_config.stats.bad ? "fail" : "pass");
});
}
-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 {
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" ] );
}
for ( var i = 0; i < f.length; i++ )
s += (s && ",") + '"' + f[i].id + '"';
isSet(f, q.apply(q,c), a + " (" + b + ")");
-}
\ No newline at end of file
+}
+
+/**
+ * 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);
+}
+
+/**
+ * Checks that the first two arguments are equal, with an optional message.
+ * Prints out both expected and actual values on failure.
+ *
+ * Prefered to ok( expected == actual, message )
+ *
+ * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
+ *
+ * @param Object expected
+ * @param Object actual
+ * @param String message (optional)
+ */
+function equals(expected, actual, message) {
+ var result = expected == actual;
+ message = message || result ? "okay" : "failed";
+ _config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] );
+}