ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
});
-var foobar;
-
test("jQuery.ajax - dataType html", function() {
expect(5);
stop();
- foobar = null;
- testFoo = undefined;
+ window.foobar = null;
+ window.testFoo = undefined;
var verifyEvaluation = function() {
- equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
- equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
- start();
+ equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
+ equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
+
+ // Cleanup the global namespace
+ delete window.foobar;
+ delete window.testFoo;
+
+ start();
};
jQuery.ajax({
var target = "data/name.html";
var successCount = 0;
var errorCount = 0;
- var errorEx = "";
+ var errorEx = "";
var success = function() {
successCount++;
};
jQuery("#foo").ajaxError(function (e, xml, s, ex) {
errorCount++;
- errorEx += ": " + xml.status;
+ errorEx += ": " + xml.status;
});
jQuery("#foo").one('ajaxStop', function () {
equals(successCount, 5, "Check all ajax calls successful");
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
jQuery("#foo").unbind('ajaxError');
+
+ delete window.foobar;
start();
});
test("load(String, Function) - check scripts", function() {
expect(7);
stop();
+
window.testFoo = undefined;
window.foobar = null;
+
var verifyEvaluation = function() {
equals( foobar, "bar", 'Check if script src was evaluated after load' );
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
- start();
+
+ // Cleanup the global namespace
+ delete window.foobar;
+ delete window.testFoo;
+
+ start();
};
jQuery('#first').load(url('data/test.html'), function() {
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
test("load(String, Function) - check file with only a script tag", function() {
expect(3);
stop();
- testFoo = undefined;
+ window.testFoo = undefined;
jQuery('#first').load(url('data/test2.html'), function() {
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
+
+ // Cleanup the global namespace
+ delete window.testFoo;
start();
});
});
window.foobar = null;
jQuery.getScript(url("data/test.js"), function() {
equals( foobar, "bar", 'Check if script was evaluated' );
+ delete window.foobar;
setTimeout(start, 100);
});
});
test("jQuery.getScript(String, Function) - no callback", function() {
expect(1);
stop();
- jQuery.getScript(url("data/test.js"), start);
+ jQuery.getScript(url("data/test.js"), function(){
+ delete window.foobar;
+ start();
+ });
});
test("jQuery.ajax() - JSONP, Local", function() {
dataType: "script",
success: function(data){
ok( foobar, "Script results returned (GET, no callback)" );
+ delete window.foobar;
start();
}
});
success: function(data, status){
ok( foobar, "Script results returned (GET, no callback)" );
equals( status, "success", "Script results returned (GET, no callback)" );
+ delete window.foobar;
start();
}
});
dataType: "script",
success: function(data){
ok( foobar, "Script results returned (GET, no callback)" );
+ delete window.foobar;
start();
}
});
jQuery.ajax();
});
+/*
test("custom timeout does not set error message when timeout occurs, see #970", function() {
stop();
jQuery.ajax({
- url: "data/name.php?wait=10",
+ url: "data/name.php?wait=1",
timeout: 500,
error: function(request, status) {
ok( status != null, "status shouldn't be null in error handler" );
}
});
});
+*/
test("data option: evaluate function values (#2806)", function() {
stop();