From b7ece8c6206d87e71145d1aeefc984e1649af06a Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 5 Dec 2012 14:54:14 +0100 Subject: [PATCH] Revert "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." This reverts commit 228ab3ddae527f72cc3122a1c6115d7718bcfd57. --- 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 | 1479 +++++++++++---------- test/unit/manipulation.js | 2 +- 38 files changed, 1308 insertions(+), 835 deletions(-) delete mode 100644 test/data/ajax/echo/index.php delete mode 100644 test/data/ajax/headers/cache/index.php delete mode 100644 test/data/ajax/headers/request/index.php delete mode 100644 test/data/ajax/headers/response/index.php create mode 100644 test/data/atom+xml.php create mode 100644 test/data/badcall.js create mode 100644 test/data/badjson.js create mode 100644 test/data/cleanScript.html create mode 100644 test/data/dashboard.xml create mode 100644 test/data/echoData.php create mode 100644 test/data/echoQuery.php create mode 100644 test/data/errorWithText.php create mode 100644 test/data/etag.php create mode 100644 test/data/evalScript.php create mode 100644 test/data/headers.php create mode 100644 test/data/if_modified_since.php create mode 100644 test/data/json.php create mode 100644 test/data/json_obj.js create mode 100644 test/data/jsonp.php create mode 100644 test/data/name.html create mode 100644 test/data/name.php create mode 100644 test/data/params_html.php create mode 100644 test/data/script.php create mode 100644 test/data/statusText.php create mode 100644 test/data/test.html create mode 100644 test/data/test.js create mode 100644 test/data/test.php create mode 100644 test/data/test2.html create mode 100644 test/data/test3.html create mode 100644 test/data/text.php create mode 100644 test/data/ua.txt create mode 100644 test/data/with_fries.xml create mode 100644 test/data/with_fries_over_jsonp.php diff --git a/test/.jshintrc b/test/.jshintrc index 43e9c722d..2dd668c3f 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -41,15 +41,11 @@ "ajaxTest": true, "testIframe": true, "testIframeWithCallback": true, - "createComplexHTML": true, "createDashboardXML": true, - "createWithFriesXML": true, "createXMLFragment": true, "moduleTeardown": true, - "testBar": true, "testFoo": true, - "url": true, - "service": true, + "url": true, "t": true, "q": true, "amdDefined": true, diff --git a/test/data/ajax/echo/index.php b/test/data/ajax/echo/index.php deleted file mode 100644 index a03fe4b0d..000000000 --- a/test/data/ajax/echo/index.php +++ /dev/null @@ -1,43 +0,0 @@ - "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 deleted file mode 100644 index c52b665bd..000000000 --- a/test/data/ajax/headers/cache/index.php +++ /dev/null @@ -1,30 +0,0 @@ - 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 deleted file mode 100644 index c064ad709..000000000 --- a/test/data/ajax/headers/request/index.php +++ /dev/null @@ -1,12 +0,0 @@ - $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 deleted file mode 100644 index 6c8d0864e..000000000 --- a/test/data/ajax/headers/response/index.php +++ /dev/null @@ -1,5 +0,0 @@ - $value ) { - @header("$header: $value"); -} diff --git a/test/data/atom+xml.php b/test/data/atom+xml.php new file mode 100644 index 000000000..944591abf --- /dev/null +++ b/test/data/atom+xml.php @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/data/badcall.js b/test/data/badcall.js new file mode 100644 index 000000000..cc2f2b42c --- /dev/null +++ b/test/data/badcall.js @@ -0,0 +1 @@ +undefined(); diff --git a/test/data/badjson.js b/test/data/badjson.js new file mode 100644 index 000000000..ad2de7a39 --- /dev/null +++ b/test/data/badjson.js @@ -0,0 +1 @@ +{bad: toTheBone} diff --git a/test/data/cleanScript.html b/test/data/cleanScript.html new file mode 100644 index 000000000..69288a858 --- /dev/null +++ b/test/data/cleanScript.html @@ -0,0 +1,10 @@ + + diff --git a/test/data/dashboard.xml b/test/data/dashboard.xml new file mode 100644 index 000000000..5a6f56142 --- /dev/null +++ b/test/data/dashboard.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/data/echoData.php b/test/data/echoData.php new file mode 100644 index 000000000..a37ba515a --- /dev/null +++ b/test/data/echoData.php @@ -0,0 +1 @@ + diff --git a/test/data/echoQuery.php b/test/data/echoQuery.php new file mode 100644 index 000000000..b72f329c9 --- /dev/null +++ b/test/data/echoQuery.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/data/errorWithText.php b/test/data/errorWithText.php new file mode 100644 index 000000000..abd873217 --- /dev/null +++ b/test/data/errorWithText.php @@ -0,0 +1,5 @@ + diff --git a/test/data/evalScript.php b/test/data/evalScript.php new file mode 100644 index 000000000..ea9b8c55f --- /dev/null +++ b/test/data/evalScript.php @@ -0,0 +1 @@ +ok( "" === "GET", "request method is " ); \ No newline at end of file diff --git a/test/data/headers.php b/test/data/headers.php new file mode 100644 index 000000000..968f13f19 --- /dev/null +++ b/test/data/headers.php @@ -0,0 +1,18 @@ + $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 new file mode 100644 index 000000000..098b7da85 --- /dev/null +++ b/test/data/if_modified_since.php @@ -0,0 +1,20 @@ + diff --git a/test/data/json.php b/test/data/json.php new file mode 100644 index 000000000..d6e0f2fc7 --- /dev/null +++ b/test/data/json.php @@ -0,0 +1,13 @@ + diff --git a/test/data/json_obj.js b/test/data/json_obj.js new file mode 100644 index 000000000..7fa61820f --- /dev/null +++ b/test/data/json_obj.js @@ -0,0 +1 @@ +{ "data": {"lang": "en", "length": 25} } diff --git a/test/data/jsonp.php b/test/data/jsonp.php new file mode 100644 index 000000000..6c13d72e9 --- /dev/null +++ b/test/data/jsonp.php @@ -0,0 +1,14 @@ + diff --git a/test/data/name.html b/test/data/name.html new file mode 100644 index 000000000..0fa32d1a8 --- /dev/null +++ b/test/data/name.html @@ -0,0 +1 @@ +ERROR diff --git a/test/data/name.php b/test/data/name.php new file mode 100644 index 000000000..64028585d --- /dev/null +++ b/test/data/name.php @@ -0,0 +1,24 @@ +$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 new file mode 100644 index 000000000..e88ef1521 --- /dev/null +++ b/test/data/params_html.php @@ -0,0 +1,12 @@ +
+$value ) + echo "$value"; +?> +
+
+$value ) + echo "$value"; +?> +
\ No newline at end of file diff --git a/test/data/script.php b/test/data/script.php new file mode 100644 index 000000000..fb7110491 --- /dev/null +++ b/test/data/script.php @@ -0,0 +1,11 @@ + +ok( true, "Script executed correctly." ); diff --git a/test/data/statusText.php b/test/data/statusText.php new file mode 100644 index 000000000..daf58ce3f --- /dev/null +++ b/test/data/statusText.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/test/data/test.html b/test/data/test.html new file mode 100644 index 000000000..eec028e90 --- /dev/null +++ b/test/data/test.html @@ -0,0 +1,7 @@ +html text
+ + +blabla diff --git a/test/data/test.js b/test/data/test.js new file mode 100644 index 000000000..a18815315 --- /dev/null +++ b/test/data/test.js @@ -0,0 +1,3 @@ +var testBar = "bar"; +jQuery('#ap').html('bar'); +ok( true, "test.js executed"); diff --git a/test/data/test.php b/test/data/test.php new file mode 100644 index 000000000..3d08f3253 --- /dev/null +++ b/test/data/test.php @@ -0,0 +1,7 @@ +html text
+ + +blabla \ No newline at end of file diff --git a/test/data/test2.html b/test/data/test2.html new file mode 100644 index 000000000..1df6151a0 --- /dev/null +++ b/test/data/test2.html @@ -0,0 +1,5 @@ + diff --git a/test/data/test3.html b/test/data/test3.html new file mode 100644 index 000000000..909d41745 --- /dev/null +++ b/test/data/test3.html @@ -0,0 +1,3 @@ +
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 6050eec4c..bff6b8dff 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -58,21 +58,7 @@ function t( a, b, c ) { deepEqual(f, q.apply( q, c ), a + " (" + b + ")"); } -function createComplexHTML() { - return 'html text
\ - \ - \ - blabla'; -} - -function createDashboardXML( noParse ) { +function createDashboardXML() { var string = ' \ \ \ @@ -85,10 +71,10 @@ function createDashboardXML( noParse ) { \ '; - return noParse ? string : jQuery.parseXML(string); + return jQuery.parseXML(string); } -function createWithFriesXML( noParse ) { +function createWithFriesXML() { var string = ' \ \ \ \ - '.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ); + '; - return noParse ? string : jQuery.parseXML( string ); + return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) ); } function createXMLFragment() { @@ -147,27 +133,16 @@ fireNative = document.createEvent ? /** * Add random number to url to stop caching * - * @example url("data/iframe.html") - * @result "data/iframe.html?10538358428943" + * @example url("data/test.html") + * @result "data/test.html?10538358428943" * - * @example url("data/ajax/echo?foo=bar") - * @result "data/ajax/echo?foo=bar&10538358345554" + * @example url("data/test.php?foo=bar") + * @result "data/test.php?foo=bar&10538358345554" */ function url( value ) { return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 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; @@ -192,9 +167,8 @@ 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 new file mode 100644 index 000000000..b9df4cf3b --- /dev/null +++ b/test/data/text.php @@ -0,0 +1,12 @@ +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 new file mode 100644 index 000000000..95e522e25 --- /dev/null +++ b/test/data/ua.txt @@ -0,0 +1,272 @@ +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 new file mode 100644 index 000000000..dc42ddfc4 --- /dev/null +++ b/test/data/with_fries.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + 1 + + + + + foo + + + + + + + diff --git a/test/data/with_fries_over_jsonp.php b/test/data/with_fries_over_jsonp.php new file mode 100644 index 000000000..456aeb3bd --- /dev/null +++ b/test/data/with_fries_over_jsonp.php @@ -0,0 +1,7 @@ + diff --git a/test/localfile.html b/test/localfile.html index faf34091c..7d49c44e1 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/ajax/echo/index.php", { + jQuery.ajax( "./data/badjson.js" , { 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( "error" , { + jQuery.ajax( "./data/doesnotexist.ext" , { context: jQuery( "#error" ), dataType: "text" }).error(function( xhr ) { diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 91c1c93c0..f88b5d7cc 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -30,40 +30,9 @@ module( "ajax", { //----------- jQuery.ajax() - 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, { + ajaxTest( "jQuery.ajax() - success callbacks", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: service("echo"), + url: url("data/name.html"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -75,10 +44,10 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success - (url, options)", 8, { + ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), create: function( options ) { - return jQuery.ajax( service("echo"), options ); + return jQuery.ajax( url("data/name.html"), options ); }, beforeSend: function() { ok( true, "beforeSend" ); @@ -91,9 +60,9 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success - late binding", 8, { + ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: service("echo"), + url: url("data/name.html"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -109,9 +78,9 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - success - oncomplete binding", 8, { + ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), - url: service("echo"), + url: url("data/name.html"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -127,12 +96,15 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - error", 8, { + ajaxTest( "jQuery.ajax() - error callbacks", 8, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"), - url: service("error"), + url: url("data/name.php?wait=5"), beforeSend: function() { ok( true, "beforeSend" ); }, + afterSend: function( request ) { + request.abort(); + }, error: function() { ok( true, "error" ); }, @@ -141,12 +113,9 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - abort - textStatus and errorThrown values", 4, [ + ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, [ { - url: service("echo"), - data: { - delay: 1 - }, + url: url("data/name.php?wait=5"), error: function( _, textStatus, errorThrown ) { strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" ); strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" ); @@ -156,10 +125,7 @@ module( "ajax", { } }, { - url: service("echo"), - data: { - delay: 1 - }, + url: url("data/name.php?wait=5"), error: function( _, textStatus, errorThrown ) { strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" ); strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" ); @@ -170,12 +136,8 @@ module( "ajax", { } ]); - ajaxTest( "jQuery.ajax() - error - responseText", 1, { - url: service("echo"), - data: { - status: 400, - content: "plain text message" - }, + ajaxTest( "jQuery.ajax() - responseText on error", 1, { + url: url("data/errorWithText.php"), error: function( xhr ) { strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" ); } @@ -185,7 +147,7 @@ module( "ajax", { var previousUrl, firstTime = true; jQuery.ajax({ - url: service("error"), + url: url("data/errorWithText.php"), error: function() { if ( firstTime ) { firstTime = false; @@ -193,7 +155,7 @@ module( "ajax", { } else { ok ( true, "Test retrying with jQuery.ajax(this) works" ); jQuery.ajax({ - url: service("error"), + url: url("data/errorWithText.php"), data: { "x": 1 }, @@ -215,16 +177,13 @@ module( "ajax", { }); }); - ajaxTest( "jQuery.ajax() - headers - request", 1, { + ajaxTest( "jQuery.ajax() - headers", 4, { setup: function() { jQuery( document ).ajaxSend(function( evt, xhr ) { xhr.setRequestHeader( "ajax-send", "test" ); }); }, - url: service("headers/request"), - data: { - headers: "siMPle,SometHing-elsE,OthEr,ajax-send" - }, + url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax-send"), headers: { "siMPle": "value", "SometHing-elsE": "other value", @@ -242,39 +201,20 @@ module( "ajax", { tmp = tmp.join(""); strictEqual( data, tmp, "Headers were sent" ); - } - }); - - 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"); + strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" ); + + 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-Header"), "sample value", "Sample header received" ); - strictEqual( xhr.getResponseHeader("Sample-Header2"), "sample value 2", "Second sample header received" ); - + strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" ); } }); - ajaxTest( "jQuery.ajax() - headers - Accept", 1, { - url: service("headers/request"), - data: { - headers: "accept" - }, + ajaxTest( "jQuery.ajax() - Accept header", 1, { + url: url("data/headers.php?keys=accept"), headers: { Accept: "very wrong accept value" }, @@ -286,22 +226,16 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - headers - contentType option", 2, [ + ajaxTest( "jQuery.ajax() - contentType", 2, [ { - url: service("headers/request"), - data: { - headers: "content-type" - }, + url: url("data/headers.php?keys=content-type"), contentType: "test", success: function( data ) { - ok( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); + strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); } }, { - url: service("headers/request"), - data: { - headers: "content-type" - }, + url: url("data/headers.php?keys=content-type"), contentType: false, success: function( data ) { strictEqual( data, "content-type: \n", "Test content-type is not sent when options.contentType===false" ); @@ -309,7 +243,7 @@ module( "ajax", { } ]); - ajaxTest( "jQuery.ajax() - url - protocol-less", 1, { + ajaxTest( "jQuery.ajax() - protocol-less urls", 1, { url: "//somedomain.com", beforeSend: function( xhr, settings ) { equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." ); @@ -318,37 +252,37 @@ module( "ajax", { error: true }); - ajaxTest( "jQuery.ajax() - url - hash", 3, [ + ajaxTest( "jQuery.ajax() - hash", 3, [ { - url: "path/to/service#foo", + url: "data/name.html#foo", beforeSend: function( xhr, settings ) { - strictEqual( settings.url, "path/to/service", "Make sure that the URL is trimmed." ); + equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." ); return false; }, error: true }, { - url: "path/to/service?abc#foo", + url: "data/name.html?abc#foo", beforeSend: function( xhr, settings ) { - strictEqual( settings.url, "path/to/service?abc", "Make sure that the URL is trimmed." ); + equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." ); return false; }, error: true }, { - url: "path/to/service?abc#foo", + url: "data/name.html?abc#foo", data: { "test": 123 }, beforeSend: function( xhr, settings ) { - equal( settings.url, "path/to/service?abc&test=123", "Make sure that the URL is trimmed." ); + equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." ); return false; }, error: true } ]); - ajaxTest( "jQuery.ajax() - url - cross-domain detection", 7, function() { + ajaxTest( "jQuery.ajax() - cross-domain detection", 7, function() { function request( url, title, crossDomainOrOptions ) { return jQuery.extend( { dataType: "jsonp", @@ -404,10 +338,7 @@ module( "ajax", { ajaxTest( "jQuery.ajax() - abort", 9, { setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete"), - url: service("echo"), - data: { - delay: 1 - }, + url: url("data/name.php?wait=5"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -422,42 +353,37 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - context", 12, function() { + ajaxTest( "jQuery.ajax() - events with context", 12, function() { - var context; + var context = document.createElement("div"); function event( e ) { - strictEqual( this, context, e.type ); + equal( this, context, e.type ); } function callback( msg ) { return function() { - strictEqual( this, context, "context is preserved on callback " + msg ); + equal( this, context, "context is preserved on callback " + msg ); }; } return { setup: function() { - 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 ); + jQuery( context ).appendTo("#foo") + .ajaxSend( event ) + .ajaxComplete( event ) + .ajaxError( event ) + .ajaxSuccess( event ); }, requests: [{ - url: service("echo"), + url: url("data/name.html"), + context: context, beforeSend: callback("beforeSend"), success: callback("success"), complete: callback("complete") }, { - url: service("error"), + url: url("data/404.html"), + context: context, beforeSend: callback("beforeSend"), error: callback("error"), complete: callback("complete") @@ -465,22 +391,22 @@ module( "ajax", { }; }); - ajaxTest( "jQuery.ajax() - context - none", 3, function() { + ajaxTest( "jQuery.ajax() - events without context", 3, function() { function nocallback( msg ) { return function() { - strictEqual( typeof this.url, "string", "context is settings on callback " + msg ); + equal( typeof this.url, "string", "context is settings on callback " + msg ); }; } return { - url: service("error"), + url: url("data/404.html"), beforeSend: nocallback("beforeSend"), error: nocallback("error"), complete: nocallback("complete") }; }); - ajaxTest( "jQuery.ajax() - context - modification", 1, { - url: service("error"), + ajaxTest( "jQuery.ajax() - context modification", 1, { + url: url("data/name.html"), context: {}, beforeSend: function() { this.test = "foo"; @@ -488,10 +414,10 @@ module( "ajax", { afterSend: function() { strictEqual( this.context.test, "foo", "Make sure the original object is maintained." ); }, - error: true + success: true }); - ajaxTest( "jQuery.ajax() - context - ajaxSetup", 3, function() { + ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function() { var obj = {}; return { setup: function() { @@ -501,24 +427,24 @@ module( "ajax", { strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); }, requests: [{ - url: service("error"), - error: function() { + url: url("data/name.html"), + success: function() { strictEqual( this, obj, "Make sure the original object is maintained." ); } }, { - url: service("error"), + url: url("data/name.html"), context: {}, - error: function() { + success: function() { ok( this !== obj, "Make sure overidding context is possible." ); } }] }; }); - ajaxTest( "jQuery.ajax() - events - disable", 3, { + ajaxTest( "jQuery.ajax() - disabled globals", 3, { setup: addGlobalEvents(""), global: false, - url: service("echo"), + url: url("data/name.html"), beforeSend: function() { ok( true, "beforeSend" ); }, @@ -530,69 +456,52 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - xml - non-namespace elements inside namespaced elements", 3, { - url: service("echo"), - data: { - contentType: "text/xml", - content: createWithFriesXML( true ) - }, + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, { + url: url("data/with_fries.xml"), + dataType: "xml", success: function( resp ) { - 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" ); + 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" ); } }); - ajaxTest( "jQuery.ajax() - xml - non-namespace elements inside namespaced elements (over JSONP)", 3, { - url: service("echo"), - data: { - content: createWithFriesXML( true ) - }, + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, { + url: url("data/with_fries_over_jsonp.php"), dataType: "jsonp xml", success: function( resp ) { - 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" ); + 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" ); } }); - ajaxTest( "jQuery.ajax() - atom+xml", 2, { - url: service("echo"), - data: { - content: "", - contentType: "atom+xml" + 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" ); + } }, - success: function( xml ) { - strictEqual( jQuery( "root", xml ).length, 1, "root in responseXML" ); - strictEqual( jQuery( "element", xml ).length, 1, "element in responseXML" ); + { + 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" ); + } } - }); - - 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: service("error"), + url: url("data/name.html"), beforeSend: function( xml ) { this.check = true; }, - error: function( data ) { + success: function( data ) { ok( this.check, "check beforeSend was executed" ); } }); @@ -600,7 +509,7 @@ module( "ajax", { ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, { create: function() { return jQuery.ajax({ - url: service("error"), + url: url("data/name.html"), beforeSend: function( xhr ) { ok( true, "beforeSend got called, canceling" ); xhr.abort(); @@ -621,16 +530,13 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - html", 5, { + ajaxTest( "jQuery.ajax() - dataType html", 5, { setup: function() { Globals.register("testFoo"); Globals.register("testBar"); }, dataType: "html", - url: service("echo"), - data: { - content: createComplexHTML() - }, + url: url("data/test.html"), success: function( data ) { ok( data.match( /^html text/ ), "Check content for datatype html" ); jQuery("#ap").html( data ); @@ -640,23 +546,17 @@ module( "ajax", { }); ajaxTest( "jQuery.ajax() - synchronous request", 1, { - url: service("echo"), - data: { - content: "hello world" - }, + url: url("data/json_obj.js"), dataType: "text", async: false, success: true, afterSend: function( xhr ) { - strictEqual( xhr.responseText, "hello world", "check returned text" ); + ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" ); } }); - ajaxTest( "jQuery.ajax() - synchronous request - callbacks", 2, { - url: service("echo"), - data: { - content: "hello world" - }, + ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, { + url: url("data/json_obj.js"), async: false, dataType: "text", success: true, @@ -666,33 +566,36 @@ module( "ajax", { ok( true, "success callback executed" ); result = data; }); - strictEqual( result, "hello world", "check returned text" ); + ok( /^\{ "data"/.test( result ), "check returned text" ); } }); - asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 7, function() { - var successCount = 0, - errorCount = 0, - errorEx = []; - function success() { + 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() { successCount++; - } - jQuery( document ).ajaxError(function( e, xhr, s, ex ) { + }; + jQuery( document ).on( "ajaxError.passthru", function( e, xml, s, ex ) { errorCount++; - errorEx.push( s.dataType + " / " + xhr.status + " / " + ex + " " ); + errorEx += ": " + xml.status; }); - jQuery( document ).ajaxStop(function() { - strictEqual( successCount, 5, "Check all ajax calls successful" ); - strictEqual( errorCount, 0, "Check no ajax errors ( " + errorEx.join() + ")" ); + 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"); start(); }); + Globals.register("testBar"); - 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.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.ajax({ - url: service("echo"), + url: url( target ), success: success }), "generic" ); }); @@ -720,219 +623,256 @@ module( "ajax", { return [ request( - "path/to/service", + "data/text.php", "no parameter" ), request( - "path/to/service?pizza=true", + "data/text.php?pizza=true", "1 parameter" ), request( - "path/to/service?_=tobereplaced555", + "data/text.php?_=tobereplaced555", "_= parameter" ), request( - "path/to/service?pizza=true&_=tobereplaced555", + "data/text.php?pizza=true&_=tobereplaced555", "1 parameter and _=" ), request( - "path/to/service?_=tobereplaced555&tv=false", + "data/text.php?_=tobereplaced555&tv=false", "_= and 1 parameter" ), request( - "path/to/service?name=David&_=tobereplaced555&washere=true", + "data/text.php?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, [ - 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; + { + 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)" ); + } + } ]); - ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 8, { + ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 9, { setup: function() { Globals.register("functionToCleanUp"); - Globals.register("functionToCleanUpAfterEarlyAbort"); Globals.register("XXX"); Globals.register("jsonpResults"); window["jsonpResults"] = function( data ) { - strictEqual( data, "041275", "JSON results returned - GET - custom callback function" ); + ok( data["data"], "JSON results returned (GET, custom callback function)" ); }; }, - 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" ); - } - }) - ] + 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)" ); + } + }] }); ajaxTest( "jQuery.ajax() - JSONP - Callback in data" + label, 2, [ - request({ - title: "data callback", - data: "content=041275&callback=?" - }), - request({ - title: "data context-free callback", - data: "content=041275&callback=??" - }) + { + 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)" ); + } + } ]); ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [ - request({ - title: "no callback", + { type: "POST", - url: "/" - }), - request({ - title: "data callback", + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, no callback)" ); + } + }, + { type: "POST", - url: "/", - data: "content=041275&callback=?" - }), - request({ - title: "data obj callback", + url: "data/jsonp.php", + data: "callback=?", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, data callback)" ); + } + }, + { type: "POST", - url: "/", - jsonp: "callback" - }) + url: "data/jsonp.php", + jsonp: "callback", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, data obj callback)" ); + } + } ]); ajaxTest( "jQuery.ajax() - JSONP" + label, 3, [ - request({ - title: "no callback" - }), - request({ - title: "no callback and re-use", + { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data.data, "JSON results returned (GET, no callback)" ); + } + }, + { create: function( options ) { var request = jQuery.ajax( options ), promise = request.then(function( data ) { - request = jQuery.ajax( this ); + 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)" ); + }); 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: service("echo"), - data: { - content: "{bad: toTheBone}" - }, + url: "data/badjson.js", dataType: "json", error: function( xhr, msg, detailedMsg ) { strictEqual( msg, "parsererror", "A parse error occurred." ); @@ -940,85 +880,186 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - JSON - content-type", 2, { - converters: { - "text json": function( text ) { - strictEqual( text, "", "content-type detected" ); - return 42; - } + ajaxTest( "jQuery.ajax() - script by content-type", 2, [ + { + url: "data/script.php", + data: { + "header": "script" + }, + success: true }, - url: service("headers/response/index.php"), + { + url: "data/script.php", + data: { + "header": "ecma" + }, + success: true + } + ]); + + ajaxTest( "jQuery.ajax() - JSON by content-type", 5, { + url: "data/json.php", data: { - "Content-Type": "application/json" + "header": "json", + "json": "array" }, success: function( json ) { - strictEqual( json, 42, "success" ); + 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() - JSON - content-type disabled", 1, { - converters: { - "text json": function() { - ok( false, "content-type detected" ); - } - }, - url: service("headers/response/index.php"), + ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, { + url: url("data/json.php"), data: { - "Content-Type": "application/json" + "header": "json", + "json": "array" }, contents: { - json: false + "json": false }, - success: function() { - ok( true, "success" ); + 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() - JSON - empty", 1, { - url: service("echo"), - dataType: "json", - error: function( _, __, error ) { - strictEqual( typeof error, "object", "error object for empty json response" ); + 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" ); + } + }); + + 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, "" ); } }); var ifModifiedNow = new Date(); - 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({ + 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({ url: url, - data: { - header: header, - value: value - }, ifModified: true, - 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" ); + 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(); + } + }); + }, + 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(); } - }).fail(function() { - ok( isOpera, "Opera cannot handle 304" ); - ok( isOpera, "Opera cannot handle 304" ); - }).always( 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(); + } + }); + }); + } + /* jQuery.each arguments end */ + ); ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, { // see RFC 2606 @@ -1035,121 +1076,192 @@ module( "ajax", { } }); - ajaxTest( "jQuery.ajax() - statusText", 4, [ - { - url: service("echo"), - data: { - status: 200, - statusText: "Hello" + 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 ) { + 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(); + } + } + + function createStatusCodes( name, isSuccess ) { + name = "Test " + name + " " + ( isSuccess ? "success" : "error" ); + return { + 200: function() { + ok( isSuccess, name ); + }, + 404: function() { + ok( !isSuccess, name ); + } + }; + } + + jQuery.each( + /* jQuery.each arguments start */ + { + "data/name.html": true, + "data/someFileThatDoesNotExist.html": false }, - 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" ); + 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; + } + }, + 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: service("echo"), - data: { - status: 404, - statusText: "Hello" + url: url("data/json.php"), + converters: { + "json myJson": function( data ) { + ok( true, "converter called (*)" ); + return data; + } }, - error: function( jqXHR, statusText ) { - strictEqual( statusText, "error", "callback status text ok for error" ); - strictEqual( jqXHR.statusText, jqXHR.statusText === "Hello" ? "Hello" : "Not Found", "jqXHR status text ok for error" ); + 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 (*)" ); } } ]); - jQuery.each( [ "error", service("echo") ], function( isSuccess, url ) { - function statusCodes( title ) { - return { - 200: function() { - ok( isSuccess, title + " - success" ); - }, - 404: function() { - ok( !isSuccess, title + " - error" ); - } - }; - } - 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") ); - } - }), - request({ - complete: function( jqXHR ) { - jqXHR.statusCode( statusCodes("on complete") ); - } - }) - ]); - }); - - 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: service("echo"), - data: { - content: "42" - }, + url: url("data/json.php"), beforeSend: function( xhr ) { xhr.overrideMimeType( "application/json" ); }, success: function( json ) { - strictEqual( json, 42, "Mimetype overriden using beforeSend" ); + ok( json.data, "Mimetype overriden using beforeSend" ); } }, { - url: service("echo"), - data: { - content: "42" - }, + url: url("data/json.php"), mimeType: "application/json", success: function( json ) { - strictEqual( json, 42, "Mimetype overriden using mimeType option" ); + ok( json.data, "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; @@ -1171,14 +1283,14 @@ module( "ajax", { }); ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, { - url: service("echo"), + url: "data/echoQuery.php", data: { - content: function() { + key: function() { return "value"; } }, success: function( result ) { - strictEqual( result, "value", "function called" ); + strictEqual( result, "key=value" ); } }); @@ -1198,10 +1310,11 @@ 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 JSONP request" ); + strictEqual( this.cache, false, "cache must be false on JSON request" ); return false; }, error: true @@ -1219,7 +1332,7 @@ module( "ajax", { }, { create: function() { - return jQuery.ajax( service("echo") ); + return jQuery.ajax("data/name.html"); }, done: function() { ok( true, "With only string URL argument" ); @@ -1227,7 +1340,7 @@ module( "ajax", { }, { create: function() { - return jQuery.ajax( service("echo"), {}); + return jQuery.ajax( "data/name.html", {}); }, done: function() { ok( true, "With string URL param and map" ); @@ -1237,7 +1350,7 @@ module( "ajax", { create: function( options ) { return jQuery.ajax( options ); }, - url: service("echo"), + url: "data/name.html", success: function() { ok( true, "With only map" ); } @@ -1246,10 +1359,7 @@ module( "ajax", { jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 2, { - url: service("echo"), - data: { - content: "42" - }, + url: "data/jsonp.php", dataType: "jsonp", crossDomain: crossDomain, beforeSend: function( jqXHR, s ) { @@ -1259,6 +1369,7 @@ 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() { @@ -1275,7 +1386,7 @@ module( "ajax", { context = {}; context.field = context; try { - jQuery.ajax({ + jQuery.ajax( "non-existing", { context: context, beforeSend: function() { ok( this === context, "context was not deep extended" ); @@ -1289,7 +1400,7 @@ module( "ajax", { ok( success, "context with circular reference did not generate an exception" ); }); - jQuery.each( [ "argument", "settings object" ], function( inSetting, title ) { + jQuery.each( [ "as argument", "in settings object" ], function( inSetting, title ) { function request( url, test ) { return { @@ -1302,7 +1413,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 ), @@ -1321,10 +1432,7 @@ module( "ajax", { test( "#11743 - jQuery.ajax() - script, throws exception", 1, function() { raises(function() { jQuery.ajax({ - url: service("echo"), - data: { - content: "SYNTAX ERROR" - }, + url: "data/badjson.js", dataType: "script", throws: true, // TODO find a way to test this asynchronously, too @@ -1332,10 +1440,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" ); @@ -1345,11 +1453,8 @@ module( "ajax", { function request( option ) { var options = { - url: service("echo/index.php"), - data: { - requestArray: "POST", - content: "hello" - }, + url: url("data/echoData.php"), + data: "hello", success: function( msg ) { strictEqual( msg, "hello", "Check for POST (no override)" ); } @@ -1401,10 +1506,7 @@ module( "ajax", { asyncTest( "jQuery.ajaxSetup()", 1, function() { jQuery.ajaxSetup({ - url: service("echo"), - data: { - content: "bar" - }, + url: url("data/name.php?name=foo"), success: function( msg ) { strictEqual( msg, "bar", "Check for GET" ); start(); @@ -1413,31 +1515,51 @@ module( "ajax", { jQuery.ajax(); }); - 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 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 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" ); - } + 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(); + } + }); }); //----------- jQuery.domManip() @@ -1451,79 +1573,65 @@ module( "ajax", { ok( false, "Global event triggered" ); }); - jQuery("#qunit-fixture").append(""); + jQuery("#qunit-fixture").append(""); + + jQuery( document ).unbind("ajaxStart ajaxStop"); }); asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { - jQuery("#qunit-fixture").load( service( "echo", { - content: - "\n" + - "" - }), start ); + jQuery("#qunit-fixture").load( "data/cleanScript.html", start ); }); //----------- jQuery.get() asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function() { - 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 ) ); + jQuery.get( url("data/dashboard.xml"), function( xml ) { + var content = []; + jQuery( "tab", xml ).each(function() { + content.push( jQuery( this ).text() ); }); + 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: { - content: "helloworld" - } + data: "helloworld" }); - jQuery.get( service("echo"), function( data ) { - strictEqual( data, "helloworld", "Data from ajaxSettings was used" ); + jQuery.get( url("data/echoQuery.php"), function( data ) { + ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" ); start(); }); }); //----------- jQuery.getJSON() - asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 1, function() { + asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function() { jQuery.getJSON( - service("echo"), + url("data/json.php"), { - "content": "[{ \"name\": \"John\", \"age\": 21 }, { \"name\": \"Peter\", \"age\": 25 }]" + "json": "array" }, function( json ) { - deepEqual( json, [{ - name: "John", - age: 21 - }, { - name: "Peter", - age: 25 - }], "json is as expected" ); + 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" ); 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(); + 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(); + } }); }); @@ -1540,22 +1648,16 @@ module( "ajax", { return true; } }; - jQuery.getJSON( service("echo"), function( json ) { + jQuery.getJSON( url("data/json.php"), function( json ) { strictEqual( json, true, "Verifying return value" ); start(); }); }); - 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" ); + 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" ); start(); }); }); @@ -1564,26 +1666,20 @@ module( "ajax", { asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() { Globals.register("testBar"); - jQuery.getScript( service("echo", { - content: "var testBar = \"bar\"; ok( true, \"script executed\");" - }), function( data, _, jqXHR ) { - strictEqual( testBar, "bar", "Check if script was evaluated" ); + jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) { + strictEqual( window["testBar"], "bar", "Check if script was evaluated" ); start(); }); }); asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() { Globals.register("testBar"); - jQuery.getScript( service("echo", { - content: "var testBar = \"bar\"; ok( true, \"script executed\");" - }) ).done( start ); + jQuery.getScript( url("data/test.js") ).done( start ); }); asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() { Globals.register("testBar"); - jQuery.getScript( service("echo", { - content: "var testBar = \"bar\"; ok( true, \"script executed\");" - }), function( data, _, jqXHR ) { + jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) { strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" ); start(); }); @@ -1598,16 +1694,14 @@ module( "ajax", { strictEqual( this.type, "GET", "no data means GET request" ); } }); - jQuery("#first").load( service( "echo", { - content: "" - }), start ); + jQuery("#first").load( "data/name.html", start ); }); asyncTest( "jQuery.fn.load() - 404 error callbacks", 6, function() { addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError")(); - jQuery("
    ").load( "error", function() { + jQuery( document ).ajaxStop( start ); + jQuery("
    ").load( "data/404.html", function() { ok( true, "complete" ); - start(); }); }); @@ -1615,41 +1709,33 @@ module( "ajax", { asyncTest( "jQuery.fn.load( String, null )", 2, function() { jQuery.ajaxSetup({ beforeSend: function() { - strictEqual( this.type, "GET", "null data means GET request" ); + strictEqual( this.type, "GET", "no data means GET request" ); } }); - jQuery("#first").load( service( "echo", { - content: "" - }), null, start ); + jQuery("#first").load( "data/name.html", 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", "undefined data means GET request" ); + strictEqual( this.type, "GET", "no data means GET request" ); } }); - jQuery("#first").load( service( "echo", { - content: "" - }), undefined, start ); + jQuery("#first").load( "data/name.html", undefined, start ); }); // check if load can be called with only url asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function() { - jQuery("#first").load( service("echo", { - content: "
    " - }) + " div.user", function() { + jQuery("#first").load( "data/test3.html 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( service( "echo", { - content: "INJECTED" - }), function() { - ok( /^INJECTED/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); + jQuery("#first").load( url("data/name.html"), function() { + ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); start(); }); }); @@ -1664,9 +1750,7 @@ module( "ajax", { Globals.register("testFoo"); Globals.register("testBar"); - jQuery("#first").load( service( "echo", { - content: createComplexHTML() - }), function() { + jQuery("#first").load( url("data/test.html"), 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" ); @@ -1675,9 +1759,9 @@ module( "ajax", { }); asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() { - jQuery("#first").load( service("echo", { - content: "" - }), function() { + Globals.register("testFoo"); + + jQuery("#first").load( url("data/test2.html"), 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(); @@ -1690,29 +1774,30 @@ module( "ajax", { return "Hello World"; } }); - jQuery("
    ").load( service("echo"), function( responseText ) { + jQuery("
    ").load( url("data/name.html"), 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 )", 1, function() { - jQuery("
    ").load( service("echo/", { - requestArray: "POST" - }), { - content: "INJECTED" + asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function() { + jQuery("
    ").load( url("data/params_html.php"), { + "foo": 3, + "bar": "ok" }, function() { - strictEqual( jQuery( this ).text(), "INJECTED", "data passed" ); + 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" ); start(); }); }); - 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" ); + 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" ); start(); }); }); @@ -1735,11 +1820,11 @@ module( "ajax", { jQuery.map([ { type: "success", - url: service("echo") + url: "data/echoQuery.php?arg=pop" }, { type: "error", - url: "error" + url: "data/404.php" } ], function( options ) { @@ -1763,23 +1848,25 @@ 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( service("echo") ); + jQuery("#first").load("data/test3.html"); }); - test( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { + asyncTest( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { + var data = { + "baz": 1 + }; 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( "path/to/service", { - "baz": 1 + 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(); }); }); @@ -1788,11 +1875,10 @@ module( "ajax", { asyncTest( "jQuery.post() - data", 3, function() { jQuery.when( jQuery.post( - service("echo/"), + url("data/name.php"), { - requestArray: "POST", - contentType: "text/xml", - content: "5-23" + xml: "5-2", + length: 3 }, function( xml ) { jQuery( "math", xml ).each(function() { @@ -1802,15 +1888,12 @@ module( "ajax", { } ), jQuery.ajax({ - url: service("echo/"), + url: url("data/echoData.php"), type: "POST", data: { - requestArray: "POST", - content: { - test: { - "length": 7, - "foo": "bar" - } + "test": { + "length": 7, + "foo": "bar" } }, success: function( data ) { @@ -1823,11 +1906,9 @@ module( "ajax", { asyncTest( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function() { jQuery.when( jQuery.post( - service("echo/"), + url("data/name.php"), { - requestArray: "POST", - contentType: "text/xml", - content: "5-23" + "xml": "5-2" }, function( xml ) { jQuery( "math", xml ).each(function() { @@ -1836,11 +1917,7 @@ module( "ajax", { }); } ), - jQuery.post( service("echo/", { - requestArray: "GET", - contentType: "text/xml", - content: "5-23" - }), {}, function( xml ) { + jQuery.post( url("data/name.php?xml=5-2"), {}, 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 70f5ab9e7..8382b6282 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2148,7 +2148,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" ); });