mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fixing style for test unit ajax.js. https://github.com/jquery/2012-dev-summit/issues/56
This commit is contained in:
parent
f3323901f9
commit
be1f1d7b5b
@ -1,4 +1,6 @@
|
|||||||
module("ajax", { teardown: moduleTeardown });
|
module( "ajax", {
|
||||||
|
teardown: moduleTeardown
|
||||||
|
});
|
||||||
|
|
||||||
if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
|
if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
|
||||||
|
|
||||||
@ -7,7 +9,9 @@ var isOpera = !!window.opera;
|
|||||||
test( "jQuery.ajax() - success callbacks", function() {
|
test( "jQuery.ajax() - success callbacks", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -28,17 +32,27 @@ test("jQuery.ajax() - success callbacks", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
success: function(){ ok(true, "success"); },
|
ok( true, "beforeSend" );
|
||||||
error: function(){ ok(false, "error"); },
|
},
|
||||||
complete: function(){ ok(true, "complete"); }
|
success: function() {
|
||||||
|
ok( true, "success" );
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
ok( true, "complete");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajax() - success callbacks - (url, options) syntax", function() {
|
test( "jQuery.ajax() - success callbacks - (url, options) syntax", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -59,10 +73,18 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jQuery.ajax( url("data/name.html"), {
|
jQuery.ajax( url("data/name.html"), {
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
success: function(){ ok(true, "success"); },
|
ok( true, "beforeSend" );
|
||||||
error: function(){ ok(false, "error"); },
|
},
|
||||||
complete: function(){ ok(true, "complete"); }
|
success: function() {
|
||||||
|
ok( true, "success" );
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
ok( true, "complete" );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 13 );
|
}, 13 );
|
||||||
});
|
});
|
||||||
@ -70,7 +92,9 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
|
|||||||
test( "jQuery.ajax() - success callbacks (late binding)", function() {
|
test( "jQuery.ajax() - success callbacks (late binding)", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -92,18 +116,25 @@ test("jQuery.ajax() - success callbacks (late binding)", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); }
|
beforeSend: function() {
|
||||||
})
|
ok( true, "beforeSend" );
|
||||||
.complete(function(){ ok(true, "complete"); })
|
}
|
||||||
.success(function(){ ok(true, "success"); })
|
}).complete(function() {
|
||||||
.error(function(){ ok(false, "error"); });
|
ok( true, "complete" );
|
||||||
|
}).success(function() {
|
||||||
|
ok( true, "success" );
|
||||||
|
}).error(function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
});
|
||||||
}, 13 );
|
}, 13 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajax() - success callbacks (oncomplete binding)", function() {
|
test( "jQuery.ajax() - success callbacks (oncomplete binding)", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -124,13 +155,19 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
|
ok( true, "beforeSend" );
|
||||||
|
},
|
||||||
complete: function( xhr ) {
|
complete: function( xhr ) {
|
||||||
xhr
|
xhr.complete(function() {
|
||||||
.complete(function(){ ok(true, "complete"); })
|
ok( true, "complete" );
|
||||||
.success(function(){ ok(true, "success"); })
|
}).success(function() {
|
||||||
.error(function(){ ok(false, "error"); })
|
ok( true, "success" );
|
||||||
.complete(function(){ start(); });
|
}).error(function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
}).complete(function() {
|
||||||
|
start();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 13 );
|
}, 13 );
|
||||||
@ -139,7 +176,9 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
|
|||||||
test( "jQuery.ajax() - success callbacks (very late binding)", function() {
|
test( "jQuery.ajax() - success callbacks (very late binding)", function() {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -160,14 +199,20 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
|
ok(true, "beforeSend");
|
||||||
|
},
|
||||||
complete: function( xhr ) {
|
complete: function( xhr ) {
|
||||||
setTimeout (function() {
|
setTimeout (function() {
|
||||||
xhr
|
xhr.complete(function() {
|
||||||
.complete(function(){ ok(true, "complete"); })
|
ok( true, "complete" );
|
||||||
.success(function(){ ok(true, "success"); })
|
}).success(function() {
|
||||||
.error(function(){ ok(false, "error"); })
|
ok( true, "success" );
|
||||||
.complete(function(){ start(); });
|
}).error(function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
}).complete(function() {
|
||||||
|
start();
|
||||||
|
});
|
||||||
}, 100 );
|
}, 100 );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -177,7 +222,9 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() {
|
|||||||
test( "jQuery.ajax() - success callbacks (order)", function() {
|
test( "jQuery.ajax() - success callbacks (order)", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -226,14 +273,24 @@ test("jQuery.ajax() - error callbacks", function() {
|
|||||||
ok( false, "ajaxSuccess" );
|
ok( false, "ajaxSuccess" );
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 500 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 500
|
||||||
|
});
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.php?wait=5"),
|
url: url("data/name.php?wait=5"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
success: function(){ ok(false, "success"); },
|
ok( true, "beforeSend" );
|
||||||
error: function(){ ok(true, "error"); },
|
},
|
||||||
complete: function(){ ok(true, "complete"); }
|
success: function() {
|
||||||
|
ok( false, "success" );
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
ok( true, "error" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
ok( true, "complete" );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -244,10 +301,22 @@ test( "jQuery.ajax - multiple method signatures introduced in 1.5 ( #8107)", fun
|
|||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.when(
|
jQuery.when(
|
||||||
jQuery.ajax().success(function() { ok( true, "With no arguments" ); }),
|
/* jQuery.when arguments start */
|
||||||
jQuery.ajax("data/name.html").success(function() { ok( true, "With only string URL argument" ); }),
|
jQuery.ajax().success(function() {
|
||||||
jQuery.ajax("data/name.html", {} ).success(function() { ok( true, "With string URL param and map" ); }),
|
ok( true, "With no arguments" );
|
||||||
jQuery.ajax({ url: "data/name.html"} ).success(function() { ok( true, "With only map" ); })
|
}),
|
||||||
|
jQuery.ajax("data/name.html").success(function() {
|
||||||
|
ok( true, "With only string URL argument" );
|
||||||
|
}),
|
||||||
|
jQuery.ajax( "data/name.html", {}).success(function() {
|
||||||
|
ok( true, "With string URL param and map" );
|
||||||
|
}),
|
||||||
|
jQuery.ajax({
|
||||||
|
url: "data/name.html"
|
||||||
|
}).success(function() {
|
||||||
|
ok( true, "With only map" );
|
||||||
|
})
|
||||||
|
/* jQuery.when arguments end */
|
||||||
).always(function() {
|
).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
@ -324,8 +393,8 @@ test(".ajax() - retry with jQuery.ajax( this )", function() {
|
|||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var firstTime = true,
|
var previousUrl,
|
||||||
previousUrl;
|
firstTime = true;
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/errorWithText.php"),
|
url: url("data/errorWithText.php"),
|
||||||
@ -337,7 +406,9 @@ test(".ajax() - retry with jQuery.ajax( this )", function() {
|
|||||||
ok ( true, "Test retrying with jQuery.ajax(this) works" );
|
ok ( true, "Test retrying with jQuery.ajax(this) works" );
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/errorWithText.php"),
|
url: url("data/errorWithText.php"),
|
||||||
data: { "x": 1 },
|
data: {
|
||||||
|
"x": 1
|
||||||
|
},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
if ( !previousUrl ) {
|
if ( !previousUrl ) {
|
||||||
previousUrl = this.url;
|
previousUrl = this.url;
|
||||||
@ -366,13 +437,13 @@ test(".ajax() - headers" , function() {
|
|||||||
xhr.setRequestHeader( "ajax-send", "test" );
|
xhr.setRequestHeader( "ajax-send", "test" );
|
||||||
});
|
});
|
||||||
|
|
||||||
var requestHeaders = {
|
var i,
|
||||||
|
requestHeaders = {
|
||||||
"siMPle": "value",
|
"siMPle": "value",
|
||||||
"SometHing-elsE": "other value",
|
"SometHing-elsE": "other value",
|
||||||
"OthEr": "something else"
|
"OthEr": "something else"
|
||||||
},
|
},
|
||||||
list = [],
|
list = [];
|
||||||
i;
|
|
||||||
|
|
||||||
for ( i in requestHeaders ) {
|
for ( i in requestHeaders ) {
|
||||||
list.push( i );
|
list.push( i );
|
||||||
@ -402,12 +473,12 @@ test(".ajax() - headers" , function() {
|
|||||||
}
|
}
|
||||||
strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" );
|
strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" );
|
||||||
},
|
},
|
||||||
error: function(){ ok(false, "error"); }
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
}
|
||||||
}).always(function() {
|
}).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test( ".ajax() - Accept header", function() {
|
test( ".ajax() - Accept header", function() {
|
||||||
@ -427,9 +498,10 @@ test(".ajax() - Accept header" , function() {
|
|||||||
strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" );
|
strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" );
|
||||||
start();
|
start();
|
||||||
},
|
},
|
||||||
error: function(){ ok(false, "error"); }
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test( ".ajax() - contentType", function() {
|
test( ".ajax() - contentType", function() {
|
||||||
@ -501,7 +573,9 @@ test(".ajax() - hash", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/name.html?abc#foo",
|
url: "data/name.html?abc#foo",
|
||||||
data: { "test": 123 },
|
data: {
|
||||||
|
"test": 123
|
||||||
|
},
|
||||||
beforeSend: function( xhr, settings ) {
|
beforeSend: function( xhr, settings ) {
|
||||||
equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." );
|
equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." );
|
||||||
return false;
|
return false;
|
||||||
@ -625,8 +699,12 @@ test("jQuery.ajax() - abort", function() {
|
|||||||
|
|
||||||
var xhr = jQuery.ajax({
|
var xhr = jQuery.ajax({
|
||||||
url: url("data/name.php?wait=5"),
|
url: url("data/name.php?wait=5"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
complete: function(){ ok(true, "complete"); }
|
ok( true, "beforeSend" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
ok( true, "complete" );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
equal( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
|
equal( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
|
||||||
@ -780,19 +858,29 @@ test("jQuery.ajax() - disabled globals", function() {
|
|||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
global: false,
|
global: false,
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function(){ ok(true, "beforeSend"); },
|
beforeSend: function() {
|
||||||
success: function(){ ok(true, "success"); },
|
ok( true, "beforeSend" );
|
||||||
error: function(){ ok(false, "error"); },
|
},
|
||||||
|
success: function() {
|
||||||
|
ok( true, "success" );
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
ok( true, "complete" );
|
ok( true, "complete" );
|
||||||
setTimeout(function(){ start(); }, 13);
|
setTimeout(function() {
|
||||||
|
start();
|
||||||
|
}, 13 );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
|
test( "jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/with_fries.xml"),
|
url: url("data/with_fries.xml"),
|
||||||
dataType: "xml",
|
dataType: "xml",
|
||||||
@ -837,7 +925,9 @@ test("jQuery.ajax - HEAD requests", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
data: { "whip_it": "good" },
|
data: {
|
||||||
|
"whip_it": "good"
|
||||||
|
},
|
||||||
type: "HEAD",
|
type: "HEAD",
|
||||||
success: function( data, status, xhr ) {
|
success: function( data, status, xhr ) {
|
||||||
var h = xhr.getAllResponseHeaders();
|
var h = xhr.getAllResponseHeaders();
|
||||||
@ -856,7 +946,9 @@ test("jQuery.ajax - beforeSend", function() {
|
|||||||
|
|
||||||
var check = false;
|
var check = false;
|
||||||
|
|
||||||
jQuery.ajaxSetup({ timeout: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
@ -872,6 +964,7 @@ test("jQuery.ajax - beforeSend", function() {
|
|||||||
|
|
||||||
test( "jQuery.ajax - beforeSend, cancel request (#2688)", function() {
|
test( "jQuery.ajax - beforeSend, cancel request (#2688)", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/name.html"),
|
url: url("data/name.html"),
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
@ -953,7 +1046,15 @@ test("synchronous request", function() {
|
|||||||
test( "synchronous request with callbacks", function() {
|
test( "synchronous request with callbacks", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
var result;
|
var result;
|
||||||
jQuery.ajax({url: url("data/json_obj.js"), async: false, dataType: "text", success: function(data) { ok(true, "sucess callback executed"); result = data; } });
|
jQuery.ajax({
|
||||||
|
url: url("data/json_obj.js"),
|
||||||
|
async: false,
|
||||||
|
dataType: "text",
|
||||||
|
success: function(data) {
|
||||||
|
ok( true, "sucess callback executed" );
|
||||||
|
result = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
ok( /^\{ "data"/.test( result ), "check returned text" );
|
ok( /^\{ "data"/.test( result ), "check returned text" );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -984,7 +1085,10 @@ test("pass-through request object", function() {
|
|||||||
ok( jQuery.post( url(target), success ), "post" );
|
ok( jQuery.post( url(target), success ), "post" );
|
||||||
ok( jQuery.getScript( url("data/test.js"), success ), "script" );
|
ok( jQuery.getScript( url("data/test.js"), success ), "script" );
|
||||||
ok( jQuery.getJSON( url("data/json_obj.js"), success ), "json" );
|
ok( jQuery.getJSON( url("data/json_obj.js"), success ), "json" );
|
||||||
ok( jQuery.ajax({url: url(target), success: success}), "generic" );
|
ok( jQuery.ajax({
|
||||||
|
url: url( target ),
|
||||||
|
success: success
|
||||||
|
}), "generic" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "ajax cache", function() {
|
test( "ajax cache", function() {
|
||||||
@ -1011,12 +1115,30 @@ test("ajax cache", function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
|
ok( jQuery.ajax({
|
||||||
ok( jQuery.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
|
url: "data/text.php",
|
||||||
ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
|
cache: false
|
||||||
ok( jQuery.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
|
}), "test with no parameters" );
|
||||||
ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
|
ok( jQuery.ajax({
|
||||||
ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
|
url: "data/text.php?pizza=true",
|
||||||
|
cache: false
|
||||||
|
}), "test with 1 parameter" );
|
||||||
|
ok( jQuery.ajax({
|
||||||
|
url: "data/text.php?_=tobereplaced555",
|
||||||
|
cache: false
|
||||||
|
}), "test with _= parameter" );
|
||||||
|
ok( jQuery.ajax({
|
||||||
|
url: "data/text.php?pizza=true&_=tobereplaced555",
|
||||||
|
cache: false
|
||||||
|
}), "test with 1 parameter plus _= one" );
|
||||||
|
ok( jQuery.ajax({
|
||||||
|
url: "data/text.php?_=tobereplaced555&tv=false",
|
||||||
|
cache: false
|
||||||
|
}), "test with 1 parameter plus _= one before it" );
|
||||||
|
ok( jQuery.ajax({
|
||||||
|
url: "data/text.php?name=David&_=tobereplaced555&washere=true",
|
||||||
|
cache: false
|
||||||
|
}), "test with 2 parameters surrounding _= one" );
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1026,11 +1148,18 @@ test("ajax cache", function () {
|
|||||||
test( "global ajaxSettings", function() {
|
test( "global ajaxSettings", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
|
|
||||||
var tmp = jQuery.extend({}, jQuery.ajaxSettings);
|
var t,
|
||||||
var orig = { url: "data/with_fries.xml" };
|
tmp = jQuery.extend({}, jQuery.ajaxSettings ),
|
||||||
var t;
|
orig = {
|
||||||
|
url: "data/with_fries.xml"
|
||||||
|
};
|
||||||
|
|
||||||
jQuery.ajaxSetup({ data: {foo: "bar", bar: "BAR"} });
|
jQuery.ajaxSetup({
|
||||||
|
data: {
|
||||||
|
foo: "bar",
|
||||||
|
bar: "BAR"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
t = jQuery.extend({}, orig );
|
t = jQuery.extend({}, orig );
|
||||||
t.data = {};
|
t.data = {};
|
||||||
@ -1038,7 +1167,10 @@ test("global ajaxSettings", function() {
|
|||||||
ok( t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending {}" );
|
ok( t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending {}" );
|
||||||
|
|
||||||
t = jQuery.extend({}, orig );
|
t = jQuery.extend({}, orig );
|
||||||
t.data = { zoo: "a", ping: "b" };
|
t.data = {
|
||||||
|
zoo: "a",
|
||||||
|
ping: "b"
|
||||||
|
};
|
||||||
jQuery.ajax( t );
|
jQuery.ajax( t );
|
||||||
ok( t.url.indexOf("ping") > -1 && t.url.indexOf("zoo") > -1 && t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending { zoo: "a", ping: "b" }" );
|
ok( t.url.indexOf("ping") > -1 && t.url.indexOf("zoo") > -1 && t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending { zoo: "a", ping: "b" }" );
|
||||||
|
|
||||||
@ -1100,11 +1232,15 @@ test("load('url selector')", function() {
|
|||||||
test( "load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
|
test( "load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
stop();
|
stop();
|
||||||
jQuery.ajaxSetup({ dataType: "json" });
|
jQuery.ajaxSetup({
|
||||||
|
dataType: "json"
|
||||||
|
});
|
||||||
jQuery("#first").ajaxComplete(function( e, xml, s ) {
|
jQuery("#first").ajaxComplete(function( e, xml, s ) {
|
||||||
equal( s.dataType, "html", "Verify the load() dataType was html" );
|
equal( s.dataType, "html", "Verify the load() dataType was html" );
|
||||||
jQuery("#first").unbind("ajaxComplete");
|
jQuery("#first").unbind("ajaxComplete");
|
||||||
jQuery.ajaxSetup({ dataType: "" });
|
jQuery.ajaxSetup({
|
||||||
|
dataType: ""
|
||||||
|
});
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
jQuery("#first").load("data/test3.html");
|
jQuery("#first").load("data/test3.html");
|
||||||
@ -1152,11 +1288,17 @@ test("load(String, Function) - check file with only a script tag", function() {
|
|||||||
test( "load(String, Function) - dataFilter in ajaxSettings", function() {
|
test( "load(String, Function) - dataFilter in ajaxSettings", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
stop();
|
stop();
|
||||||
jQuery.ajaxSetup({ dataFilter: function() { return "Hello World"; } });
|
jQuery.ajaxSetup({
|
||||||
|
dataFilter: function() {
|
||||||
|
return "Hello World";
|
||||||
|
}
|
||||||
|
});
|
||||||
var div = jQuery("<div/>").load( url("data/name.html"), function( responseText ) {
|
var div = jQuery("<div/>").load( url("data/name.html"), function( responseText ) {
|
||||||
strictEqual( div.html(), "Hello World", "Test div was filled with filtered data" );
|
strictEqual( div.html(), "Hello World", "Test div was filled with filtered data" );
|
||||||
strictEqual( responseText, "Hello World", "Test callback receives filtered data" );
|
strictEqual( responseText, "Hello World", "Test callback receives filtered data" );
|
||||||
jQuery.ajaxSetup({ dataFilter: 0 });
|
jQuery.ajaxSetup({
|
||||||
|
dataFilter: 0
|
||||||
|
});
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1165,7 +1307,10 @@ test("load(String, Object, Function)", function() {
|
|||||||
expect( 2 );
|
expect( 2 );
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery("<div />").load(url("data/params_html.php"), { "foo": 3, "bar": "ok" }, function() {
|
jQuery("<div />").load( url("data/params_html.php"), {
|
||||||
|
"foo": 3,
|
||||||
|
"bar": "ok"
|
||||||
|
}, function() {
|
||||||
var $post = jQuery( this ).find("#post");
|
var $post = jQuery( this ).find("#post");
|
||||||
equal( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly" );
|
equal( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly" );
|
||||||
equal( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly" );
|
equal( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly" );
|
||||||
@ -1187,14 +1332,18 @@ test("load(String, String, Function)", function() {
|
|||||||
|
|
||||||
asyncTest( "load() - data specified in ajaxSettings is merged in (#10524)", 1, function() {
|
asyncTest( "load() - data specified in ajaxSettings is merged in (#10524)", 1, function() {
|
||||||
jQuery.ajaxSetup({
|
jQuery.ajaxSetup({
|
||||||
data: { "foo": "bar" }
|
data: {
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
"baz": 1
|
"baz": 1
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery("#foo").load( "data/echoQuery.php", data).ajaxComplete(function( event, jqXHR, options ) {
|
jQuery("#foo")
|
||||||
|
.load( "data/echoQuery.php", data )
|
||||||
|
.ajaxComplete(function( event, jqXHR, options ) {
|
||||||
ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" );
|
ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" );
|
||||||
jQuery.ajaxSetup({
|
jQuery.ajaxSetup({
|
||||||
data: null
|
data: null
|
||||||
@ -1216,7 +1365,10 @@ asyncTest("load() - callbacks get the correct parameters", 8, function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery.when.apply( jQuery, jQuery.map([
|
jQuery.when.apply(
|
||||||
|
/* jQuery.when.apply arguments start */
|
||||||
|
jQuery,
|
||||||
|
jQuery.map([
|
||||||
{
|
{
|
||||||
type: "success",
|
type: "success",
|
||||||
url: "data/echoQuery.php?arg=pop"
|
url: "data/echoQuery.php?arg=pop"
|
||||||
@ -1225,7 +1377,8 @@ asyncTest("load() - callbacks get the correct parameters", 8, function() {
|
|||||||
type: "error",
|
type: "error",
|
||||||
url: "data/404.php"
|
url: "data/404.php"
|
||||||
}
|
}
|
||||||
], function( options ) {
|
],
|
||||||
|
function( options ) {
|
||||||
return jQuery.Deferred(function( defer ) {
|
return jQuery.Deferred(function( defer ) {
|
||||||
jQuery("#foo").load( options.url, function() {
|
jQuery("#foo").load( options.url, function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
@ -1236,7 +1389,9 @@ asyncTest("load() - callbacks get the correct parameters", 8, function() {
|
|||||||
defer.resolve();
|
defer.resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}) ).always(function() {
|
})
|
||||||
|
/* jQuery.when.apply arguments end*/
|
||||||
|
).always(function() {
|
||||||
jQuery.ajaxSetup({
|
jQuery.ajaxSetup({
|
||||||
success: null,
|
success: null,
|
||||||
error: null
|
error: null
|
||||||
@ -1561,8 +1716,7 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
|
|||||||
jsonpCallback: "XXX",
|
jsonpCallback: "XXX",
|
||||||
crossDomain: crossDomain,
|
crossDomain: crossDomain,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ) ,
|
ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" );
|
||||||
"The URL wasn't messed with (GET, custom callback name with no url manipulation)" );
|
|
||||||
plus();
|
plus();
|
||||||
},
|
},
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
@ -1706,17 +1860,20 @@ test("jQuery.ajax() - script by content-type", function() {
|
|||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.when(
|
jQuery.when(
|
||||||
|
/* jQuery.when arguments start */
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/script.php",
|
url: "data/script.php",
|
||||||
data: { "header": "script" }
|
data: {
|
||||||
|
"header": "script"
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/script.php",
|
url: "data/script.php",
|
||||||
data: { "header": "ecma" }
|
data: {
|
||||||
|
"header": "ecma"
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
/* jQuery.when arguments end */
|
||||||
).always(function() {
|
).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
@ -1729,7 +1886,10 @@ test("jQuery.ajax() - json by content-type", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/json.php",
|
url: "data/json.php",
|
||||||
data: { "header": "json", "json": "array" },
|
data: {
|
||||||
|
"header": "json",
|
||||||
|
"json": "array"
|
||||||
|
},
|
||||||
success: function( json ) {
|
success: function( json ) {
|
||||||
ok( json.length >= 2, "Check length" );
|
ok( json.length >= 2, "Check length" );
|
||||||
equal( json[ 0 ]["name"], "John", "Check JSON: first, name" );
|
equal( json[ 0 ]["name"], "John", "Check JSON: first, name" );
|
||||||
@ -1748,7 +1908,10 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/json.php"),
|
url: url("data/json.php"),
|
||||||
data: { "header": "json", "json": "array" },
|
data: {
|
||||||
|
"header": "json",
|
||||||
|
"json": "array"
|
||||||
|
},
|
||||||
contents: {
|
contents: {
|
||||||
"json": false
|
"json": false
|
||||||
},
|
},
|
||||||
@ -1768,14 +1931,22 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
|
|||||||
test( "jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
test( "jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
||||||
expect( 5 );
|
expect( 5 );
|
||||||
stop();
|
stop();
|
||||||
jQuery.getJSON(url("data/json.php"), {"json": "array"}, function(json) {
|
jQuery.getJSON(
|
||||||
|
/* jQuery.getJSON arguments start */
|
||||||
|
url("data/json.php"),
|
||||||
|
{
|
||||||
|
"json": "array"
|
||||||
|
},
|
||||||
|
function( json ) {
|
||||||
ok( json.length >= 2, "Check length" );
|
ok( json.length >= 2, "Check length" );
|
||||||
equal( json[ 0 ]["name"], "John", "Check JSON: first, name" );
|
equal( json[ 0 ]["name"], "John", "Check JSON: first, name" );
|
||||||
equal( json[ 0 ]["age"], 21, "Check JSON: first, age" );
|
equal( json[ 0 ]["age"], 21, "Check JSON: first, age" );
|
||||||
equal( json[ 1 ]["name"], "Peter", "Check JSON: second, name" );
|
equal( json[ 1 ]["name"], "Peter", "Check JSON: second, name" );
|
||||||
equal( json[ 1 ]["age"], 25, "Check JSON: second, age" );
|
equal( json[ 1 ]["age"], 25, "Check JSON: second, age" );
|
||||||
start();
|
start();
|
||||||
});
|
}
|
||||||
|
/* jQuery.getJSON arguments end */
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.getJSON(String, Function) - JSON object", function() {
|
test( "jQuery.getJSON(String, Function) - JSON object", function() {
|
||||||
@ -1826,13 +1997,22 @@ test("jQuery.post - data", 3, function() {
|
|||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.when(
|
jQuery.when(
|
||||||
jQuery.post( url( "data/name.php" ), { xml: "5-2", length: 3 }, function( xml ) {
|
/* jQuery.when arguments start */
|
||||||
|
jQuery.post(
|
||||||
|
/* jQuery.post arguments start */
|
||||||
|
url("data/name.php"),
|
||||||
|
{
|
||||||
|
xml: "5-2",
|
||||||
|
length: 3
|
||||||
|
},
|
||||||
|
function( xml ) {
|
||||||
jQuery( "math", xml ).each(function() {
|
jQuery( "math", xml ).each(function() {
|
||||||
equal( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
|
equal( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
|
||||||
equal( jQuery( "result", this ).text(), "3", "Check for XML" );
|
equal( jQuery( "result", this ).text(), "3", "Check for XML" );
|
||||||
});
|
});
|
||||||
}),
|
}
|
||||||
|
/* jQuery.post arguments end */
|
||||||
|
),
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/echoData.php"),
|
url: url("data/echoData.php"),
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -1846,6 +2026,7 @@ test("jQuery.post - data", 3, function() {
|
|||||||
strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" );
|
strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" );
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
/* jQuery.when arguments end */
|
||||||
).always(function() {
|
).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
@ -1857,7 +2038,13 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
|||||||
stop();
|
stop();
|
||||||
var done = 0;
|
var done = 0;
|
||||||
|
|
||||||
jQuery.post(url("data/name.php"), {"xml": "5-2"}, function(xml){
|
jQuery.post(
|
||||||
|
/* jQuery.post arguments start */
|
||||||
|
url("data/name.php"),
|
||||||
|
{
|
||||||
|
"xml": "5-2"
|
||||||
|
},
|
||||||
|
function( xml ) {
|
||||||
jQuery( "math", xml ).each(function() {
|
jQuery( "math", xml ).each(function() {
|
||||||
equal( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
|
equal( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
|
||||||
equal( jQuery( "result", this ).text(), "3", "Check for XML" );
|
equal( jQuery( "result", this ).text(), "3", "Check for XML" );
|
||||||
@ -1865,7 +2052,9 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
|||||||
if ( ++done === 2 ) {
|
if ( ++done === 2 ) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
/* jQuery.post arguments end */
|
||||||
|
);
|
||||||
|
|
||||||
jQuery.post( url("data/name.php?xml=5-2"), {}, function( xml ) {
|
jQuery.post( url("data/name.php?xml=5-2"), {}, function( xml ) {
|
||||||
jQuery( "math", xml ).each(function() {
|
jQuery( "math", xml ).each(function() {
|
||||||
@ -1879,13 +2068,15 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
||||||
|
var passed = 0;
|
||||||
|
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var passed = 0;
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 1000
|
||||||
jQuery.ajaxSetup({timeout: 1000});
|
});
|
||||||
|
|
||||||
var pass = function() {
|
var pass = function() {
|
||||||
passed++;
|
passed++;
|
||||||
@ -1911,14 +2102,18 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// reset timeout
|
// reset timeout
|
||||||
jQuery.ajaxSetup({timeout: 0});
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
|
test( "jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
jQuery.ajaxSetup({timeout: 50});
|
|
||||||
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 50
|
||||||
|
});
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@ -1935,7 +2130,9 @@ test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// reset timeout
|
// reset timeout
|
||||||
jQuery.ajaxSetup({timeout: 0});
|
jQuery.ajaxSetup({
|
||||||
|
timeout: 0
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajax - simple get", function() {
|
test( "jQuery.ajax - simple get", function() {
|
||||||
@ -1978,24 +2175,8 @@ test("ajaxSetup()", function() {
|
|||||||
jQuery.ajax();
|
jQuery.ajax();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
test("custom timeout does not set error message when timeout occurs, see #970", function() {
|
|
||||||
stop();
|
|
||||||
jQuery.ajax({
|
|
||||||
url: "data/name.php?wait=1",
|
|
||||||
timeout: 500,
|
|
||||||
error: function(request, status) {
|
|
||||||
ok( status != null, "status shouldn't be null in error handler" );
|
|
||||||
equal( "timeout", status );
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
test( "data option: evaluate function values (#2806)", function() {
|
test( "data option: evaluate function values (#2806)", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/echoQuery.php",
|
url: "data/echoQuery.php",
|
||||||
@ -2013,7 +2194,6 @@ test("data option: evaluate function values (#2806)", function() {
|
|||||||
|
|
||||||
test( "data option: empty bodies for non-GET requests", function() {
|
test( "data option: empty bodies for non-GET requests", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "data/echoData.php",
|
url: "data/echoData.php",
|
||||||
@ -2028,7 +2208,13 @@ test("data option: empty bodies for non-GET requests", function() {
|
|||||||
|
|
||||||
var ifModifiedNow = new Date();
|
var ifModifiedNow = new Date();
|
||||||
|
|
||||||
jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache ) {
|
jQuery.each(
|
||||||
|
/* jQuery.each arguments start */
|
||||||
|
{
|
||||||
|
" (cache)": true,
|
||||||
|
" (no cache)": false
|
||||||
|
},
|
||||||
|
function( label, cache ) {
|
||||||
|
|
||||||
test( "jQuery.ajax - If-Modified-Since support" + label, function() {
|
test( "jQuery.ajax - If-Modified-Since support" + label, function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
@ -2126,7 +2312,9 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
/* jQuery.each arguments end */
|
||||||
|
);
|
||||||
|
|
||||||
test( "jQuery ajax - failing cross-domain", function() {
|
test( "jQuery ajax - failing cross-domain", function() {
|
||||||
|
|
||||||
@ -2138,8 +2326,12 @@ test("jQuery ajax - failing cross-domain", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "http://somewebsitethatdoesnotexist-67864863574657654.com",
|
url: "http://somewebsitethatdoesnotexist-67864863574657654.com",
|
||||||
success: function(){ ok( false , "success" ); },
|
success: function() {
|
||||||
error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
|
ok( false, "success" );
|
||||||
|
},
|
||||||
|
error: function( xhr, _, e ) {
|
||||||
|
ok( true, "file not found: " + xhr.status + " => " + e );
|
||||||
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
if ( ! --i ) {
|
if ( ! --i ) {
|
||||||
start();
|
start();
|
||||||
@ -2149,8 +2341,12 @@ test("jQuery ajax - failing cross-domain", function() {
|
|||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "http://www.google.com",
|
url: "http://www.google.com",
|
||||||
success: function(){ ok( false , "success" ); },
|
success: function() {
|
||||||
error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
|
ok( false, "success" );
|
||||||
|
},
|
||||||
|
error: function( xhr, _, e ) {
|
||||||
|
ok( true, "access denied: " + xhr.status + " => " + e );
|
||||||
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
if ( ! --i ) {
|
if ( ! --i ) {
|
||||||
start();
|
start();
|
||||||
@ -2162,14 +2358,19 @@ test("jQuery ajax - failing cross-domain", function() {
|
|||||||
|
|
||||||
test( "jQuery ajax - atom+xml", function() {
|
test( "jQuery ajax - atom+xml", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/atom+xml.php"),
|
url: url("data/atom+xml.php"),
|
||||||
success: function(){ ok( true , "success" ); },
|
success: function() {
|
||||||
error: function(){ ok( false , "error" ); },
|
ok( true, "success" );
|
||||||
complete: function() { start(); }
|
},
|
||||||
|
error: function() {
|
||||||
|
ok( false, "error" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
start();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -2177,10 +2378,14 @@ test("jQuery ajax - atom+xml", function() {
|
|||||||
test( "jQuery.ajax - Location object as url (#7531)", 1, function () {
|
test( "jQuery.ajax - Location object as url (#7531)", 1, function () {
|
||||||
var success = false;
|
var success = false;
|
||||||
try {
|
try {
|
||||||
var xhr = jQuery.ajax({ url: window.location });
|
var xhr = jQuery.ajax({
|
||||||
|
url: window.location
|
||||||
|
});
|
||||||
success = true;
|
success = true;
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ok( success, "document.location did not generate exception" );
|
ok( success, "document.location did not generate exception" );
|
||||||
});
|
});
|
||||||
@ -2198,7 +2403,9 @@ test( "jQuery.ajax - Context with circular references (#9887)", 2, function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
success = true;
|
success = true;
|
||||||
} catch (e) { console.log( e ); }
|
} catch ( e ) {
|
||||||
|
console.log( e );
|
||||||
|
}
|
||||||
ok( success, "context with circular reference did not generate an exception" );
|
ok( success, "context with circular reference did not generate an exception" );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2240,10 +2447,13 @@ test( "jQuery.ajax - statusCode" , function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery.each( {
|
jQuery.each(
|
||||||
|
/* jQuery.each arguments start */
|
||||||
|
{
|
||||||
"data/name.html": true,
|
"data/name.html": true,
|
||||||
"data/someFileThatDoesNotExist.html": false
|
"data/someFileThatDoesNotExist.html": false
|
||||||
} , function( uri , isSuccess ) {
|
},
|
||||||
|
function( uri, isSuccess ) {
|
||||||
|
|
||||||
jQuery.ajax( url(uri), {
|
jQuery.ajax( url(uri), {
|
||||||
statusCode: createStatusCodes( "in options", isSuccess ),
|
statusCode: createStatusCodes( "in options", isSuccess ),
|
||||||
@ -2303,13 +2513,18 @@ test( "jQuery.ajax - statusCode" , function() {
|
|||||||
testString += "A";
|
testString += "A";
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
strictEqual( testString , "AB" , "Test statusCode callbacks are ordered like " +
|
strictEqual(
|
||||||
( isSuccess ? "success" : "error" ) + " callbacks" );
|
testString,
|
||||||
|
"AB",
|
||||||
|
"Test statusCode callbacks are ordered like " + ( isSuccess ? "success" : "error" ) + " callbacks"
|
||||||
|
);
|
||||||
countComplete();
|
countComplete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
}
|
||||||
|
/* jQuery.each arguments end*/
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.ajax - transitive conversions", function() {
|
test( "jQuery.ajax - transitive conversions", function() {
|
||||||
@ -2319,7 +2534,7 @@ test("jQuery.ajax - transitive conversions", function() {
|
|||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.when(
|
jQuery.when(
|
||||||
|
/* jQuery.when arguments start */
|
||||||
jQuery.ajax( url("data/json.php"), {
|
jQuery.ajax( url("data/json.php"), {
|
||||||
converters: {
|
converters: {
|
||||||
"json myJson": function( data ) {
|
"json myJson": function( data ) {
|
||||||
@ -2350,7 +2565,7 @@ test("jQuery.ajax - transitive conversions", function() {
|
|||||||
strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" );
|
strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" );
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
/* jQuery.when arguments end */
|
||||||
).always(function() {
|
).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
@ -2364,7 +2579,7 @@ test("jQuery.ajax - overrideMimeType", function() {
|
|||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.when(
|
jQuery.when(
|
||||||
|
/* jQuery.when arguments start */
|
||||||
jQuery.ajax( url("data/json.php"), {
|
jQuery.ajax( url("data/json.php"), {
|
||||||
beforeSend: function( xhr ) {
|
beforeSend: function( xhr ) {
|
||||||
xhr.overrideMimeType( "application/json" );
|
xhr.overrideMimeType( "application/json" );
|
||||||
@ -2373,14 +2588,13 @@ test("jQuery.ajax - overrideMimeType", function() {
|
|||||||
ok( json.data, "Mimetype overriden using beforeSend" );
|
ok( json.data, "Mimetype overriden using beforeSend" );
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
jQuery.ajax( url("data/json.php"), {
|
jQuery.ajax( url("data/json.php"), {
|
||||||
mimeType: "application/json",
|
mimeType: "application/json",
|
||||||
success: function( json ) {
|
success: function( json ) {
|
||||||
ok( json.data, "Mimetype overriden using mimeType option" );
|
ok( json.data, "Mimetype overriden using mimeType option" );
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
/* jQuery.when arguments end */
|
||||||
).always(function() {
|
).always(function() {
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
@ -2452,8 +2666,6 @@ test( "jQuery.domManip - script in comments are properly evaluated (#11402)", fu
|
|||||||
|
|
||||||
test( "jQuery.ajax - active counter", function() {
|
test( "jQuery.ajax - active counter", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
|
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user