From 228ab3ddae527f72cc3122a1c6115d7718bcfd57 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Tue, 4 Dec 2012 07:39:27 +0100 Subject: [PATCH] Organizes the php scripts used for testing better, so that the whole logic of a unit, server-side and client-side, is contained within the unit itself. Nearly all ajax unit tests take advantage of the new 'framework'. Lots of files got deleted because they became redundant or weren't used anymore. --- test/.jshintrc | 6 +- test/data/ajax/echo/index.php | 43 + test/data/ajax/headers/cache/index.php | 30 + test/data/ajax/headers/request/index.php | 12 + test/data/ajax/headers/response/index.php | 5 + test/data/atom+xml.php | 4 - test/data/badcall.js | 1 - test/data/badjson.js | 1 - test/data/cleanScript.html | 10 - test/data/dashboard.xml | 11 - test/data/echoData.php | 1 - test/data/echoQuery.php | 1 - test/data/errorWithText.php | 5 - test/data/etag.php | 21 - test/data/evalScript.php | 1 - test/data/headers.php | 18 - test/data/if_modified_since.php | 20 - test/data/json.php | 13 - test/data/json_obj.js | 1 - test/data/jsonp.php | 14 - test/data/name.html | 1 - test/data/name.php | 24 - test/data/params_html.php | 12 - test/data/script.php | 11 - test/data/statusText.php | 5 - test/data/test.html | 7 - test/data/test.js | 3 - test/data/test.php | 7 - test/data/test2.html | 5 - test/data/test3.html | 3 - test/data/testinit.js | 46 +- test/data/text.php | 12 - test/data/ua.txt | 272 ---- test/data/with_fries.xml | 25 - test/data/with_fries_over_jsonp.php | 7 - test/localfile.html | 4 +- test/unit/ajax.js | 1465 ++++++++++----------- test/unit/manipulation.js | 2 +- 38 files changed, 828 insertions(+), 1301 deletions(-) create mode 100644 test/data/ajax/echo/index.php create mode 100644 test/data/ajax/headers/cache/index.php create mode 100644 test/data/ajax/headers/request/index.php create mode 100644 test/data/ajax/headers/response/index.php delete mode 100644 test/data/atom+xml.php delete mode 100644 test/data/badcall.js delete mode 100644 test/data/badjson.js delete mode 100644 test/data/cleanScript.html delete mode 100644 test/data/dashboard.xml delete mode 100644 test/data/echoData.php delete mode 100644 test/data/echoQuery.php delete mode 100644 test/data/errorWithText.php delete mode 100644 test/data/etag.php delete mode 100644 test/data/evalScript.php delete mode 100644 test/data/headers.php delete mode 100644 test/data/if_modified_since.php delete mode 100644 test/data/json.php delete mode 100644 test/data/json_obj.js delete mode 100644 test/data/jsonp.php delete mode 100644 test/data/name.html delete mode 100644 test/data/name.php delete mode 100644 test/data/params_html.php delete mode 100644 test/data/script.php delete mode 100644 test/data/statusText.php delete mode 100644 test/data/test.html delete mode 100644 test/data/test.js delete mode 100644 test/data/test.php delete mode 100644 test/data/test2.html delete mode 100644 test/data/test3.html delete mode 100644 test/data/text.php delete mode 100644 test/data/ua.txt delete mode 100644 test/data/with_fries.xml delete mode 100644 test/data/with_fries_over_jsonp.php diff --git a/test/.jshintrc b/test/.jshintrc index 2dd668c3f..43e9c722d 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -41,11 +41,15 @@ "ajaxTest": true, "testIframe": true, "testIframeWithCallback": true, + "createComplexHTML": true, "createDashboardXML": true, + "createWithFriesXML": true, "createXMLFragment": true, "moduleTeardown": true, + "testBar": true, "testFoo": true, - "url": true, + "url": true, + "service": true, "t": true, "q": true, "amdDefined": true, diff --git a/test/data/ajax/echo/index.php b/test/data/ajax/echo/index.php new file mode 100644 index 000000000..a03fe4b0d --- /dev/null +++ b/test/data/ajax/echo/index.php @@ -0,0 +1,43 @@ + "200", + "statusText" => "", + "contentType" => "text/plain", + "content" => "", + "callback" => "", + "delay" => 0 + ); + + foreach( $response as $field => &$value ) { + if ( isset( $requestArray[ $field ] ) ) { + $value = $requestArray[ $field ]; + } + } + + if ( is_array( $response["content"] ) ) { + $response["content"] = http_build_query( $response["content"] ); + } + + if ( !$response["callback"] && preg_match( '/index.php\/([^\/\?&]+)/', $_SERVER["REQUEST_URI"], $match ) ) { + $response["callback"] = $match[ 1 ]; + } + + header("HTTP/1.1 $response[status] $response[statusText]"); + header("Content-Type: $response[contentType]"); + + if ( $response["delay"] ) { + sleep( $response["delay"] ); + } + + echo $response["callback"] + ? "$response[callback](" . json_encode("$response[content]") . ");" + : "$response[content]"; diff --git a/test/data/ajax/headers/cache/index.php b/test/data/ajax/headers/cache/index.php new file mode 100644 index 000000000..c52b665bd --- /dev/null +++ b/test/data/ajax/headers/cache/index.php @@ -0,0 +1,30 @@ + array( + "request" => "HTTP_IF_MODIFIED_SINCE", + "response" => "Last-Modified", + ), + "If-None-Match" => array( + "request" => "HTTP_IF_NONE_MATCH", + "response" => "Etag", + ), + +); + +$header = $_REQUEST["header"]; +$value = $_REQUEST["value"]; + +if ( $header === "If-None-Match" ) { + $value = md5( $value ); +} + +$headers = $headers[ $header ]; + +$requestHeader = isset( $_SERVER[ $headers["request"] ] ) ? stripslashes($_SERVER[ $headers["request"] ]) : false; +if ( $requestHeader === $value ) { + header("HTTP/1.0 304 Not Modified"); +} else { + header("$headers[response]: $value"); + echo $requestHeader ? "OK: $value": "FAIL"; +} diff --git a/test/data/ajax/headers/request/index.php b/test/data/ajax/headers/request/index.php new file mode 100644 index 000000000..c064ad709 --- /dev/null +++ b/test/data/ajax/headers/request/index.php @@ -0,0 +1,12 @@ + $value ) { + $key = str_replace( "_" , "-" , substr($key,0,5) == "HTTP_" ? substr($key,5) : $key ); + $headers[ $key ] = $value; +} + +foreach( explode( "," , $_GET["headers"] ) as $key ) { + echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; +} diff --git a/test/data/ajax/headers/response/index.php b/test/data/ajax/headers/response/index.php new file mode 100644 index 000000000..6c8d0864e --- /dev/null +++ b/test/data/ajax/headers/response/index.php @@ -0,0 +1,5 @@ + $value ) { + @header("$header: $value"); +} diff --git a/test/data/atom+xml.php b/test/data/atom+xml.php deleted file mode 100644 index 944591abf..000000000 --- a/test/data/atom+xml.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/test/data/badcall.js b/test/data/badcall.js deleted file mode 100644 index cc2f2b42c..000000000 --- a/test/data/badcall.js +++ /dev/null @@ -1 +0,0 @@ -undefined(); diff --git a/test/data/badjson.js b/test/data/badjson.js deleted file mode 100644 index ad2de7a39..000000000 --- a/test/data/badjson.js +++ /dev/null @@ -1 +0,0 @@ -{bad: toTheBone} diff --git a/test/data/cleanScript.html b/test/data/cleanScript.html deleted file mode 100644 index 69288a858..000000000 --- a/test/data/cleanScript.html +++ /dev/null @@ -1,10 +0,0 @@ - - diff --git a/test/data/dashboard.xml b/test/data/dashboard.xml deleted file mode 100644 index 5a6f56142..000000000 --- a/test/data/dashboard.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/data/echoData.php b/test/data/echoData.php deleted file mode 100644 index a37ba515a..000000000 --- a/test/data/echoData.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/data/echoQuery.php b/test/data/echoQuery.php deleted file mode 100644 index b72f329c9..000000000 --- a/test/data/echoQuery.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/data/errorWithText.php b/test/data/errorWithText.php deleted file mode 100644 index abd873217..000000000 --- a/test/data/errorWithText.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/test/data/evalScript.php b/test/data/evalScript.php deleted file mode 100644 index ea9b8c55f..000000000 --- a/test/data/evalScript.php +++ /dev/null @@ -1 +0,0 @@ -ok( "" === "GET", "request method is " ); \ No newline at end of file diff --git a/test/data/headers.php b/test/data/headers.php deleted file mode 100644 index 968f13f19..000000000 --- a/test/data/headers.php +++ /dev/null @@ -1,18 +0,0 @@ - $value ) { - - $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key ); - $headers[ $key ] = $value; - -} - -foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) { - echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; -} diff --git a/test/data/if_modified_since.php b/test/data/if_modified_since.php deleted file mode 100644 index 098b7da85..000000000 --- a/test/data/if_modified_since.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/test/data/json.php b/test/data/json.php deleted file mode 100644 index d6e0f2fc7..000000000 --- a/test/data/json.php +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/test/data/json_obj.js b/test/data/json_obj.js deleted file mode 100644 index 7fa61820f..000000000 --- a/test/data/json_obj.js +++ /dev/null @@ -1 +0,0 @@ -{ "data": {"lang": "en", "length": 25} } diff --git a/test/data/jsonp.php b/test/data/jsonp.php deleted file mode 100644 index 6c13d72e9..000000000 --- a/test/data/jsonp.php +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/test/data/name.html b/test/data/name.html deleted file mode 100644 index 0fa32d1a8..000000000 --- a/test/data/name.html +++ /dev/null @@ -1 +0,0 @@ -ERROR diff --git a/test/data/name.php b/test/data/name.php deleted file mode 100644 index 64028585d..000000000 --- a/test/data/name.php +++ /dev/null @@ -1,24 +0,0 @@ -$xml$result"; - die(); -} -$name = $_REQUEST['name']; -if($name == 'foo') { - echo "bar"; - die(); -} else if($name == 'peter') { - echo "pan"; - die(); -} - -echo 'ERROR '; -?> \ No newline at end of file diff --git a/test/data/params_html.php b/test/data/params_html.php deleted file mode 100644 index e88ef1521..000000000 --- a/test/data/params_html.php +++ /dev/null @@ -1,12 +0,0 @@ -
-$value ) - echo "$value"; -?> -
-
-$value ) - echo "$value"; -?> -
\ No newline at end of file diff --git a/test/data/script.php b/test/data/script.php deleted file mode 100644 index fb7110491..000000000 --- a/test/data/script.php +++ /dev/null @@ -1,11 +0,0 @@ - -ok( true, "Script executed correctly." ); diff --git a/test/data/statusText.php b/test/data/statusText.php deleted file mode 100644 index daf58ce3f..000000000 --- a/test/data/statusText.php +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/test/data/test.html b/test/data/test.html deleted file mode 100644 index eec028e90..000000000 --- a/test/data/test.html +++ /dev/null @@ -1,7 +0,0 @@ -html text
- - -blabla diff --git a/test/data/test.js b/test/data/test.js deleted file mode 100644 index a18815315..000000000 --- a/test/data/test.js +++ /dev/null @@ -1,3 +0,0 @@ -var testBar = "bar"; -jQuery('#ap').html('bar'); -ok( true, "test.js executed"); diff --git a/test/data/test.php b/test/data/test.php deleted file mode 100644 index 3d08f3253..000000000 --- a/test/data/test.php +++ /dev/null @@ -1,7 +0,0 @@ -html text
- - -blabla \ No newline at end of file diff --git a/test/data/test2.html b/test/data/test2.html deleted file mode 100644 index 1df6151a0..000000000 --- a/test/data/test2.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/test/data/test3.html b/test/data/test3.html deleted file mode 100644 index 909d41745..000000000 --- a/test/data/test3.html +++ /dev/null @@ -1,3 +0,0 @@ -
This is a user
-
This is a user
-
This is a teacher
diff --git a/test/data/testinit.js b/test/data/testinit.js index bff6b8dff..6050eec4c 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -58,7 +58,21 @@ function t( a, b, c ) { deepEqual(f, q.apply( q, c ), a + " (" + b + ")"); } -function createDashboardXML() { +function createComplexHTML() { + return 'html text
\ + \ + \ + blabla'; +} + +function createDashboardXML( noParse ) { var string = ' \ \ \ @@ -71,10 +85,10 @@ function createDashboardXML() { \ '; - return jQuery.parseXML(string); + return noParse ? string : jQuery.parseXML(string); } -function createWithFriesXML() { +function createWithFriesXML( noParse ) { var string = ' \ \ \ \ - '; + '.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ); - return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) ); + return noParse ? string : jQuery.parseXML( string ); } function createXMLFragment() { @@ -133,16 +147,27 @@ fireNative = document.createEvent ? /** * Add random number to url to stop caching * - * @example url("data/test.html") - * @result "data/test.html?10538358428943" + * @example url("data/iframe.html") + * @result "data/iframe.html?10538358428943" * - * @example url("data/test.php?foo=bar") - * @result "data/test.php?foo=bar&10538358345554" + * @example url("data/ajax/echo?foo=bar") + * @result "data/ajax/echo?foo=bar&10538358345554" */ function url( value ) { return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 10); } +function service( value, data ) { + var fragment = url( "data/ajax/" + ( value || "" ) ); + if ( data ) { + if ( typeof data !== "string" ) { + data = jQuery.param( data ); + } + fragment += "&" + data; + } + return fragment; +} + // Ajax testing helper function ajaxTest( title, expect, options ) { var requestOptions; @@ -167,8 +192,9 @@ function ajaxTest( title, expect, options ) { delete ajaxTest.abort; if ( options.teardown ) { options.teardown(); + } else { + start(); } - start(); } }, requests = jQuery.map( requestOptions, function( options ) { diff --git a/test/data/text.php b/test/data/text.php deleted file mode 100644 index b9df4cf3b..000000000 --- a/test/data/text.php +++ /dev/null @@ -1,12 +0,0 @@ -Lorem ipsum dolor sit amet -consectetuer adipiscing elit -Sed lorem leo -lorem leo consectetuer adipiscing elit -Sed lorem leo -rhoncus sit amet -elementum at -bibendum at, eros -Cras at mi et tortor egestas vestibulum -sed Cras at mi vestibulum -Phasellus sed felis sit amet -orci dapibus semper. diff --git a/test/data/ua.txt b/test/data/ua.txt deleted file mode 100644 index 95e522e25..000000000 --- a/test/data/ua.txt +++ /dev/null @@ -1,272 +0,0 @@ -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90; http://www.Abolimba.de) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; JyxoToolbar1.0; http://www.Abolimba.de; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322) - 0 Mozilla/5.0 (compatible; ABrowse 0.4; Syllable) -webkit 420 Mozilla/5.0 (compatible; U; ABrowse 0.6; Syllable) AppleWebKit/420+ (KHTML, like Gecko) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Acoo Browser; InfoPath.2; .NET CLR 2.0.50727; Alexa Toolbar) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Acoo Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506) - 0 amaya/9.52 libwww/5.4.0 - 0 amaya/11.1 libwww/5.4.0 - 0 Amiga-AWeb/3.5.07 beta - 0 AmigaVoyager/3.4.4 (MorphOS/PPC native) - 0 AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; AOL 7.0; Windows NT 5.1; FunWebProducts) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; AOL 8.0; Windows NT 5.1; SV1) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; Zango 10.1.181.0) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; AOL 6.0; Windows NT 5.1) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) -webkit 523.15 Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30) -webkit 527 Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6 -webkit 523.15 Mozilla/5.0 (X11; U; Linux; C -) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.5 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Avant Browser; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1) - 0 Avant Browser (http://www.avantbrowser.com) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; JyxoToolbar1.0; Embedded Web Browser from: http://bsalsa.com/; Avant Browser; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Avant Browser) -mozilla 0 Mozilla/5.0 (Windows; U; Win9x; en; Stable) Gecko/20020911 Beonex/0.8.1-stable -mozilla 0 Mozilla/5.0 (Windows; U; WinNT; en; Preview) Gecko/20020603 Beonex/0.8-stable -mozilla 1.0.2 Mozilla/5.0 (Windows; U; WinNT; en; rv:1.0.2) Gecko/20030311 Beonex/0.8.2-stable -mozilla 1.9 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008120120 Blackbird/0.9991 -webkit 527 Mozilla/5.0 (X11; 78; CentOS; US-en) AppleWebKit/527+ (KHTML, like Gecko) Bolt/0.862 Version/3.0 Safari/523.15 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Browzar) - 0 Bunjalloo/0.7.4(Nintendo DS;U;en) - 0 Bunjalloo/0.7.6(Nintendo DS;U;en) -mozilla 1.8.1.4pre Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4pre) Gecko/20070511 Camino/1.6pre -mozilla 1.7.2 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.2) Gecko/20040825 Camino/0.8.1 -mozilla 1.8.1.12 Mozilla/5.0 (Macintosh; U; Intel Mac OS X Mach-O; en; rv:1.8.1.12) Gecko/20080206 Camino/1.5.5 -mozilla 1.0.1 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20030111 Chimera/0.6 -mozilla 1.8.0.10 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.10) Gecko/20070228 Camino/1.0.4 -webkit 418.9 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko, Safari) Safari/419.3 Cheshire/1.0.ALPHA -webkit 419 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko, Safari/419.3) Cheshire/1.0.ALPHA -chrome 1.0.154.36 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.36 Safari/525.19 -chrome 1.0.154.53 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19 -mozilla 1.9.0.10 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042815 Firefox/3.0.10 CometBird/3.0.10 -mozilla 1.9.0.5 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2009011615 Firefox/3.0.5 CometBird/3.0.5 -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Crazy Browser 3.0.0 Beta2) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; Crazy Browser 2.0.1) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Crazy Browser 1.0.5; .NET CLR 1.1.4322; InfoPath.1) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Deepnet Explorer 1.5.0; .NET CLR 1.0.3705) -webkit 525.27.1 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Demeter/1.0.9 Safari/125 -webkit 312.8 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; pl-pl) AppleWebKit/312.8 (KHTML, like Gecko, Safari) DeskBrowse/1.0 - 0 Dillo/0.8.5 - 0 Dillo/2.0 - 0 DocZilla/1.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020804 - 0 DocZilla/2.7 (Windows; U; Windows NT 5.1; en-US; rv:2.7.0) Gecko/20050706 CiTEC Information -webkit 527 Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Dooble - 0 Doris/1.15 [en] (Symbian) - 0 edbrowse/1.5.17-2 - 0 edbrowse/2.2.10 - 0 edbrowse/3.1.2-1 - 0 ELinks/0.13.GIT (textmode; Linux 2.6.22-2-686 i686; 148x68-3) - 0 ELinks/0.9.3 (textmode; Linux 2.6.11 i686; 79x24) - 0 Enigma Browser -mozilla 1.8.1.12 Mozilla/5.0 (X11; U; Linux i686; en; rv:1.8.1.12) Gecko/20080208 (Debian-1.8.1.12-2) Epiphany/2.20 -mozilla 1.9.0.12 Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.12) Gecko/20080528 Fedora/2.24.3-8.fc10 Epiphany/2.22 Firefox/3.0 -mozilla 1.7.3 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Epiphany/1.4.7 -mozilla 1.5 Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031007 Firebird/0.7 -mozilla 1.5 Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5) Gecko/20031007 Firebird/0.7 -mozilla 1.8.0.3 Mozilla/5.0 (Windows; U; Windows NT 5.0; es-ES; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3 -mozilla 1.9.1b2 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; ko; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2 -mozilla 1.9.0.8 Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 -mozilla 1.7.9 Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.7.9) Gecko/20050711 Firefox/1.0.5 -mozilla 1.9b5 Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5 -mozilla 1.8.0.5 Mozilla/5.0 (X11; U; OpenBSD i386; en-US; rv:1.8.0.5) Gecko/20060819 Firefox/1.5.0.5 -mozilla 1.9.1b3 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3 GTB5 -mozilla 1.8.1.12 Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080214 Firefox/2.0.0.12 -mozilla 1.8.1.9 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) Gecko/20071113 BonEcho/2.0.0.9 -mozilla 1.8.1 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061026 BonEcho/2.0 -mozilla 1.8.1.21pre Mozilla/5.0 (BeOS; U; Haiku BePC; en-US; rv:1.8.1.21pre) Gecko/20090227 BonEcho/2.0.0.21pre -mozilla 1.9.0.8 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko/2009033017 GranParadiso/3.0.8 -mozilla 1.9.2a2pre Mozilla/5.0 (Windows; U; Windows NT 6.1; cs; rv:1.9.2a2pre) Gecko/20090912 Namoroka/3.6a2pre (.NET CLR 3.5.30729) -mozilla 1.9.2a2pre Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2a2pre) Gecko/20090901 Ubuntu/9.10 (karmic) Namoroka/3.6a2pre -mozilla 1.9.2a1 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2a1) Gecko/20090806 Namoroka/3.6a1 -mozilla 1.9.1b3pre Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090109 Shiretoko/3.1b3pre -mozilla 1.9.1b4pre Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1b4pre) Gecko/20090311 Shiretoko/3.1b4pre -mozilla 1.8.0.1 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060314 Flock/0.5.13.2 -mozilla 1.9.0.2 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.2) Gecko/2008092122 Firefox/3.0.2 Flock/2.0b3 -webkit 525.13 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Fluid/0.9.4 Safari/525.13 -mozilla 1.7.12 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050929 Galeon/1.3.21 -mozilla 1.9.0.8 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko/20090327 Galeon/2.0.7 -mozilla 1.9.1.5 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091105 Firefox/3.5.5 compat GlobalMojo/1.5.5 GlobalMojoExt/1.5 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; GreenBrowser) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; GreenBrowser) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser) - 0 HotJava/1.1.2 FCS -mozilla 0 Mozilla/3.0 (x86 [cs] Windows NT 5.1; Sun) -mozilla 1.8.0.3 Mozilla/5.1 (X11; U; Linux i686; en-US; rv:1.8.0.3) Gecko/20060425 SUSE/1.5.0.3-7 Hv3/alpha -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SIMBAR={CFBFDAEA-F21E-4D6E-A9B0-E100A69B860F}; Hydra Browser; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Hydra Browser; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) - 0 IBrowse/2.3 (AmigaOS 3.9) - 0 Mozilla/5.0 (compatible; IBrowse 3.0; AmigaOS4.0) - 0 iCab/4.0 (Macintosh; U; Intel Mac OS X) - 0 Mozilla/4.5 (compatible; iCab 2.9.1; Macintosh; U; PPC) - 0 iCab/3.0.2 (Macintosh; U; PPC Mac OS X) - 0 ICE Browser/v5_4_3 (Java 1.4.2; Windows XP 5.1 x86) -mozilla 0 Mozilla/5.0 (Java 1.6.0_01; Windows XP 5.1 x86; en) ICEbrowser/v6_1_2 - 0 ICE Browser/5.05 (Java 1.4.0; Windows 2000 5.0 x86) -mozilla 1.8.1.9 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) Gecko/20071030 Iceape/1.1.6 (Debian-1.1.6-3) -mozilla 1.8.1.8 Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071008 Iceape/1.1.5 (Ubuntu-1.1.5-1ubuntu0.7.10) -mozilla 1.9.0.3 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092921 IceCat/3.0.3-g1 -mozilla 1.8.1.11 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071203 IceCat/2.0.0.11-g1 -mozilla 1.9.0.5 Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1) -mozilla 1.8.1.1 Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.1) Gecko/20061205 Iceweasel/2.0.0.1 (Debian-2.0.0.1+dfsg-4) -mozilla 1.9.0.5 Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1) -msie 4.0 Mozilla/2.0 (compatible; MSIE 4.0; Windows 98) -msie 6.0 Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) -msie 7.0 Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30) -msie 5.01 Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) -msie 8.0 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 3.0.30729) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727) -msie 5.0b1 Mozilla/4.0 (compatible; MSIE 5.0b1; Mac_PowerPC) -msie 5.0 Mozilla/4.0 (compatible; MSIE 5.0; Windows NT;) -msie 5.23 Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6; Ant.com Toolbar 1.6; MSIECrawler) -msie 8.0 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 3.0.30729) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; iRider 2.21.1108; FDM) -webkit 528.5 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/528.5 (KHTML, like Gecko) Iron/0.4.155.0 Safari/528.5 -webkit 528.7 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/528.7 (KHTML, like Gecko) Iron/1.0.155.0 Safari/528.7 -webkit 525.19 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Iron/0.2.152.0 Safari/12081672.525 -webkit 531.0 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.0 (KHTML, like Gecko) Iron/3.0.189.0 Safari/531.0 -mozilla 1.8.1.19 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.8.1.19) Gecko/20081217 K-Meleon/1.5.2 -mozilla 1.8.1.21 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090331 K-Meleon/1.5.3 -mozilla 1.8.0.5 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060706 K-Meleon/1.0 -mozilla 1.8.1.21 Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.21) Gecko/20090331 K-Meleon/1.5.3 -mozilla 1.8.0.6 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060731 K-Ninja/2.0.2 -mozilla 1.8.1.4pre Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4pre) Gecko/20070404 K-Ninja/2.1.3 -mozilla 1.8.1.2pre Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1 -mozilla 1.9 Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0 -mozilla 0 Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5 -mozilla 1.9.0.8 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; KKman2.0) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; KKMAN3.2) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; KKman3.0) - 0 Mozilla/5.0 (compatible; Konqueror/3.1-rc5; i686 Linux; 20020712) - 0 Mozilla/5.0 (compatible; Konqueror/4.3; Windows) KHTML/4.3.0 (like Gecko) - 0 Mozilla/5.0 (compatible; Konqueror/2.2.1; Linux) - 0 Mozilla/5.0 (compatible; Konqueror/3.5; SunOS) - 0 Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko) - 0 Links (0.96; Linux 2.4.20-18.7 i586) - 0 Links (0.98; Win32; 80x25) - 0 Links (2.1pre18; Linux 2.4.31 i686; 100x37) - 0 Links (2.1; Linux 2.6.18-gentoo-r6 x86_64; 80x24) - 0 Links (2.2; Linux 2.6.25-gentoo-r9 sparc64; 166x52) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Linux 2.6.26-1-amd64) Lobo/0.98.3 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows XP 5.1) Lobo/0.98.4 - 0 Mozilla/4.0 (compatible; Lotus-Notes/5.0; Windows-NT) - 0 Mozilla/4.0 (compatible; Lotus-Notes/6.0; Windows-NT) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; Lunascape 2.1.3) -mozilla 1.9.1b3pre Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3pre) Gecko/2008 Lunascape/4.9.9.98 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; JyxoToolbar1.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Lunascape 5.1.4.5) -webkit 528 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/528+ (KHTML, like Gecko, Safari/528.0) Lunascape/5.0.2.0 -mozilla 1.9.1.2 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090804 Firefox/3.5.2 Lunascape/5.1.4.5 - 0 Lynx/2.8.6rel.4 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.6.3 - 0 Lynx/2.8.3dev.6 libwww-FM/2.14 - 0 Lynx/2.8.5dev.16 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7a -mozilla 1.7.12 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20051001 Firefox/1.0.7 Madfox/0.3.2u3 -webkit 530.6 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.6 (KHTML, like Gecko) Maxthon/3.0 Safari/530.6 -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MyIE2) -msie 8.0 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; MAXTHON 2.0) - 0 Midori/0.1.7 -webkit 532 Midori/0.1.5 (X11; Linux; U; en-gb) WebKit/532+ -mozilla 1.0.1 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020919 -mozilla 1.7.12 Mozilla/5.0 (Windows; U; Windows NT 5.0; it-IT; rv:1.7.12) Gecko/20050915 -mozilla 1.4 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4; MultiZilla v1.5.0.0f) Gecko/20030624 -mozilla 1.2.1 Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1; MultiZilla v1.1.32 final) Gecko/20021130 - 0 NCSA_Mosaic/2.0 (Windows 3.1) - 0 NCSA_Mosaic/3.0 (Windows 95) - 0 NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m) - 0 NCSA_Mosaic/2.6 (X11; SunOS 4.1.3 sun4m) - 0 Mozilla/3.01 (compatible; Netbox/3.5 R92; Linux 2.2) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; NetCaptor 7.5.4; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -msie 5.01 Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; NetCaptor 6.5.0RC1) -mozilla 1.7.5 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20060127 Netscape/8.1 -mozilla 0 Mozilla/4.04 [en] (X11; I; IRIX 5.3 IP22) -mozilla 0.9.2 Mozilla/5.0 (Windows; U; Win 9x 4.90; de-DE; rv:0.9.2) Gecko/20010726 Netscape6/6.1 -mozilla 1.8.1.12 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6 -mozilla 0 Mozilla/4.08 [en] (WinNT; U ;Nav) -mozilla 1.0.2 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 -mozilla 0 Mozilla/3.0 (Win95; I) -mozilla 0 Mozilla/4.51 [en] (Win98; U) - 0 NetSurf/2.0 (RISC OS; armv3l) - 0 NetSurf/1.2 (Linux; i686) - 0 Mozilla/4.7 (compatible; OffByOne; Windows 2000) - 0 Mozilla/4.7 (compatible; OffByOne; Windows 98) - 0 Mozilla/4.5 (compatible; OmniWeb/4.1.1-v424.6; Mac_PowerPC) - 0 OmniWeb/2.7-beta-3 OWF/1.0 -webkit 420 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ (KHTML, like Gecko, Safari) OmniWeb/v595 -opera 6.0 Opera/6.0 (Windows 2000; U) [fr] -opera 7.10 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.10 [en] -opera 10.00 Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.2.15 Version/10.00 -opera 5.11 Opera/5.11 (Windows 98; U) [en] -opera 9.51 Opera/9.51 (Macintosh; Intel Mac OS X; U; en) -opera 6.01 Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0) Opera 6.01 [en] -opera 9.02 Opera/9.02 (Windows XP; U; ru) -opera 5.12 Mozilla/4.0 (compatible; MSIE 5.0; Windows 98) Opera 5.12 [en] -opera 9.70 Opera/9.70 (Linux i686 ; U; en) Presto/2.2.1 -opera 7.03 Opera/7.03 (Windows NT 5.0; U) [en] -opera 9.24 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.24 -mozilla 1.9.0.7 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009030821 Firefox/3.0.7 Orca/1.1 build 2 -mozilla 1.9.0.6 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009022300 Firefox/3.0.6 Orca/1.1 build 1 - 0 Mozilla/1.10 [en] (Compatible; RISC OS 3.70; Oregano 1.10) -webkit 530.0 Mozilla/5.0 (compatible; Origyn Web Browser; AmigaOS 4.1; ppc; U; en) AppleWebKit/530.0+ (KHTML, like Gecko, Safari/530.0+) -webkit 531.0 Mozilla/5.0 (compatible; Origyn Web Browser; AmigaOS 4.0; U; en) AppleWebKit/531.0+ (KHTML, like Gecko, Safari/531.0+) -webkit 528.5 Mozilla/5.0 (compatible; Origyn Web Browser; MorphOS; PPC; U) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; PhaseOut-www.phaseout.net) -mozilla 1.4a Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4a) Gecko/20030411 Phoenix/0.5 -mozilla 1.2b Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021029 Phoenix/0.4 -webkit 527 Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/527+ (KHTML, like Gecko) QtWeb Internet Browser/2.5 http://www.QtWeb.net -webkit 527 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/527+ (KHTML, like Gecko) QtWeb Internet Browser/1.2 http://www.QtWeb.net -webkit 527 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/527+ (KHTML, like Gecko) QtWeb Internet Browser/1.7 http://www.QtWeb.net -webkit 527 Mozilla/5.0 (X11; U; Linux; cs-CZ) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) rekonq - 0 retawq/0.2.6c [en] (text) -webkit 312.8 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.6 -webkit 528.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_6; it-it) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16 -webkit 523.15 Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/523.15 (KHTML, like Gecko) Version/3.0 Safari/523.15 -webkit 125.2 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.7 -webkit 528.16 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16 -webkit 420 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; fi-fi) AppleWebKit/420+ (KHTML, like Gecko) Safari/419.3 -mozilla 1.8.1.13 Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 SeaMonkey/1.1.9 -mozilla 1.9.1a2pre Mozilla/5.0 (X11; U; Linux i686; rv:1.9.1a2pre) Gecko/20080824052448 SeaMonkey/2.0a1pre -mozilla 1.8.1.6 Mozilla/5.0 (Windows; U; Win 9x 4.90; en-GB; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 -mozilla 1.9.1b3pre Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1b3pre) Gecko/20081208 SeaMonkey/2.0a3pre -mozilla 1.9a1 Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.9a1) Gecko/20060702 SeaMonkey/1.5a -mozilla 1.9.1b3pre Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081202 SeaMonkey/2.0a2 -webkit 419 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; ja-jp) AppleWebKit/419 (KHTML, like Gecko) Shiira/1.2.3 Safari/125 -webkit 417.9 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko, Safari) Shiira/1.1 -webkit 418.9.1 Mozilla/5.0 (Macintosh; U; Intel Mac OS X; fr) AppleWebKit/418.9.1 (KHTML, like Gecko) Shiira Safari/125 -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Sleipnir/2.8.1 -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727) Sleipnir/2.8.4 -webkit 525.27.1 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Stainless/0.4 Safari/525.20.1 -webkit 528.16 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/528.16 (KHTML, like Gecko) Stainless/0.5.3 Safari/525.20.1 -webkit 525.18 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Sunrise/1.7.4 like Safari/4525.22 -webkit 125.5.7 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/125.5.7 (KHTML, like Gecko) SunriseBrowser/0.853 -mozilla 1.9.0.10pre Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10pre) Gecko/2009041814 Firefox/3.0.10pre (Swiftfox) -msie 6.0 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; TheWorld) -webkit 1.1.8 Webkit/1.1.8 (Linux; en-us) Uzbl -webkit 1.1.10 Uzbl (X11; U; Linux x86_64; en-GB) AppleWebkit/1.1.10 -webkit 1.1.9 Uzbl (Webkit 1.1.9) (Linux) -webkit 1.1.10 Uzbl (U; Linux x86_64; en-GB) Webkit 1.1.10 - 0 w3m/0.5.1 - 0 w3m/0.5.2 -webkit 103u Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/103u (KHTML, like Gecko) wKiosk/100 -mozilla 1.9.0.9 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.9) Gecko/2009042410 Firefox/3.0.9 Wyzo/3.0.3 - 0 X-Smiles/1.2-20081113 -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; MEGAUPLOAD 2.0) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30) -mozilla 1.9.0.4 Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.4) Gecko/2008111217 Fedora/3.0.4-1.fc9 Firefox/3.0.4 -mozilla 1.9.0.4 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4 -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; FDM) -msie 6.0 mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; mra 4.6 (build 01425); .net clr 2.0.50727) -msie 7.0 mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; mra 4.9 (build 01863)) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath?.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; MS-RTC LM 8; .NET CLR 1.1.4322) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; InfoPath?.2; .NET CLR 3.5.21022) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Sky Broadband; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; MS-RTC LM 8; .NET CLR 1.1.4322) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; InfoPath.2; .NET CLR 3.5.21022) -msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB6; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com); .NET CLR 1.1.4322; .NET CLR 2.0.50727 -opera 10.00 Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00 -msie 8.0 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; InfoPath?.2; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) -opera 10.00 Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.2.15 Version/10.00 -opera 10.50 Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.5.18 Version/10.50 diff --git a/test/data/with_fries.xml b/test/data/with_fries.xml deleted file mode 100644 index dc42ddfc4..000000000 --- a/test/data/with_fries.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - 1 - - - - - foo - - - - - - - diff --git a/test/data/with_fries_over_jsonp.php b/test/data/with_fries_over_jsonp.php deleted file mode 100644 index 456aeb3bd..000000000 --- a/test/data/with_fries_over_jsonp.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/test/localfile.html b/test/localfile.html index 7d49c44e1..faf34091c 100644 --- a/test/localfile.html +++ b/test/localfile.html @@ -51,7 +51,7 @@ function doLog( message, args ) { jQuery( "
  • ").appendTo( logUL ).text( message + ': "' + Array.prototype.join.call( args, '" - "' ) + '"' ); } - jQuery.ajax( "./data/badjson.js" , { + jQuery.ajax( "data/ajax/echo/index.php", { context: jQuery( "#success" ), dataType: "text" }).success(function( data, _, xhr ) { @@ -61,7 +61,7 @@ doLog( "Success (" + xhr.status + ")" , arguments ); this.addClass( "error" ).text( "FAIL" ); }); - jQuery.ajax( "./data/doesnotexist.ext" , { + jQuery.ajax( "error" , { context: jQuery( "#error" ), dataType: "text" }).error(function( xhr ) { diff --git a/test/unit/ajax.js b/test/unit/ajax.js index f88b5d7cc..91c1c93c0 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -30,9 +30,40 @@ module( "ajax", { //----------- jQuery.ajax() - ajaxTest( "jQuery.ajax() - success callbacks", 8, { + ajaxTest( "jQuery.ajax() - GET", 1, { + type: "GET", + url: service("echo"), + data: { + content: "bar" + }, + success: function( msg ) { + strictEqual( msg, "bar", "Check for GET" ); + } + }); + + ajaxTest( "jQuery.ajax() - POST", 1, { + type: "POST", + url: service("echo/"), + data: { + content: "pan" + }, + success: function( msg ) { + strictEqual( msg, "pan", "Check for POST" ); + } + }); + + ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, { + type: "POST", + url: service("echo/"), + data: undefined, + success: function( result ) { + strictEqual( result, "", "no data given" ); + } + }); + + ajaxTest( "jQuery.ajax() - success", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: url("data/name.html"), + url: service("echo"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -44,10 +75,10 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, { + ajaxTest( "jQuery.ajax() - success - (url, options)", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), create: function( options ) { - return jQuery.ajax( url("data/name.html"), options ); + return jQuery.ajax( service("echo"), options ); }, beforeSend: function() { ok( true, "beforeSend" ); @@ -60,9 +91,9 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, { + ajaxTest( "jQuery.ajax() - success - late binding", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: url("data/name.html"), + url: service("echo"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -78,9 +109,9 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, { + ajaxTest( "jQuery.ajax() - success - oncomplete binding", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: url("data/name.html"), + url: service("echo"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -96,15 +127,12 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - error callbacks", 8, { + ajaxTest( "jQuery.ajax() - error", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"), - url: url("data/name.php?wait=5"), + url: service("error"), beforeSend: function() { ok( true, "beforeSend" ); }, - afterSend: function( request ) { - request.abort(); - }, error: function() { ok( true, "error" ); }, @@ -113,9 +141,12 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, [ + ajaxTest( "jQuery.ajax() - abort - textStatus and errorThrown values", 4, [ { - url: url("data/name.php?wait=5"), + url: service("echo"), + data: { + delay: 1 + }, error: function( _, textStatus, errorThrown ) { strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" ); strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" ); @@ -125,7 +156,10 @@ module( "ajax", { } }, { - url: url("data/name.php?wait=5"), + url: service("echo"), + data: { + delay: 1 + }, error: function( _, textStatus, errorThrown ) { strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" ); strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" ); @@ -136,8 +170,12 @@ module( "ajax", { } ]); - ajaxTest( "jQuery.ajax() - responseText on error", 1, { - url: url("data/errorWithText.php"), + ajaxTest( "jQuery.ajax() - error - responseText", 1, { + url: service("echo"), + data: { + status: 400, + content: "plain text message" + }, error: function( xhr ) { strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" ); } @@ -147,7 +185,7 @@ module( "ajax", { var previousUrl, firstTime = true; jQuery.ajax({ - url: url("data/errorWithText.php"), + url: service("error"), error: function() { if ( firstTime ) { firstTime = false; @@ -155,7 +193,7 @@ module( "ajax", { } else { ok ( true, "Test retrying with jQuery.ajax(this) works" ); jQuery.ajax({ - url: url("data/errorWithText.php"), + url: service("error"), data: { "x": 1 }, @@ -177,13 +215,16 @@ module( "ajax", { }); }); - ajaxTest( "jQuery.ajax() - headers", 4, { + ajaxTest( "jQuery.ajax() - headers - request", 1, { setup: function() { jQuery( document ).ajaxSend(function( evt, xhr ) { xhr.setRequestHeader( "ajax-send", "test" ); }); }, - url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax-send"), + url: service("headers/request"), + data: { + headers: "siMPle,SometHing-elsE,OthEr,ajax-send" + }, headers: { "siMPle": "value", "SometHing-elsE": "other value", @@ -201,20 +242,39 @@ module( "ajax", { tmp = tmp.join(""); strictEqual( data, tmp, "Headers were sent" ); - strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" ); - - emptyHeader = xhr.getResponseHeader("Empty-Header"); + } + }); + + ajaxTest( "jQuery.ajax() - headers - response", 3, { + setup: function() { + jQuery( document ).ajaxSend(function( evt, xhr ) { + xhr.setRequestHeader( "ajax-send", "test" ); + }); + }, + url: service("headers/response"), + data: { + "Sample-Header": "sample value", + "Sample-Header2": "sample value 2", + "Empty-Header": "" + }, + success: function( data, _, xhr ) { + var emptyHeader = xhr.getResponseHeader("Empty-Header"); if ( emptyHeader === null ) { ok( true, "Firefox doesn't support empty headers" ); } else { strictEqual( emptyHeader, "", "Empty header received" ); } - strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" ); + strictEqual( xhr.getResponseHeader("Sample-Header"), "sample value", "Sample header received" ); + strictEqual( xhr.getResponseHeader("Sample-Header2"), "sample value 2", "Second sample header received" ); + } }); - ajaxTest( "jQuery.ajax() - Accept header", 1, { - url: url("data/headers.php?keys=accept"), + ajaxTest( "jQuery.ajax() - headers - Accept", 1, { + url: service("headers/request"), + data: { + headers: "accept" + }, headers: { Accept: "very wrong accept value" }, @@ -226,16 +286,22 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - contentType", 2, [ + ajaxTest( "jQuery.ajax() - headers - contentType option", 2, [ { - url: url("data/headers.php?keys=content-type"), + url: service("headers/request"), + data: { + headers: "content-type" + }, contentType: "test", success: function( data ) { - strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); + ok( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); } }, { - url: url("data/headers.php?keys=content-type"), + url: service("headers/request"), + data: { + headers: "content-type" + }, contentType: false, success: function( data ) { strictEqual( data, "content-type: \n", "Test content-type is not sent when options.contentType===false" ); @@ -243,7 +309,7 @@ module( "ajax", { } ]); - ajaxTest( "jQuery.ajax() - protocol-less urls", 1, { + ajaxTest( "jQuery.ajax() - url - protocol-less", 1, { url: "//somedomain.com", beforeSend: function( xhr, settings ) { equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." ); @@ -252,37 +318,37 @@ module( "ajax", { error: true }); - ajaxTest( "jQuery.ajax() - hash", 3, [ + ajaxTest( "jQuery.ajax() - url - hash", 3, [ { - url: "data/name.html#foo", + url: "path/to/service#foo", beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." ); + strictEqual( settings.url, "path/to/service", "Make sure that the URL is trimmed." ); return false; }, error: true }, { - url: "data/name.html?abc#foo", + url: "path/to/service?abc#foo", beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." ); + strictEqual( settings.url, "path/to/service?abc", "Make sure that the URL is trimmed." ); return false; }, error: true }, { - url: "data/name.html?abc#foo", + url: "path/to/service?abc#foo", data: { "test": 123 }, beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." ); + equal( settings.url, "path/to/service?abc&test=123", "Make sure that the URL is trimmed." ); return false; }, error: true } ]); - ajaxTest( "jQuery.ajax() - cross-domain detection", 7, function() { + ajaxTest( "jQuery.ajax() - url - cross-domain detection", 7, function() { function request( url, title, crossDomainOrOptions ) { return jQuery.extend( { dataType: "jsonp", @@ -338,7 +404,10 @@ module( "ajax", { ajaxTest( "jQuery.ajax() - abort", 9, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete"), - url: url("data/name.php?wait=5"), + url: service("echo"), + data: { + delay: 1 + }, beforeSend: function() { ok( true, "beforeSend" ); }, @@ -353,37 +422,42 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - events with context", 12, function() { + ajaxTest( "jQuery.ajax() - context", 12, function() { - var context = document.createElement("div"); + var context; function event( e ) { - equal( this, context, e.type ); + strictEqual( this, context, e.type ); } function callback( msg ) { return function() { - equal( this, context, "context is preserved on callback " + msg ); + strictEqual( this, context, "context is preserved on callback " + msg ); }; } return { setup: function() { - jQuery( context ).appendTo("#foo") - .ajaxSend( event ) - .ajaxComplete( event ) - .ajaxError( event ) - .ajaxSuccess( event ); + var target = jQuery("#foo").on( "ajaxSend ajaxComplete ajaxError ajaxSuccess", event ); + context = target[ 0 ]; + jQuery.each( this.requests, function( _, options ) { + options.context = context; + }); + }, + teardown: function() { + // Let everything fire properly + setTimeout(function() { + jQuery("#foo").off("ajaxSend ajaxComplete ajaxError ajaxSuccess"); + start(); + }, 0 ); }, requests: [{ - url: url("data/name.html"), - context: context, + url: service("echo"), beforeSend: callback("beforeSend"), success: callback("success"), complete: callback("complete") }, { - url: url("data/404.html"), - context: context, + url: service("error"), beforeSend: callback("beforeSend"), error: callback("error"), complete: callback("complete") @@ -391,22 +465,22 @@ module( "ajax", { }; }); - ajaxTest( "jQuery.ajax() - events without context", 3, function() { + ajaxTest( "jQuery.ajax() - context - none", 3, function() { function nocallback( msg ) { return function() { - equal( typeof this.url, "string", "context is settings on callback " + msg ); + strictEqual( typeof this.url, "string", "context is settings on callback " + msg ); }; } return { - url: url("data/404.html"), + url: service("error"), beforeSend: nocallback("beforeSend"), error: nocallback("error"), complete: nocallback("complete") }; }); - ajaxTest( "jQuery.ajax() - context modification", 1, { - url: url("data/name.html"), + ajaxTest( "jQuery.ajax() - context - modification", 1, { + url: service("error"), context: {}, beforeSend: function() { this.test = "foo"; @@ -414,10 +488,10 @@ module( "ajax", { afterSend: function() { strictEqual( this.context.test, "foo", "Make sure the original object is maintained." ); }, - success: true + error: true }); - ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function() { + ajaxTest( "jQuery.ajax() - context - ajaxSetup", 3, function() { var obj = {}; return { setup: function() { @@ -427,24 +501,24 @@ module( "ajax", { strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); }, requests: [{ - url: url("data/name.html"), - success: function() { + url: service("error"), + error: function() { strictEqual( this, obj, "Make sure the original object is maintained." ); } }, { - url: url("data/name.html"), + url: service("error"), context: {}, - success: function() { + error: function() { ok( this !== obj, "Make sure overidding context is possible." ); } }] }; }); - ajaxTest( "jQuery.ajax() - disabled globals", 3, { + ajaxTest( "jQuery.ajax() - events - disable", 3, { setup: addGlobalEvents(""), global: false, - url: url("data/name.html"), + url: service("echo"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -456,52 +530,69 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, { - url: url("data/with_fries.xml"), - dataType: "xml", + ajaxTest( "jQuery.ajax() - xml - non-namespace elements inside namespaced elements", 3, { + url: service("echo"), + data: { + contentType: "text/xml", + content: createWithFriesXML( true ) + }, success: function( resp ) { - equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); - equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); - equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + strictEqual( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + strictEqual( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + strictEqual( jQuery( "thing", resp ).length, 2, "things in responseXML" ); } }); - ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, { - url: url("data/with_fries_over_jsonp.php"), + ajaxTest( "jQuery.ajax() - xml - non-namespace elements inside namespaced elements (over JSONP)", 3, { + url: service("echo"), + data: { + content: createWithFriesXML( true ) + }, dataType: "jsonp xml", success: function( resp ) { - equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); - equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); - equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + strictEqual( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + strictEqual( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + strictEqual( jQuery( "thing", resp ).length, 2, "things in responseXML" ); } }); - ajaxTest( "jQuery.ajax() - HEAD requests", 2, [ - { - url: url("data/name.html"), - type: "HEAD", - success: function( data, status, xhr ) { - ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response" ); - } + ajaxTest( "jQuery.ajax() - atom+xml", 2, { + url: service("echo"), + data: { + content: "", + contentType: "atom+xml" }, - { - url: url("data/name.html"), - data: { - "whip_it": "good" - }, - type: "HEAD", - success: function( data, status, xhr ) { - ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response with data" ); - } + success: function( xml ) { + strictEqual( jQuery( "root", xml ).length, 1, "root in responseXML" ); + strictEqual( jQuery( "element", xml ).length, 1, "element in responseXML" ); } - ]); + }); + + ajaxTest( "jQuery.ajax() - HEAD requests", 2, function() { + function request( method ) { + return { + url: service("echo/"), + data: { + content: "head request" + }, + type: method, + success: function( data, status, xhr ) { + strictEqual( data, method === "HEAD" ? "" : "head request", "Content (" + method + ")" ); + } + }; + } + return [ + request("HEAD"), + request("GET") + ]; + }); ajaxTest( "jQuery.ajax() - beforeSend", 1, { - url: url("data/name.html"), + url: service("error"), beforeSend: function( xml ) { this.check = true; }, - success: function( data ) { + error: function( data ) { ok( this.check, "check beforeSend was executed" ); } }); @@ -509,7 +600,7 @@ module( "ajax", { ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, { create: function() { return jQuery.ajax({ - url: url("data/name.html"), + url: service("error"), beforeSend: function( xhr ) { ok( true, "beforeSend got called, canceling" ); xhr.abort(); @@ -530,13 +621,16 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - dataType html", 5, { + ajaxTest( "jQuery.ajax() - html", 5, { setup: function() { Globals.register("testFoo"); Globals.register("testBar"); }, dataType: "html", - url: url("data/test.html"), + url: service("echo"), + data: { + content: createComplexHTML() + }, success: function( data ) { ok( data.match( /^html text/ ), "Check content for datatype html" ); jQuery("#ap").html( data ); @@ -546,17 +640,23 @@ module( "ajax", { }); ajaxTest( "jQuery.ajax() - synchronous request", 1, { - url: url("data/json_obj.js"), + url: service("echo"), + data: { + content: "hello world" + }, dataType: "text", async: false, success: true, afterSend: function( xhr ) { - ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" ); + strictEqual( xhr.responseText, "hello world", "check returned text" ); } }); - ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, { - url: url("data/json_obj.js"), + ajaxTest( "jQuery.ajax() - synchronous request - callbacks", 2, { + url: service("echo"), + data: { + content: "hello world" + }, async: false, dataType: "text", success: true, @@ -566,36 +666,33 @@ module( "ajax", { ok( true, "success callback executed" ); result = data; }); - ok( /^\{ "data"/.test( result ), "check returned text" ); + strictEqual( result, "hello world", "check returned text" ); } }); - asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function() { - var target = "data/name.html"; - var successCount = 0; - var errorCount = 0; - var errorEx = ""; - var success = function() { + asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 7, function() { + var successCount = 0, + errorCount = 0, + errorEx = []; + function success() { successCount++; - }; - jQuery( document ).on( "ajaxError.passthru", function( e, xml, s, ex ) { + } + jQuery( document ).ajaxError(function( e, xhr, s, ex ) { errorCount++; - errorEx += ": " + xml.status; + errorEx.push( s.dataType + " / " + xhr.status + " / " + ex + " " ); }); - jQuery( document ).one( "ajaxStop", function() { - equal( successCount, 5, "Check all ajax calls successful" ); - equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" ); - jQuery( document ).off("ajaxError.passthru"); + jQuery( document ).ajaxStop(function() { + strictEqual( successCount, 5, "Check all ajax calls successful" ); + strictEqual( errorCount, 0, "Check no ajax errors ( " + errorEx.join() + ")" ); start(); }); - Globals.register("testBar"); - ok( jQuery.get( url(target), success ), "get" ); - ok( jQuery.post( url(target), success ), "post" ); - ok( jQuery.getScript( url("data/test.js"), success ), "script" ); - ok( jQuery.getJSON( url("data/json_obj.js"), success ), "json" ); + ok( jQuery.get( service("echo"), success ), "get" ); + ok( jQuery.post( service("echo"), success ), "post" ); + ok( jQuery.getScript( service("echo"), success ), "script" ); + ok( jQuery.getJSON( service("echo?content=0"), success ), "json" ); ok( jQuery.ajax({ - url: url( target ), + url: service("echo"), success: success }), "generic" ); }); @@ -623,256 +720,219 @@ module( "ajax", { return [ request( - "data/text.php", + "path/to/service", "no parameter" ), request( - "data/text.php?pizza=true", + "path/to/service?pizza=true", "1 parameter" ), request( - "data/text.php?_=tobereplaced555", + "path/to/service?_=tobereplaced555", "_= parameter" ), request( - "data/text.php?pizza=true&_=tobereplaced555", + "path/to/service?pizza=true&_=tobereplaced555", "1 parameter and _=" ), request( - "data/text.php?_=tobereplaced555&tv=false", + "path/to/service?_=tobereplaced555&tv=false", "_= and 1 parameter" ), request( - "data/text.php?name=David&_=tobereplaced555&washere=true", + "path/to/service?name=David&_=tobereplaced555&washere=true", "2 parameters surrounding _=" ) ]; }); jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { + + function request( options ) { + var tmp = jQuery.extend( true, { + data: { + content: "041275" + }, + dataType: "jsonp", + crossDomain: crossDomain, + success: !options.fail && !options.error && function( data ) { + strictEqual( data, "041275", "JSON results returned - " + this.type + " - " + options.title ); + } + }, options ); + tmp.url = service( "echo" + ( options.url || "" ) ); + return tmp; + } ajaxTest( "jQuery.ajax() - JSONP - Query String (?n)" + label, 4, [ - { - url: "data/jsonp.php?callback=?", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, url callback)" ); - } - }, - { - url: "data/jsonp.php?callback=??", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, url context-free callback)" ); - } - }, - { - url: "data/jsonp.php/??", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, REST-like)" ); - } - }, - { - url: "data/jsonp.php/???json=1", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - strictEqual( jQuery.type( data ), "array", "JSON results returned (GET, REST-like with param)" ); + request({ + title: "URL Callback", + url: "?callback=?" + }), + request({ + title: "URL Context-Free Callback", + url: "?callback=??" + }), + request({ + title: "REST-like", + url: "/index.php/??" + }), + request({ + title: "REST-like (with param)", + url: "/index.php/???content=\"041275\"", + beforeSend: function() { + delete this.data; } - } + }) ]); - ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 9, { + ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 8, { setup: function() { Globals.register("functionToCleanUp"); + Globals.register("functionToCleanUpAfterEarlyAbort"); Globals.register("XXX"); Globals.register("jsonpResults"); window["jsonpResults"] = function( data ) { - ok( data["data"], "JSON results returned (GET, custom callback function)" ); + strictEqual( data, "041275", "JSON results returned - GET - custom callback function" ); }; }, - requests: [{ - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonp: "callback", - success: function( data ) { - ok( data["data"], "JSON results returned (GET, data obj callback)" ); - } - }, { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonpCallback: "jsonpResults", - success: function( data ) { - ok( data.data, "JSON results returned (GET, custom callback name)" ); - } - }, { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonpCallback: "functionToCleanUp", - success: function( data ) { - ok( data["data"], "JSON results returned (GET, custom callback name to be cleaned up)" ); - strictEqual( window["functionToCleanUp"], undefined, "Callback was removed (GET, custom callback name to be cleaned up)" ); - var xhr; - jQuery.ajax({ - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonpCallback: "functionToCleanUp", - beforeSend: function( jqXHR ) { - xhr = jqXHR; - return false; - } - }); - xhr.fail(function() { - ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" ); - strictEqual( window["functionToCleanUp"], undefined, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" ); - }); - } - }, { - url: "data/jsonp.php?callback=XXX", - dataType: "jsonp", - jsonp: false, - jsonpCallback: "XXX", - crossDomain: crossDomain, - beforeSend: function() { - ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" ); - }, - success: function( data ) { - ok( data["data"], "JSON results returned (GET, custom callback name with no url manipulation)" ); - } - }] + requests: [ + request({ + title: "jsonp option", + jsonp: "callback" + }), + request({ + title: "jsonpCallback option", + jsonpCallback: "jsonpResults" + }), + request({ + title: "no URL manipulation", + url: "/index.php/XXX", + jsonp: false, + jsonpCallback: "XXX", + beforeSend: function() { + ok( /\/XXX\?\d+&content=041275&_=\d+$/.test( this.url ), "The URL wasn't messed with" ); + } + }), + request({ + title: "jsonpCallback option - cleanup", + jsonpCallback: "functionToCleanUp", + done: function( data ) { + strictEqual( window["functionToCleanUp"], undefined, "Callback was removed" ); + } + }), + request({ + title: "jsonpCallback option - cleanup after early abort", + jsonpCallback: "functionToCleanUpAfterEarlyAbort", + beforeSend: function() { + return false; + }, + fail: function() { + strictEqual( window["functionToCleanUpAfterEarlyAbort"], undefined, "Callback was removed after early abort" ); + } + }) + ] }); ajaxTest( "jQuery.ajax() - JSONP - Callback in data" + label, 2, [ - { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - data: "callback=?", - success: function( data ) { - ok( data.data, "JSON results returned (GET, data callback)" ); - } - }, - { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - data: "callback=??", - success: function( data ) { - ok( data.data, "JSON results returned (GET, data context-free callback)" ); - } - } + request({ + title: "data callback", + data: "content=041275&callback=?" + }), + request({ + title: "data context-free callback", + data: "content=041275&callback=??" + }) ]); ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [ - { + request({ + title: "no callback", type: "POST", - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data["data"], "JSON results returned (POST, no callback)" ); - } - }, - { + url: "/" + }), + request({ + title: "data callback", type: "POST", - url: "data/jsonp.php", - data: "callback=?", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data["data"], "JSON results returned (POST, data callback)" ); - } - }, - { + url: "/", + data: "content=041275&callback=?" + }), + request({ + title: "data obj callback", type: "POST", - url: "data/jsonp.php", - jsonp: "callback", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data["data"], "JSON results returned (POST, data obj callback)" ); - } - } + url: "/", + jsonp: "callback" + }) ]); ajaxTest( "jQuery.ajax() - JSONP" + label, 3, [ - { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, no callback)" ); - } - }, - { + request({ + title: "no callback" + }), + request({ + title: "no callback and re-use", create: function( options ) { var request = jQuery.ajax( options ), promise = request.then(function( data ) { - ok( data.data, "first request: JSON results returned (GET, no callback)" ); - request = jQuery.ajax( this ).done(function( data ) { - ok( data.data, "this re-used: JSON results returned (GET, no callback)" ); - }); + request = jQuery.ajax( this ); promise.abort = request.abort; return request; }); promise.abort = request.abort; return promise; - }, - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - success: true - } + } + }) ]); }); + + jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { + + jQuery.each( [ "GET", "POST" ], function( _, type ) { + + ajaxTest( "jQuery.ajax() - script - " + type + label, 3, { + setup: function() { + Globals.register("testBar"); + }, + type: type, + crossDomain: crossDomain, + url: service("echo/"), + data: { + content: "var testBar = true; ok( true, 'script executed' );" + }, + dataType: "script", + success: function( data, status ) { + strictEqual( window.testBar, true, "Variable declared and set" ); + strictEqual( status, "success", "Script results returned" ); + } + }); + + jQuery.each( "text/javascript application/javascript application/ecmascript application/x-ecmascript".split(" "), function( _, contentType ) { + ajaxTest( "jQuery.ajax() - script - " + type + label + " - auto-detected content-type - " + contentType, 2, { + converters: { + "text script": function( text ) { + strictEqual( text, "", "content-type detected" ); + } + }, + url: service("headers/response/"), + data: { + "Content-Type": contentType + }, + success: function() { + ok( true, "success" ); + } + }); + }); - ajaxTest( "jQuery.ajax() - script, Remote", 2, { - setup: function() { - Globals.register("testBar"); - }, - url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js", - dataType: "script", - success: function( data ) { - strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" ); - } - }); - - ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, { - setup: function() { - Globals.register("testBar"); - }, - url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js", - type: "POST", - dataType: "script", - success: function( data, status ) { - strictEqual( window["testBar"], "bar", "Script results returned (POST, no callback)" ); - strictEqual( status, "success", "Script results returned (POST, no callback)" ); - } - }); - - ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, { - setup: function() { - Globals.register("testBar"); - }, - url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/test.js", - dataType: "script", - success: function( data ) { - strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" ); - } + }); + }); ajaxTest( "jQuery.ajax() - malformed JSON", 2, { - url: "data/badjson.js", + url: service("echo"), + data: { + content: "{bad: toTheBone}" + }, dataType: "json", error: function( xhr, msg, detailedMsg ) { strictEqual( msg, "parsererror", "A parse error occurred." ); @@ -880,186 +940,85 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - script by content-type", 2, [ - { - url: "data/script.php", - data: { - "header": "script" - }, - success: true + ajaxTest( "jQuery.ajax() - JSON - content-type", 2, { + converters: { + "text json": function( text ) { + strictEqual( text, "", "content-type detected" ); + return 42; + } }, - { - url: "data/script.php", - data: { - "header": "ecma" - }, - success: true - } - ]); - - ajaxTest( "jQuery.ajax() - JSON by content-type", 5, { - url: "data/json.php", + url: service("headers/response/index.php"), data: { - "header": "json", - "json": "array" + "Content-Type": "application/json" }, success: function( json ) { - ok( json.length >= 2, "Check length" ); - strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); + strictEqual( json, 42, "success" ); } }); - ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, { - url: url("data/json.php"), + ajaxTest( "jQuery.ajax() - JSON - content-type disabled", 1, { + converters: { + "text json": function() { + ok( false, "content-type detected" ); + } + }, + url: service("headers/response/index.php"), data: { - "header": "json", - "json": "array" + "Content-Type": "application/json" }, contents: { - "json": false + json: false }, - success: function( text ) { - strictEqual( typeof text, "string", "json wasn't auto-determined" ); - var json = jQuery.parseJSON( text ); - ok( json.length >= 2, "Check length"); - strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); - } - }); - - ajaxTest( "jQuery.ajax() - simple get", 1, { - type: "GET", - url: url("data/name.php?name=foo"), - success: function( msg ) { - strictEqual( msg, "bar", "Check for GET" ); - } - }); - - ajaxTest( "jQuery.ajax() - simple post", 1, { - type: "POST", - url: url("data/name.php"), - data: "name=peter", - success: function( msg ) { - strictEqual( msg, "pan", "Check for POST" ); + success: function() { + ok( true, "success" ); } }); - ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, { - url: "data/echoData.php", - data: undefined, - type: "post", - success: function( result ) { - strictEqual( result, "" ); + ajaxTest( "jQuery.ajax() - JSON - empty", 1, { + url: service("echo"), + dataType: "json", + error: function( _, __, error ) { + strictEqual( typeof error, "object", "error object for empty json response" ); } }); var ifModifiedNow = new Date(); - jQuery.each( - /* jQuery.each arguments start */ - { - " (cache)": true, - " (no cache)": false - }, - function( label, cache ) { - var isOpera = !!window.opera; - - asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() { - var url = "data/if_modified_since.php?ts=" + ifModifiedNow++; - - jQuery.ajax({ + jQuery.each( [ " - no cache", " - cache" ], function( cache, label ) { + jQuery.each( [ "If-Modified-Since", "If-None-Match" ], function( _, header ) { + var isOpera = !!window.opera, + url = service("headers/cache/"), + value = ifModifiedNow++; + function request() { + return jQuery.ajax({ url: url, - ifModified: true, - cache: cache, - success: function( data, status ) { - strictEqual( status, "success" ); - - jQuery.ajax({ - url: url, - ifModified: true, - cache: cache, - success: function( data, status ) { - if ( data === "FAIL" ) { - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." ); - } else { - strictEqual( status, "notmodified" ); - ok( data == null, "response body should be empty" ); - } - start(); - }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - ok( isOpera, "error" ); - start(); - } - }); + data: { + header: header, + value: value }, - error: function() { - strictEqual( false, "error" ); - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - start(); - } - }); - }); - - asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() { - var url = "data/etag.php?ts=" + ifModifiedNow++; - - jQuery.ajax({ - url: url, ifModified: true, - cache: cache, - success: function( data, status ) { - strictEqual( status, "success" ); - - jQuery.ajax({ - url: url, - ifModified: true, - cache: cache, - success: function( data, status ) { - if ( data === "FAIL" ) { - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); - ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." ); - } else { - strictEqual( status, "notmodified" ); - ok( data == null, "response body should be empty" ); - } - start(); - }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - ok( isOpera, "error" ); - start(); - } - }); - }, - error: function() { - // Do this because opera simply refuses to implement 304 handling :( - // A feature-driven way of detecting this would be appreciated - // See: http://gist.github.com/599419 - ok( isOpera, "error" ); - start(); - } + cache: !!cache }); + } + asyncTest( "jQuery.ajax() - " + header + label, 3, function() { + request().then(function( data, status ) { + strictEqual( status, "success" ); + return request(); + }).done(function( data, status ) { + if ( data === "FAIL" ) { + ok( isOpera, "Opera is incapable of doing .setRequestHeader('" + header + "')." ); + ok( isOpera, "Opera is incapable of doing .setRequestHeader('" + header + "')." ); + } else { + strictEqual( status, "notmodified" ); + ok( data == null, "response body should be empty" ); + } + }).fail(function() { + ok( isOpera, "Opera cannot handle 304" ); + ok( isOpera, "Opera cannot handle 304" ); + }).always( start ); }); - } - /* jQuery.each arguments end */ - ); + }); + }); ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, { // see RFC 2606 @@ -1076,192 +1035,121 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - atom+xml", 1, { - url: url("data/atom+xml.php"), - success: function() { - ok( true, "success" ); - } - }); - - asyncTest( "jQuery.ajax() - statusText", 3, function() { - jQuery.ajax( url("data/statusText.php?status=200&text=Hello") ).done(function( _, statusText, jqXHR ) { - strictEqual( statusText, "success", "callback status text ok for success" ); - ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); - jQuery.ajax( url("data/statusText.php?status=404&text=World") ).fail(function( jqXHR, statusText ) { + ajaxTest( "jQuery.ajax() - statusText", 4, [ + { + url: service("echo"), + data: { + status: 200, + statusText: "Hello" + }, + success: function( _, statusText, jqXHR ) { + strictEqual( statusText, "success", "callback status text ok for success" ); + strictEqual( jqXHR.statusText, jqXHR.statusText === "Hello" ? "Hello" : "OK", "jqXHR status text ok for success" ); + } + }, + { + url: service("echo"), + data: { + status: 404, + statusText: "Hello" + }, + error: function( jqXHR, statusText ) { strictEqual( statusText, "error", "callback status text ok for error" ); - // ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" ); - start(); - }); - }); - }); - - asyncTest( "jQuery.ajax() - statusCode", 20, function() { - - var count = 12; - - function countComplete() { - if ( ! --count ) { - start(); + strictEqual( jqXHR.statusText, jqXHR.statusText === "Hello" ? "Hello" : "Not Found", "jqXHR status text ok for error" ); } } + ]); - function createStatusCodes( name, isSuccess ) { - name = "Test " + name + " " + ( isSuccess ? "success" : "error" ); + jQuery.each( [ "error", service("echo") ], function( isSuccess, url ) { + function statusCodes( title ) { return { 200: function() { - ok( isSuccess, name ); + ok( isSuccess, title + " - success" ); }, 404: function() { - ok( !isSuccess, name ); + ok( !isSuccess, title + " - error" ); } }; } - - jQuery.each( - /* jQuery.each arguments start */ - { - "data/name.html": true, - "data/someFileThatDoesNotExist.html": false - }, - function( uri, isSuccess ) { - - jQuery.ajax( url(uri), { - statusCode: createStatusCodes( "in options", isSuccess ), - complete: countComplete - }); - - jQuery.ajax( url(uri), { - complete: countComplete - }).statusCode( createStatusCodes("immediately with method", isSuccess) ); - - jQuery.ajax( url(uri), { - complete: function( jqXHR ) { - jqXHR.statusCode( createStatusCodes("on complete", isSuccess) ); - countComplete(); - } - }); - - jQuery.ajax( url(uri), { - complete: function( jqXHR ) { - setTimeout(function() { - jqXHR.statusCode( createStatusCodes("very late binding", isSuccess) ); - countComplete(); - }, 100 ); - } - }); - - jQuery.ajax( url(uri), { - statusCode: createStatusCodes( "all (options)", isSuccess ), - complete: function( jqXHR ) { - jqXHR.statusCode( createStatusCodes("all (on complete)", isSuccess) ); - setTimeout(function() { - jqXHR.statusCode( createStatusCodes("all (very late binding)", isSuccess) ); - countComplete(); - }, 100 ); - } - }).statusCode( createStatusCodes("all (immediately with method)", isSuccess) ); - - var testString = ""; - - jQuery.ajax( url(uri), { - success: function( a, b, jqXHR ) { - ok( isSuccess, "success" ); - var statusCode = {}; - statusCode[ jqXHR.status ] = function() { - testString += "B"; - }; - jqXHR.statusCode( statusCode ); - testString += "A"; - }, - error: function( jqXHR ) { - ok( !isSuccess, "error" ); - var statusCode = {}; - statusCode[ jqXHR.status ] = function() { - testString += "B"; - }; - jqXHR.statusCode( statusCode ); - testString += "A"; - }, - complete: function() { - strictEqual( - testString, - "AB", - "Test statusCode callbacks are ordered like " + ( isSuccess ? "success" : "error" ) + " callbacks" - ); - countComplete(); - } - }); - - } - /* jQuery.each arguments end*/ - ); - }); - - ajaxTest( "jQuery.ajax() - transitive conversions", 8, [ - { - url: url("data/json.php"), - converters: { - "json myJson": function( data ) { - ok( true, "converter called" ); - return data; + function request( options ) { + return jQuery.extend( true, { + url: url, + success: isSuccess, + error: !isSuccess + }, options ); + } + ajaxTest( "jQuery.ajax() - statusCode - " + ( isSuccess ? "success" : "error" ), 3, [ + request({ + statusCode: statusCodes("option") + }), + request({ + afterSend: function( jqXHR ) { + jqXHR.statusCode( statusCodes("method - immediate") ); } - }, - dataType: "myJson", - success: function() { - ok( true, "Transitive conversion worked" ); - strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text" ); - strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType" ); - } - }, - { - url: url("data/json.php"), - converters: { - "json myJson": function( data ) { - ok( true, "converter called (*)" ); - return data; + }), + request({ + complete: function( jqXHR ) { + jqXHR.statusCode( statusCodes("on complete") ); } - }, - contents: false, /* headers are wrong so we ignore them */ - dataType: "* myJson", - success: function() { - ok( true, "Transitive conversion worked (*)" ); - strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text (*)" ); - strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" ); + }) + ]); + }); + + ajaxTest( "jQuery.ajax() - transitive conversions", 8, function() { + return jQuery.map( [ "", "*" ], function( srcType ) { + var dataType = "myJson"; + if ( srcType ) { + dataType = srcType + " " + dataType; } - } - ]); + return { + url: service("echo"), + data: { + content: "\"041275\"" + }, + converters: { + "json myJson": function( data ) { + strictEqual( data, "041275", "converter called - " + dataType ); + return 42; + } + }, + dataType: dataType, + success: function( data ) { + strictEqual( data, 42, "Transitive conversion worked - " + dataType ); + strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text - " + dataType ); + strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType - " + dataType ); + } + }; + }); + }); ajaxTest( "jQuery.ajax() - overrideMimeType", 2, [ { - url: url("data/json.php"), + url: service("echo"), + data: { + content: "42" + }, beforeSend: function( xhr ) { xhr.overrideMimeType( "application/json" ); }, success: function( json ) { - ok( json.data, "Mimetype overriden using beforeSend" ); + strictEqual( json, 42, "Mimetype overriden using beforeSend" ); } }, { - url: url("data/json.php"), + url: service("echo"), + data: { + content: "42" + }, mimeType: "application/json", success: function( json ) { - ok( json.data, "Mimetype overriden using mimeType option" ); + strictEqual( json, 42, "Mimetype overriden using mimeType option" ); } } ]); - ajaxTest( "jQuery.ajax() - empty json gets to error callback instead of success callback.", 1, { - url: url("data/echoData.php"), - error: function( _, __, error ) { - equal( typeof error === "object", true, "Didn't get back error object for empty json response" ); - }, - dataType: "json" - }); - ajaxTest( "#2688 - jQuery.ajax() - beforeSend, cancel request", 2, { create: function() { return jQuery.ajax({ - url: url("data/name.html"), beforeSend: function() { ok( true, "beforeSend got called, canceling" ); return false; @@ -1283,14 +1171,14 @@ module( "ajax", { }); ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, { - url: "data/echoQuery.php", + url: service("echo"), data: { - key: function() { + content: function() { return "value"; } }, success: function( result ) { - strictEqual( result, "key=value" ); + strictEqual( result, "value", "function called" ); } }); @@ -1310,11 +1198,10 @@ module( "ajax", { jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { ajaxTest( "#7578 - jQuery.ajax() - JSONP - default for cache option" + label, 1, { - url: "data/jsonp.php", dataType: "jsonp", crossDomain: crossDomain, beforeSend: function( jqXHR, s ) { - strictEqual( this.cache, false, "cache must be false on JSON request" ); + strictEqual( this.cache, false, "cache must be false on JSONP request" ); return false; }, error: true @@ -1332,7 +1219,7 @@ module( "ajax", { }, { create: function() { - return jQuery.ajax("data/name.html"); + return jQuery.ajax( service("echo") ); }, done: function() { ok( true, "With only string URL argument" ); @@ -1340,7 +1227,7 @@ module( "ajax", { }, { create: function() { - return jQuery.ajax( "data/name.html", {}); + return jQuery.ajax( service("echo"), {}); }, done: function() { ok( true, "With string URL param and map" ); @@ -1350,7 +1237,7 @@ module( "ajax", { create: function( options ) { return jQuery.ajax( options ); }, - url: "data/name.html", + url: service("echo"), success: function() { ok( true, "With only map" ); } @@ -1359,7 +1246,10 @@ module( "ajax", { jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 2, { - url: "data/jsonp.php", + url: service("echo"), + data: { + content: "42" + }, dataType: "jsonp", crossDomain: crossDomain, beforeSend: function( jqXHR, s ) { @@ -1369,7 +1259,6 @@ module( "ajax", { var previous = this; strictEqual( previous.jsonpCallback, undefined, "jsonpCallback option is set back to default in callbacks" ); jQuery.ajax({ - url: "data/jsonp.php", dataType: "jsonp", crossDomain: crossDomain, beforeSend: function() { @@ -1386,7 +1275,7 @@ module( "ajax", { context = {}; context.field = context; try { - jQuery.ajax( "non-existing", { + jQuery.ajax({ context: context, beforeSend: function() { ok( this === context, "context was not deep extended" ); @@ -1400,7 +1289,7 @@ module( "ajax", { ok( success, "context with circular reference did not generate an exception" ); }); - jQuery.each( [ "as argument", "in settings object" ], function( inSetting, title ) { + jQuery.each( [ "argument", "settings object" ], function( inSetting, title ) { function request( url, test ) { return { @@ -1413,7 +1302,7 @@ module( "ajax", { }; } - ajaxTest( "#10093 - jQuery.ajax() - falsy url " + title, 4, [ + ajaxTest( "#10093 - jQuery.ajax() - falsy url - " + title, 4, [ request( "", "empty string" ), request( false ), request( null ), @@ -1432,7 +1321,10 @@ module( "ajax", { test( "#11743 - jQuery.ajax() - script, throws exception", 1, function() { raises(function() { jQuery.ajax({ - url: "data/badjson.js", + url: service("echo"), + data: { + content: "SYNTAX ERROR" + }, dataType: "script", throws: true, // TODO find a way to test this asynchronously, too @@ -1440,10 +1332,10 @@ module( "ajax", { // Global events get confused by the exception global: false, success: function() { - ok( false, "Success." ); + ok( false, "success" ); }, error: function() { - ok( false, "Error." ); + ok( false, "error" ); } }); }, "exception bubbled" ); @@ -1453,8 +1345,11 @@ module( "ajax", { function request( option ) { var options = { - url: url("data/echoData.php"), - data: "hello", + url: service("echo/index.php"), + data: { + requestArray: "POST", + content: "hello" + }, success: function( msg ) { strictEqual( msg, "hello", "Check for POST (no override)" ); } @@ -1506,7 +1401,10 @@ module( "ajax", { asyncTest( "jQuery.ajaxSetup()", 1, function() { jQuery.ajaxSetup({ - url: url("data/name.php?name=foo"), + url: service("echo"), + data: { + content: "bar" + }, success: function( msg ) { strictEqual( msg, "bar", "Check for GET" ); start(); @@ -1515,51 +1413,31 @@ module( "ajax", { jQuery.ajax(); }); - asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function() { - var passed = 0, - pass = function() { - ok( passed++ < 2, "Error callback executed" ); - if ( passed == 2 ) { - jQuery( document ).off("ajaxError.setupTest"); - start(); - } - }, - fail = function( a, b, c ) { - ok( false, "Check for timeout failed " + a + " " + b ); - start(); - }; - - jQuery( document ).on( "ajaxError.setupTest", pass ); - - jQuery.ajaxSetup({ - timeout: 1000 - }); - - jQuery.ajax({ - type: "GET", - url: url("data/name.php?wait=5"), - error: pass, - success: fail - }); + ajaxTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 6, { + setup: function() { + addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError")(); + jQuery.ajaxSetup({ + timeout: 50 + }); + }, + url: service("echo?delay=1"), + error: function( _, status ) { + strictEqual( status, "timeout", "timed out" ); + } }); - asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function() { - jQuery.ajaxSetup({ - timeout: 50 - }); - jQuery.ajax({ - type: "GET", - timeout: 15000, - url: url("data/name.php?wait=1"), - error: function() { - ok( false, "Check for local timeout failed" ); - start(); - }, - success: function() { - ok( true, "Check for local timeout" ); - start(); - } - }); + ajaxTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, { + setup: function() { + jQuery.ajaxSetup({ + timeout: 50 + }); + }, + type: "GET", + timeout: 15000, + url: service("echo?delay=1"), + success: function() { + ok( true, "Check for local timeout" ); + } }); //----------- jQuery.domManip() @@ -1573,65 +1451,79 @@ module( "ajax", { ok( false, "Global event triggered" ); }); - jQuery("#qunit-fixture").append(""); - - jQuery( document ).unbind("ajaxStart ajaxStop"); + jQuery("#qunit-fixture").append(""); }); asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { - jQuery("#qunit-fixture").load( "data/cleanScript.html", start ); + jQuery("#qunit-fixture").load( service( "echo", { + content: + "\n" + + "" + }), start ); }); //----------- jQuery.get() asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function() { - jQuery.get( url("data/dashboard.xml"), function( xml ) { - var content = []; - jQuery( "tab", xml ).each(function() { - content.push( jQuery( this ).text() ); + var tabs = [ "blabla", "blublu" ]; + jQuery.get( service( "echo", { + contentType: "text/xml", + content: createDashboardXML( true ) + }), function( xml ) { + jQuery( "tab", xml ).each(function( index ) { + strictEqual( jQuery( this ).text(), tabs[ index ], "Check tab #" + ( index + 1 ) ); }); - strictEqual( content[ 0 ], "blabla", "Check first tab" ); - strictEqual( content[ 1 ], "blublu", "Check second tab" ); start(); }); }); asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function() { jQuery.ajaxSetup({ - data: "helloworld" + data: { + content: "helloworld" + } }); - jQuery.get( url("data/echoQuery.php"), function( data ) { - ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" ); + jQuery.get( service("echo"), function( data ) { + strictEqual( data, "helloworld", "Data from ajaxSettings was used" ); start(); }); }); //----------- jQuery.getJSON() - asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function() { + asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 1, function() { jQuery.getJSON( - url("data/json.php"), + service("echo"), { - "json": "array" + "content": "[{ \"name\": \"John\", \"age\": 21 }, { \"name\": \"Peter\", \"age\": 25 }]" }, function( json ) { - ok( json.length >= 2, "Check length" ); - strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); + deepEqual( json, [{ + name: "John", + age: 21 + }, { + name: "Peter", + age: 25 + }], "json is as expected" ); start(); } ); }); - asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function() { - jQuery.getJSON( url("data/json.php"), function( json ) { - if ( json && json["data"] ) { - strictEqual( json["data"]["lang"], "en", "Check JSON: lang" ); - strictEqual( json["data"].length, 25, "Check JSON: length" ); - start(); - } + asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 1, function() { + jQuery.getJSON( service( "echo", { + content: "{ \"data\": { \"lang\": \"en\", \"length\": 25 } }" + }), function( json ) { + deepEqual( json, { + data: { + lang: "en", + length: 25 + } + }, "json is as expected" ); + start(); }); }); @@ -1648,16 +1540,22 @@ module( "ajax", { return true; } }; - jQuery.getJSON( url("data/json.php"), function( json ) { + jQuery.getJSON( service("echo"), function( json ) { strictEqual( json, true, "Verifying return value" ); start(); }); }); - asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function() { - jQuery.getJSON( url( window.location.href.replace( /[^\/]*$/, "" ) + "data/json.php" ), function( json ) { - strictEqual( json.data.lang, "en", "Check JSON: lang" ); - strictEqual( json.data.length, 25, "Check JSON: length" ); + asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 1, function() { + jQuery.getJSON( window.location.href.replace( /[^\/]*$/, "" ) + service( "echo", { + content: "{ \"data\": { \"lang\": \"en\", \"length\": 25 } }" + }), function( json ) { + deepEqual( json, { + data: { + lang: "en", + length: 25 + } + }, "json is as expected" ); start(); }); }); @@ -1666,20 +1564,26 @@ module( "ajax", { asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() { Globals.register("testBar"); - jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) { - strictEqual( window["testBar"], "bar", "Check if script was evaluated" ); + jQuery.getScript( service("echo", { + content: "var testBar = \"bar\"; ok( true, \"script executed\");" + }), function( data, _, jqXHR ) { + strictEqual( testBar, "bar", "Check if script was evaluated" ); start(); }); }); asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() { Globals.register("testBar"); - jQuery.getScript( url("data/test.js") ).done( start ); + jQuery.getScript( service("echo", { + content: "var testBar = \"bar\"; ok( true, \"script executed\");" + }) ).done( start ); }); asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() { Globals.register("testBar"); - jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) { + jQuery.getScript( service("echo", { + content: "var testBar = \"bar\"; ok( true, \"script executed\");" + }), function( data, _, jqXHR ) { strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" ); start(); }); @@ -1694,14 +1598,16 @@ module( "ajax", { strictEqual( this.type, "GET", "no data means GET request" ); } }); - jQuery("#first").load( "data/name.html", start ); + jQuery("#first").load( service( "echo", { + content: "" + }), start ); }); asyncTest( "jQuery.fn.load() - 404 error callbacks", 6, function() { addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError")(); - jQuery( document ).ajaxStop( start ); - jQuery("
    ").load( "data/404.html", function() { + jQuery("
    ").load( "error", function() { ok( true, "complete" ); + start(); }); }); @@ -1709,33 +1615,41 @@ module( "ajax", { asyncTest( "jQuery.fn.load( String, null )", 2, function() { jQuery.ajaxSetup({ beforeSend: function() { - strictEqual( this.type, "GET", "no data means GET request" ); + strictEqual( this.type, "GET", "null data means GET request" ); } }); - jQuery("#first").load( "data/name.html", null, start ); + jQuery("#first").load( service( "echo", { + content: "" + }), null, start ); }); // check if load can be called with url and undefined data asyncTest( "jQuery.fn.load( String, undefined )", 2, function() { jQuery.ajaxSetup({ beforeSend: function() { - strictEqual( this.type, "GET", "no data means GET request" ); + strictEqual( this.type, "GET", "undefined data means GET request" ); } }); - jQuery("#first").load( "data/name.html", undefined, start ); + jQuery("#first").load( service( "echo", { + content: "" + }), undefined, start ); }); // check if load can be called with only url asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function() { - jQuery("#first").load( "data/test3.html div.user", function() { + jQuery("#first").load( service("echo", { + content: "
    " + }) + " div.user", function() { strictEqual( jQuery( this ).children("div").length, 2, "Verify that specific elements were injected" ); start(); }); }); asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() { - jQuery("#first").load( url("data/name.html"), function() { - ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); + jQuery("#first").load( service( "echo", { + content: "INJECTED" + }), function() { + ok( /^INJECTED/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); start(); }); }); @@ -1750,7 +1664,9 @@ module( "ajax", { Globals.register("testFoo"); Globals.register("testBar"); - jQuery("#first").load( url("data/test.html"), function() { + jQuery("#first").load( service( "echo", { + content: createComplexHTML() + }), function() { ok( jQuery("#first").html().match( /^html text/ ), "Check content after loading html" ); strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM" ); strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" ); @@ -1759,9 +1675,9 @@ module( "ajax", { }); asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() { - Globals.register("testFoo"); - - jQuery("#first").load( url("data/test2.html"), function() { + jQuery("#first").load( service("echo", { + content: "" + }), function() { strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" ); start(); @@ -1774,30 +1690,29 @@ module( "ajax", { return "Hello World"; } }); - jQuery("
    ").load( url("data/name.html"), function( responseText ) { + jQuery("
    ").load( service("echo"), function( responseText ) { strictEqual( jQuery( this ).html(), "Hello World", "Test div was filled with filtered data" ); strictEqual( responseText, "Hello World", "Test callback receives filtered data" ); start(); }); }); - asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function() { - jQuery("
    ").load( url("data/params_html.php"), { - "foo": 3, - "bar": "ok" + asyncTest( "jQuery.fn.load( String, Object, Function )", 1, function() { + jQuery("
    ").load( service("echo/", { + requestArray: "POST" + }), { + content: "INJECTED" }, function() { - var $post = jQuery( this ).find("#post"); - strictEqual( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly" ); - strictEqual( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly" ); + strictEqual( jQuery( this ).text(), "INJECTED", "data passed" ); start(); }); }); - asyncTest( "jQuery.fn.load( String, String, Function )", 2, function() { - jQuery("
    ").load( url("data/params_html.php"), "foo=3&bar=ok", function() { - var $get = jQuery( this ).find("#get"); - strictEqual( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly" ); - strictEqual( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly" ); + asyncTest( "jQuery.fn.load( String, String, Function )", 1, function() { + jQuery("
    ").load( service("echo/", { + requestArray: "GET" + }), "content=INJECTED", function() { + strictEqual( jQuery( this ).text(), "INJECTED", "data passed" ); start(); }); }); @@ -1820,11 +1735,11 @@ module( "ajax", { jQuery.map([ { type: "success", - url: "data/echoQuery.php?arg=pop" + url: service("echo") }, { type: "error", - url: "data/404.php" + url: "error" } ], function( options ) { @@ -1848,25 +1763,23 @@ module( "ajax", { }); jQuery( document ).ajaxComplete(function( e, xml, s ) { strictEqual( s.dataType, "html", "Verify the load() dataType was html" ); - jQuery( document ).unbind("ajaxComplete"); start(); }); - jQuery("#first").load("data/test3.html"); + jQuery("#first").load( service("echo") ); }); - asyncTest( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { - var data = { - "baz": 1 - }; + test( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { jQuery.ajaxSetup({ data: { "foo": "bar" + }, + beforeSend: function() { + strictEqual( this.data, "foo=bar&baz=1", "data used both request and ajaxSetup values" ); + return false; } }); - jQuery("#foo").load( "data/echoQuery.php", data ); - jQuery( document ).ajaxComplete(function( event, jqXHR, options ) { - ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" ); - start(); + jQuery("#foo").load( "path/to/service", { + "baz": 1 }); }); @@ -1875,10 +1788,11 @@ module( "ajax", { asyncTest( "jQuery.post() - data", 3, function() { jQuery.when( jQuery.post( - url("data/name.php"), + service("echo/"), { - xml: "5-2", - length: 3 + requestArray: "POST", + contentType: "text/xml", + content: "5-23" }, function( xml ) { jQuery( "math", xml ).each(function() { @@ -1888,12 +1802,15 @@ module( "ajax", { } ), jQuery.ajax({ - url: url("data/echoData.php"), + url: service("echo/"), type: "POST", data: { - "test": { - "length": 7, - "foo": "bar" + requestArray: "POST", + content: { + test: { + "length": 7, + "foo": "bar" + } } }, success: function( data ) { @@ -1906,9 +1823,11 @@ module( "ajax", { asyncTest( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function() { jQuery.when( jQuery.post( - url("data/name.php"), + service("echo/"), { - "xml": "5-2" + requestArray: "POST", + contentType: "text/xml", + content: "5-23" }, function( xml ) { jQuery( "math", xml ).each(function() { @@ -1917,7 +1836,11 @@ module( "ajax", { }); } ), - jQuery.post( url("data/name.php?xml=5-2"), {}, function( xml ) { + jQuery.post( service("echo/", { + requestArray: "GET", + contentType: "text/xml", + content: "5-23" + }), {}, function( xml ) { jQuery( "math", xml ).each(function() { strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 530224354..130aa3fe2 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2027,7 +2027,7 @@ test("html() - script exceptions bubble (#11743)", function() { }, "exception bubbled from inline script" ); raises(function() { - jQuery("#qunit-fixture").html(""); + jQuery("#qunit-fixture").html(""); ok( false, "error ignored" ); }, "exception bubbled from remote script" ); }); -- 2.39.5