guff-compass 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +21 -0
  3. data/.gitignore +6 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +21 -0
  6. data/demo/bower_components/jquery/.bower.json +21 -0
  7. data/demo/bower_components/jquery/.editorconfig +43 -0
  8. data/demo/bower_components/jquery/.gitattributes +2 -0
  9. data/demo/bower_components/jquery/.gitignore +14 -0
  10. data/demo/bower_components/jquery/.gitmodules +6 -0
  11. data/demo/bower_components/jquery/.jshintrc +17 -0
  12. data/demo/bower_components/jquery/.mailmap +94 -0
  13. data/demo/bower_components/jquery/AUTHORS.txt +170 -0
  14. data/demo/bower_components/jquery/CONTRIBUTING.md +216 -0
  15. data/demo/bower_components/jquery/Gruntfile.js +594 -0
  16. data/demo/bower_components/jquery/MIT-LICENSE.txt +21 -0
  17. data/demo/bower_components/jquery/README.md +398 -0
  18. data/demo/bower_components/jquery/bower.json +11 -0
  19. data/demo/bower_components/jquery/build/release-notes.js +59 -0
  20. data/demo/bower_components/jquery/build/release.js +316 -0
  21. data/demo/bower_components/jquery/component.json +15 -0
  22. data/demo/bower_components/jquery/composer.json +35 -0
  23. data/demo/bower_components/jquery/jquery-migrate.js +511 -0
  24. data/demo/bower_components/jquery/jquery-migrate.min.js +3 -0
  25. data/demo/bower_components/jquery/jquery.js +9789 -0
  26. data/demo/bower_components/jquery/jquery.min.js +6 -0
  27. data/demo/bower_components/jquery/jquery.min.map +1 -0
  28. data/demo/bower_components/jquery/package.json +38 -0
  29. data/demo/bower_components/jquery/speed/benchmark.js +15 -0
  30. data/demo/bower_components/jquery/speed/benchmarker.css +65 -0
  31. data/demo/bower_components/jquery/speed/benchmarker.js +181 -0
  32. data/demo/bower_components/jquery/speed/closest.html +39 -0
  33. data/demo/bower_components/jquery/speed/css.html +82 -0
  34. data/demo/bower_components/jquery/speed/event.html +58 -0
  35. data/demo/bower_components/jquery/speed/filter.html +183 -0
  36. data/demo/bower_components/jquery/speed/find.html +179 -0
  37. data/demo/bower_components/jquery/speed/index.html +72 -0
  38. data/demo/bower_components/jquery/speed/jquery-basis.js +6238 -0
  39. data/demo/bower_components/jquery/speed/slice.vs.concat.html +47 -0
  40. data/demo/bower_components/jquery/src/.jshintrc +27 -0
  41. data/demo/bower_components/jquery/src/ajax.js +855 -0
  42. data/demo/bower_components/jquery/src/ajax/jsonp.js +80 -0
  43. data/demo/bower_components/jquery/src/ajax/script.js +86 -0
  44. data/demo/bower_components/jquery/src/ajax/xhr.js +207 -0
  45. data/demo/bower_components/jquery/src/attributes.js +659 -0
  46. data/demo/bower_components/jquery/src/callbacks.js +197 -0
  47. data/demo/bower_components/jquery/src/core.js +981 -0
  48. data/demo/bower_components/jquery/src/css.js +661 -0
  49. data/demo/bower_components/jquery/src/data.js +336 -0
  50. data/demo/bower_components/jquery/src/deferred.js +141 -0
  51. data/demo/bower_components/jquery/src/deprecated.js +11 -0
  52. data/demo/bower_components/jquery/src/dimensions.js +41 -0
  53. data/demo/bower_components/jquery/src/effects.js +732 -0
  54. data/demo/bower_components/jquery/src/event-alias.js +32 -0
  55. data/demo/bower_components/jquery/src/event.js +995 -0
  56. data/demo/bower_components/jquery/src/exports.js +21 -0
  57. data/demo/bower_components/jquery/src/intro.js +20 -0
  58. data/demo/bower_components/jquery/src/manipulation.js +744 -0
  59. data/demo/bower_components/jquery/src/offset.js +169 -0
  60. data/demo/bower_components/jquery/src/outro.js +2 -0
  61. data/demo/bower_components/jquery/src/queue.js +146 -0
  62. data/demo/bower_components/jquery/src/serialize.js +99 -0
  63. data/demo/bower_components/jquery/src/sizzle-jquery.js +7 -0
  64. data/demo/bower_components/jquery/src/support.js +246 -0
  65. data/demo/bower_components/jquery/src/traversing.js +283 -0
  66. data/demo/bower_components/jquery/src/wrap.js +66 -0
  67. data/demo/bower_components/jquery/test/.jshintignore +3 -0
  68. data/demo/bower_components/jquery/test/.jshintrc +60 -0
  69. data/demo/bower_components/jquery/test/data/1x1.jpg +0 -0
  70. data/demo/bower_components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
  71. data/demo/bower_components/jquery/test/data/atom+xml.php +4 -0
  72. data/demo/bower_components/jquery/test/data/badcall.js +1 -0
  73. data/demo/bower_components/jquery/test/data/badjson.js +1 -0
  74. data/demo/bower_components/jquery/test/data/cleanScript.html +10 -0
  75. data/demo/bower_components/jquery/test/data/core/cc_on.html +22 -0
  76. data/demo/bower_components/jquery/test/data/dashboard.xml +11 -0
  77. data/demo/bower_components/jquery/test/data/dimensions/documentLarge.html +17 -0
  78. data/demo/bower_components/jquery/test/data/dimensions/documentSmall.html +21 -0
  79. data/demo/bower_components/jquery/test/data/echoData.php +1 -0
  80. data/demo/bower_components/jquery/test/data/echoQuery.php +1 -0
  81. data/demo/bower_components/jquery/test/data/errorWithJSON.php +6 -0
  82. data/demo/bower_components/jquery/test/data/errorWithText.php +5 -0
  83. data/demo/bower_components/jquery/test/data/etag.php +21 -0
  84. data/demo/bower_components/jquery/test/data/evalScript.php +1 -0
  85. data/demo/bower_components/jquery/test/data/event/focusElem.html +16 -0
  86. data/demo/bower_components/jquery/test/data/event/longLoadScript.php +4 -0
  87. data/demo/bower_components/jquery/test/data/event/promiseReady.html +17 -0
  88. data/demo/bower_components/jquery/test/data/event/syncReady.html +23 -0
  89. data/demo/bower_components/jquery/test/data/headers.php +18 -0
  90. data/demo/bower_components/jquery/test/data/if_modified_since.php +20 -0
  91. data/demo/bower_components/jquery/test/data/iframe.html +8 -0
  92. data/demo/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js +5 -0
  93. data/demo/bower_components/jquery/test/data/json.php +13 -0
  94. data/demo/bower_components/jquery/test/data/json_obj.js +1 -0
  95. data/demo/bower_components/jquery/test/data/jsonp.php +14 -0
  96. data/demo/bower_components/jquery/test/data/manipulation/iframe-denied.html +36 -0
  97. data/demo/bower_components/jquery/test/data/name.html +1 -0
  98. data/demo/bower_components/jquery/test/data/name.php +24 -0
  99. data/demo/bower_components/jquery/test/data/nocontent.php +5 -0
  100. data/demo/bower_components/jquery/test/data/offset/absolute.html +41 -0
  101. data/demo/bower_components/jquery/test/data/offset/body.html +26 -0
  102. data/demo/bower_components/jquery/test/data/offset/fixed.html +34 -0
  103. data/demo/bower_components/jquery/test/data/offset/relative.html +31 -0
  104. data/demo/bower_components/jquery/test/data/offset/scroll.html +39 -0
  105. data/demo/bower_components/jquery/test/data/offset/static.html +31 -0
  106. data/demo/bower_components/jquery/test/data/offset/table.html +43 -0
  107. data/demo/bower_components/jquery/test/data/params_html.php +12 -0
  108. data/demo/bower_components/jquery/test/data/readywaitasset.js +1 -0
  109. data/demo/bower_components/jquery/test/data/readywaitloader.js +25 -0
  110. data/demo/bower_components/jquery/test/data/script.php +11 -0
  111. data/demo/bower_components/jquery/test/data/selector/html5_selector.html +114 -0
  112. data/demo/bower_components/jquery/test/data/selector/sizzle_cache.html +21 -0
  113. data/demo/bower_components/jquery/test/data/statusText.php +5 -0
  114. data/demo/bower_components/jquery/test/data/support/bodyBackground.html +28 -0
  115. data/demo/bower_components/jquery/test/data/support/boxSizing.html +19 -0
  116. data/demo/bower_components/jquery/test/data/support/csp.js +3 -0
  117. data/demo/bower_components/jquery/test/data/support/csp.php +22 -0
  118. data/demo/bower_components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
  119. data/demo/bower_components/jquery/test/data/support/testElementCrash.html +17 -0
  120. data/demo/bower_components/jquery/test/data/test.html +7 -0
  121. data/demo/bower_components/jquery/test/data/test.js +3 -0
  122. data/demo/bower_components/jquery/test/data/test.php +7 -0
  123. data/demo/bower_components/jquery/test/data/test2.html +5 -0
  124. data/demo/bower_components/jquery/test/data/test3.html +3 -0
  125. data/demo/bower_components/jquery/test/data/testinit.js +264 -0
  126. data/demo/bower_components/jquery/test/data/testrunner.js +371 -0
  127. data/demo/bower_components/jquery/test/data/testsuite.css +155 -0
  128. data/demo/bower_components/jquery/test/data/text.php +12 -0
  129. data/demo/bower_components/jquery/test/data/ua.txt +272 -0
  130. data/demo/bower_components/jquery/test/data/with_fries.xml +25 -0
  131. data/demo/bower_components/jquery/test/data/with_fries_over_jsonp.php +7 -0
  132. data/demo/bower_components/jquery/test/delegatetest.html +228 -0
  133. data/demo/bower_components/jquery/test/hovertest.html +158 -0
  134. data/demo/bower_components/jquery/test/index.html +337 -0
  135. data/demo/bower_components/jquery/test/jquery.js +5 -0
  136. data/demo/bower_components/jquery/test/localfile.html +75 -0
  137. data/demo/bower_components/jquery/test/networkerror.html +84 -0
  138. data/demo/bower_components/jquery/test/readywait.html +70 -0
  139. data/demo/bower_components/jquery/test/unit/ajax.js +2016 -0
  140. data/demo/bower_components/jquery/test/unit/attributes.js +1388 -0
  141. data/demo/bower_components/jquery/test/unit/callbacks.js +342 -0
  142. data/demo/bower_components/jquery/test/unit/core.js +1360 -0
  143. data/demo/bower_components/jquery/test/unit/css.js +1056 -0
  144. data/demo/bower_components/jquery/test/unit/data.js +645 -0
  145. data/demo/bower_components/jquery/test/unit/deferred.js +436 -0
  146. data/demo/bower_components/jquery/test/unit/deprecated.js +8 -0
  147. data/demo/bower_components/jquery/test/unit/dimensions.js +472 -0
  148. data/demo/bower_components/jquery/test/unit/effects.js +2242 -0
  149. data/demo/bower_components/jquery/test/unit/event.js +2755 -0
  150. data/demo/bower_components/jquery/test/unit/exports.js +7 -0
  151. data/demo/bower_components/jquery/test/unit/manipulation.js +2120 -0
  152. data/demo/bower_components/jquery/test/unit/offset.js +559 -0
  153. data/demo/bower_components/jquery/test/unit/queue.js +314 -0
  154. data/demo/bower_components/jquery/test/unit/selector.js +172 -0
  155. data/demo/bower_components/jquery/test/unit/serialize.js +148 -0
  156. data/demo/bower_components/jquery/test/unit/support.js +370 -0
  157. data/demo/bower_components/jquery/test/unit/traversing.js +797 -0
  158. data/demo/bower_components/jquery/test/unit/wrap.js +265 -0
  159. data/demo/bower_components/jquery/test/xhtml.php +5 -0
  160. data/demo/index.html +347 -0
  161. data/demo/styles/main.css +208 -0
  162. data/demo/styles/main.scss +138 -0
  163. data/docs/docco.css +506 -0
  164. data/docs/guff.html +1127 -0
  165. data/docs/public/fonts/aller-bold.eot +0 -0
  166. data/docs/public/fonts/aller-bold.ttf +0 -0
  167. data/docs/public/fonts/aller-bold.woff +0 -0
  168. data/docs/public/fonts/aller-light.eot +0 -0
  169. data/docs/public/fonts/aller-light.ttf +0 -0
  170. data/docs/public/fonts/aller-light.woff +0 -0
  171. data/docs/public/fonts/novecento-bold.eot +0 -0
  172. data/docs/public/fonts/novecento-bold.ttf +0 -0
  173. data/docs/public/fonts/novecento-bold.woff +0 -0
  174. data/docs/public/stylesheets/normalize.css +375 -0
  175. data/guff.gemspec +16 -0
  176. data/guff.scss +514 -0
  177. data/gulpfile.js +67 -0
  178. data/lib/guff.rb +4 -0
  179. data/lib/stylesheets/_guff.scss +514 -0
  180. data/package.json +19 -0
  181. data/src/_functions.scss +57 -0
  182. data/src/_mixins.scss +301 -0
  183. data/src/_reset.scss +67 -0
  184. data/src/_settings.scss +22 -0
  185. data/src/_typography.scss +67 -0
  186. metadata +259 -0
@@ -0,0 +1,5 @@
1
+ // Use the right jQuery source in iframe tests
2
+ document.write( "<script id='jquery-js' src='" +
3
+ parent.document.getElementById("jquery-js").src.replace( /^(?![^\/?#]+:)/,
4
+ parent.location.pathname.replace( /[^\/]$/, "$0/" ) ) +
5
+ "'><\x2Fscript>" );
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <title>jQuery Local File Test</title>
6
+ <!-- Includes -->
7
+ <script src="jquery.js"></script>
8
+ <style>
9
+ .error { color: red; }
10
+ .success { color: green; }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <h1>jQuery Local File Test</h1>
15
+ <h2>
16
+ Introduction
17
+ </h2>
18
+ <ul>
19
+ <li>
20
+ Access this file using the "file:" protocol,
21
+ </li>
22
+ <li>
23
+ two green "OK" strings must appear below,
24
+ </li>
25
+ <li>
26
+ Empty local files will issue errors, it's a known limitation.
27
+ </li>
28
+ </ul>
29
+ <h2>
30
+ Results
31
+ </h2>
32
+ <ul>
33
+ <li>
34
+ Success:
35
+ <span id="success">
36
+ </span>
37
+ </li>
38
+ <li>
39
+ Error:
40
+ <span id="error">
41
+ </span>
42
+ </li>
43
+ </ul>
44
+ <h2>
45
+ Logs:
46
+ </h2>
47
+ <ul id="log">
48
+ </ul>
49
+ <script>
50
+ var logUL = jQuery( "#log" );
51
+ function doLog( message, args ) {
52
+ jQuery( "<li />").appendTo( logUL ).text( message + ': "' + Array.prototype.join.call( args, '" - "' ) + '"' );
53
+ }
54
+ jQuery.ajax( "./data/badjson.js" , {
55
+ context: jQuery( "#success" ),
56
+ dataType: "text"
57
+ }).success(function( data, _, xhr ) {
58
+ doLog( "Success (" + xhr.status + ")" , arguments );
59
+ this.addClass( data ? "success" : "error" ).text( "OK" );
60
+ }).error(function( xhr ) {
61
+ doLog( "Success (" + xhr.status + ")" , arguments );
62
+ this.addClass( "error" ).text( "FAIL" );
63
+ });
64
+ jQuery.ajax( "./data/doesnotexist.ext" , {
65
+ context: jQuery( "#error" ),
66
+ dataType: "text"
67
+ }).error(function( xhr ) {
68
+ doLog( "Error (" + xhr.status + ")" , arguments );
69
+ this.addClass( "success" ).text( "OK" );
70
+ }).success(function( data, _, xhr ) {
71
+ doLog( "Error (" + xhr.status + ")" , arguments );
72
+ this.addClass( "error" ).text( "FAIL" );
73
+ });
74
+ </script>
75
+ </body>
@@ -0,0 +1,84 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <!--
4
+ Test for #8135
5
+
6
+ Thanks John Firebaugh for this test page based on his gist
7
+ https://gist.github.com/807090
8
+
9
+ Access this page through a web server, then stop said server and click the button.
10
+ -->
11
+ <head>
12
+ <title>
13
+ jQuery Network Error Test for Firefox
14
+ </title>
15
+ <style>
16
+ div { margin-top: 10px; }
17
+ </style>
18
+ <script src="jquery.js"></script>
19
+ <script type="text/javascript">
20
+ $('button').live('click', function () {
21
+ $.ajax({
22
+ url: '/',
23
+ error: function() {
24
+ console.log( "abort", arguments );
25
+ }
26
+ }).abort();
27
+ $.ajax({
28
+ url: '/',
29
+ error: function() {
30
+ console.log( "complete", arguments );
31
+ }
32
+ });
33
+ return false;
34
+ })
35
+ </script>
36
+ </head>
37
+ <body>
38
+ <h1>
39
+ jQuery Network Error Test for Firefox
40
+ </h1>
41
+ <div>
42
+ This is a test page for
43
+ <a href="http://bugs.jquery.com/ticket/8135">
44
+ #8135
45
+ </a>
46
+ which was reported in Firefox when accessing properties
47
+ of an XMLHttpRequest object after a network error occurred.
48
+ </div>
49
+ <div>Take the following steps:</div>
50
+ <ol>
51
+ <li>
52
+ make sure you accessed this page through a web server,
53
+ </li>
54
+ <li>
55
+ stop the web server,
56
+ </li>
57
+ <li>
58
+ open the console,
59
+ </li>
60
+ <li>
61
+ click this
62
+ <button>button</button>
63
+ ,
64
+ </li>
65
+ <li>
66
+ wait for both requests to fail.
67
+ </li>
68
+ </ol>
69
+ <div>
70
+ Test passes if you get two log lines:
71
+ <ul>
72
+ <li>
73
+ the first starting with "abort",
74
+ </li>
75
+ <li>
76
+ the second starting with "complete",
77
+ </li>
78
+ </ul>
79
+ </div>
80
+ <div>
81
+ Test fails if the browser notifies an exception.
82
+ </div>
83
+ </body>
84
+ </html>
@@ -0,0 +1,70 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <!--
4
+ Test for jQuery.holdReady. Needs to be a
5
+ standalone test since it deals with DOM
6
+ ready.
7
+ -->
8
+ <head>
9
+ <title>
10
+ jQuery.holdReady Test
11
+ </title>
12
+ <style>
13
+ div { margin-top: 10px; }
14
+ #output { background-color: green }
15
+ #expectedOutput { background-color: green }
16
+ </style>
17
+ <script src="jquery.js"></script>
18
+
19
+ <!-- Load the script loader that uses
20
+ jQuery.readyWait -->
21
+ <script src="data/readywaitloader.js"></script>
22
+
23
+ <script type="text/javascript">
24
+ jQuery(function() {
25
+ // The delayedMessage is defined by
26
+ // the readywaitasset.js file, so the
27
+ // next line will only work if this DOM
28
+ // ready callback is called after readyWait
29
+ // has been decremented by readywaitloader.js
30
+ // If an error occurs.
31
+ jQuery("#output").append(delayedMessage);
32
+ });
33
+ </script>
34
+ </head>
35
+ <body>
36
+ <h1>
37
+ jQuery.holdReady Test
38
+ </h1>
39
+ <p>
40
+ This is a test page for jQuery.readyWait and jQuery.holdReady,
41
+ see
42
+ <a href="http://bugs.jquery.com/ticket/6781">#6781</a>
43
+ and
44
+ <a href="http://bugs.jquery.com/ticket/8803">#8803</a>.
45
+ </p>
46
+ <p>
47
+ Test for jQuery.holdReady, which can be used
48
+ by plugins and other scripts to indicate something
49
+ important to the page is still loading and needs
50
+ to block the DOM ready callbacks that are registered
51
+ with jQuery.
52
+ </p>
53
+ <p>
54
+ Script loaders are the most likely kind of script
55
+ to use jQuery.holdReady, but it could be used by
56
+ other things like a script that loads a CSS file
57
+ and wants to pause the DOM ready callbacks.
58
+ </p>
59
+ <p>
60
+ <strong>Expected Result</strong>: The text
61
+ <span id="expectedOutput">It Worked!</span>
62
+ appears below after about <strong>2 seconds.</strong>
63
+ </p>
64
+ <p>
65
+ If there is an error in the console,
66
+ or the text does not show up, then the test failed.
67
+ </p>
68
+ <div id="output"></div>
69
+ </body>
70
+ </html>
@@ -0,0 +1,2016 @@
1
+ module( "ajax", {
2
+ setup: function() {
3
+ var jsonpCallback = this.jsonpCallback = jQuery.ajaxSettings.jsonpCallback;
4
+ jQuery.ajaxSettings.jsonpCallback = function() {
5
+ var callback = jsonpCallback.apply( this, arguments );
6
+ Globals.register( callback );
7
+ return callback;
8
+ };
9
+ },
10
+ teardown: function() {
11
+ jQuery( document ).off( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess" );
12
+ moduleTeardown.apply( this, arguments );
13
+ }
14
+ });
15
+
16
+ (function() {
17
+
18
+ if ( !jQuery.ajax || ( isLocal && !hasPHP ) ) {
19
+ return;
20
+ }
21
+
22
+ function addGlobalEvents( expected ) {
23
+ return function() {
24
+ expected = expected || "";
25
+ jQuery( document ).on( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess", function( e ) {
26
+ ok( expected.indexOf(e.type) !== -1, e.type );
27
+ });
28
+ };
29
+ }
30
+
31
+ //----------- jQuery.ajax()
32
+
33
+ ajaxTest( "jQuery.ajax() - success callbacks", 8, {
34
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"),
35
+ url: url("data/name.html"),
36
+ beforeSend: function() {
37
+ ok( true, "beforeSend" );
38
+ },
39
+ success: function() {
40
+ ok( true, "success" );
41
+ },
42
+ complete: function() {
43
+ ok( true, "complete");
44
+ }
45
+ });
46
+
47
+ ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, {
48
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"),
49
+ create: function( options ) {
50
+ return jQuery.ajax( url("data/name.html"), options );
51
+ },
52
+ beforeSend: function() {
53
+ ok( true, "beforeSend" );
54
+ },
55
+ success: function() {
56
+ ok( true, "success" );
57
+ },
58
+ complete: function() {
59
+ ok( true, "complete" );
60
+ }
61
+ });
62
+
63
+ ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, {
64
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"),
65
+ url: url("data/name.html"),
66
+ beforeSend: function() {
67
+ ok( true, "beforeSend" );
68
+ },
69
+ success: true,
70
+ afterSend: function( request ) {
71
+ request.complete(function() {
72
+ ok( true, "complete" );
73
+ }).success(function() {
74
+ ok( true, "success" );
75
+ }).error(function() {
76
+ ok( false, "error" );
77
+ });
78
+ }
79
+ });
80
+
81
+ ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, {
82
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"),
83
+ url: url("data/name.html"),
84
+ beforeSend: function() {
85
+ ok( true, "beforeSend" );
86
+ },
87
+ success: true,
88
+ complete: function( xhr ) {
89
+ xhr.complete(function() {
90
+ ok( true, "complete" );
91
+ }).success(function() {
92
+ ok( true, "success" );
93
+ }).error(function() {
94
+ ok( false, "error" );
95
+ });
96
+ }
97
+ });
98
+
99
+ ajaxTest( "jQuery.ajax() - error callbacks", 8, {
100
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"),
101
+ url: url("data/name.php?wait=5"),
102
+ beforeSend: function() {
103
+ ok( true, "beforeSend" );
104
+ },
105
+ afterSend: function( request ) {
106
+ request.abort();
107
+ },
108
+ error: function() {
109
+ ok( true, "error" );
110
+ },
111
+ complete: function() {
112
+ ok( true, "complete" );
113
+ }
114
+ });
115
+
116
+ ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, [
117
+ {
118
+ url: url("data/name.php?wait=5"),
119
+ error: function( _, textStatus, errorThrown ) {
120
+ strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" );
121
+ strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" );
122
+ },
123
+ afterSend: function( request ) {
124
+ request.abort();
125
+ }
126
+ },
127
+ {
128
+ url: url("data/name.php?wait=5"),
129
+ error: function( _, textStatus, errorThrown ) {
130
+ strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" );
131
+ strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" );
132
+ },
133
+ afterSend: function( request ) {
134
+ request.abort("mystatus");
135
+ }
136
+ }
137
+ ]);
138
+
139
+ ajaxTest( "jQuery.ajax() - responseText on error", 1, {
140
+ url: url("data/errorWithText.php"),
141
+ error: function( xhr ) {
142
+ strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" );
143
+ }
144
+ });
145
+
146
+ asyncTest( "jQuery.ajax() - retry with jQuery.ajax( this )", 2, function() {
147
+ var previousUrl,
148
+ firstTime = true;
149
+ jQuery.ajax({
150
+ url: url("data/errorWithText.php"),
151
+ error: function() {
152
+ if ( firstTime ) {
153
+ firstTime = false;
154
+ jQuery.ajax( this );
155
+ } else {
156
+ ok ( true, "Test retrying with jQuery.ajax(this) works" );
157
+ jQuery.ajax({
158
+ url: url("data/errorWithText.php"),
159
+ data: {
160
+ "x": 1
161
+ },
162
+ beforeSend: function() {
163
+ if ( !previousUrl ) {
164
+ previousUrl = this.url;
165
+ } else {
166
+ strictEqual( this.url, previousUrl, "url parameters are not re-appended" );
167
+ start();
168
+ return false;
169
+ }
170
+ },
171
+ error: function() {
172
+ jQuery.ajax( this );
173
+ }
174
+ });
175
+ }
176
+ }
177
+ });
178
+ });
179
+
180
+ ajaxTest( "jQuery.ajax() - headers", 4, {
181
+ setup: function() {
182
+ jQuery( document ).ajaxSend(function( evt, xhr ) {
183
+ xhr.setRequestHeader( "ajax-send", "test" );
184
+ });
185
+ },
186
+ url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax-send"),
187
+ headers: {
188
+ "siMPle": "value",
189
+ "SometHing-elsE": "other value",
190
+ "OthEr": "something else"
191
+ },
192
+ success: function( data, _, xhr ) {
193
+ var i, emptyHeader,
194
+ requestHeaders = jQuery.extend( this.headers, {
195
+ "ajax-send": "test"
196
+ }),
197
+ tmp = [];
198
+ for ( i in requestHeaders ) {
199
+ tmp.push( i, ": ", requestHeaders[ i ], "\n" );
200
+ }
201
+ tmp = tmp.join("");
202
+
203
+ strictEqual( data, tmp, "Headers were sent" );
204
+ strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" );
205
+
206
+ emptyHeader = xhr.getResponseHeader("Empty-Header");
207
+ if ( emptyHeader === null ) {
208
+ ok( true, "Firefox doesn't support empty headers" );
209
+ } else {
210
+ strictEqual( emptyHeader, "", "Empty header received" );
211
+ }
212
+ strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" );
213
+ }
214
+ });
215
+
216
+ ajaxTest( "jQuery.ajax() - Accept header", 1, {
217
+ url: url("data/headers.php?keys=accept"),
218
+ headers: {
219
+ Accept: "very wrong accept value"
220
+ },
221
+ beforeSend: function( xhr ) {
222
+ xhr.setRequestHeader("Accept", "*/*");
223
+ },
224
+ success: function( data ) {
225
+ strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" );
226
+ }
227
+ });
228
+
229
+ ajaxTest( "jQuery.ajax() - contentType", 2, [
230
+ {
231
+ url: url("data/headers.php?keys=content-type"),
232
+ contentType: "test",
233
+ success: function( data ) {
234
+ strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" );
235
+ }
236
+ },
237
+ {
238
+ url: url("data/headers.php?keys=content-type"),
239
+ contentType: false,
240
+ success: function( data ) {
241
+ strictEqual( data, "content-type: \n", "Test content-type is not sent when options.contentType===false" );
242
+ }
243
+ }
244
+ ]);
245
+
246
+ ajaxTest( "jQuery.ajax() - protocol-less urls", 1, {
247
+ url: "//somedomain.com",
248
+ beforeSend: function( xhr, settings ) {
249
+ equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." );
250
+ return false;
251
+ },
252
+ error: true
253
+ });
254
+
255
+ ajaxTest( "jQuery.ajax() - hash", 3, [
256
+ {
257
+ url: "data/name.html#foo",
258
+ beforeSend: function( xhr, settings ) {
259
+ equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." );
260
+ return false;
261
+ },
262
+ error: true
263
+ },
264
+ {
265
+ url: "data/name.html?abc#foo",
266
+ beforeSend: function( xhr, settings ) {
267
+ equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." );
268
+ return false;
269
+ },
270
+ error: true
271
+ },
272
+ {
273
+ url: "data/name.html?abc#foo",
274
+ data: {
275
+ "test": 123
276
+ },
277
+ beforeSend: function( xhr, settings ) {
278
+ equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." );
279
+ return false;
280
+ },
281
+ error: true
282
+ }
283
+ ]);
284
+
285
+ ajaxTest( "jQuery.ajax() - cross-domain detection", 7, function() {
286
+ function request( url, title, crossDomainOrOptions ) {
287
+ return jQuery.extend( {
288
+ dataType: "jsonp",
289
+ url: url,
290
+ beforeSend: function( _, s ) {
291
+ ok( crossDomainOrOptions === false ? !s.crossDomain : s.crossDomain, title );
292
+ return false;
293
+ },
294
+ error: true
295
+ }, crossDomainOrOptions );
296
+ }
297
+
298
+ var loc = document.location,
299
+ samePort = loc.port || ( loc.protocol === "http:" ? 80 : 443 ),
300
+ otherPort = loc.port === 666 ? 667 : 666,
301
+ otherProtocol = loc.protocol === "http:" ? "https:" : "http:";
302
+
303
+ return [
304
+ request(
305
+ loc.protocol + "//" + loc.host + ":" + samePort,
306
+ "Test matching ports are not detected as cross-domain",
307
+ false
308
+ ),
309
+ request(
310
+ otherProtocol + "//" + loc.host,
311
+ "Test different protocols are detected as cross-domain"
312
+ ),
313
+ request(
314
+ "app:/path",
315
+ "Adobe AIR app:/ URL detected as cross-domain"
316
+ ),
317
+ request(
318
+ loc.protocol + "//example.invalid:" + ( loc.port || 80 ),
319
+ "Test different hostnames are detected as cross-domain"
320
+ ),
321
+ request(
322
+ loc.protocol + "//" + loc.hostname + ":" + otherPort,
323
+ "Test different ports are detected as cross-domain"
324
+ ),
325
+ request(
326
+ "about:blank",
327
+ "Test about:blank is detected as cross-domain"
328
+ ),
329
+ request(
330
+ loc.protocol + "//" + loc.host,
331
+ "Test forced crossDomain is detected as cross-domain",
332
+ {
333
+ crossDomain: true
334
+ }
335
+ )
336
+ ];
337
+ });
338
+
339
+ ajaxTest( "jQuery.ajax() - abort", 9, {
340
+ setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete"),
341
+ url: url("data/name.php?wait=5"),
342
+ beforeSend: function() {
343
+ ok( true, "beforeSend" );
344
+ },
345
+ afterSend: function( xhr ) {
346
+ strictEqual( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
347
+ xhr.abort();
348
+ strictEqual( xhr.readyState, 0, "XHR readyState indicates successful abortion" );
349
+ },
350
+ error: true,
351
+ complete: function() {
352
+ ok( true, "complete" );
353
+ }
354
+ });
355
+
356
+ ajaxTest( "jQuery.ajax() - events with context", 12, function() {
357
+
358
+ var context = document.createElement("div");
359
+
360
+ function event( e ) {
361
+ equal( this, context, e.type );
362
+ }
363
+
364
+ function callback( msg ) {
365
+ return function() {
366
+ equal( this, context, "context is preserved on callback " + msg );
367
+ };
368
+ }
369
+
370
+ return {
371
+ setup: function() {
372
+ jQuery( context ).appendTo("#foo")
373
+ .ajaxSend( event )
374
+ .ajaxComplete( event )
375
+ .ajaxError( event )
376
+ .ajaxSuccess( event );
377
+ },
378
+ requests: [{
379
+ url: url("data/name.html"),
380
+ context: context,
381
+ beforeSend: callback("beforeSend"),
382
+ success: callback("success"),
383
+ complete: callback("complete")
384
+ }, {
385
+ url: url("data/404.html"),
386
+ context: context,
387
+ beforeSend: callback("beforeSend"),
388
+ error: callback("error"),
389
+ complete: callback("complete")
390
+ }]
391
+ };
392
+ });
393
+
394
+ ajaxTest( "jQuery.ajax() - events without context", 3, function() {
395
+ function nocallback( msg ) {
396
+ return function() {
397
+ equal( typeof this.url, "string", "context is settings on callback " + msg );
398
+ };
399
+ }
400
+ return {
401
+ url: url("data/404.html"),
402
+ beforeSend: nocallback("beforeSend"),
403
+ error: nocallback("error"),
404
+ complete: nocallback("complete")
405
+ };
406
+ });
407
+
408
+ ajaxTest( "jQuery.ajax() - context modification", 1, {
409
+ url: url("data/name.html"),
410
+ context: {},
411
+ beforeSend: function() {
412
+ this.test = "foo";
413
+ },
414
+ afterSend: function() {
415
+ strictEqual( this.context.test, "foo", "Make sure the original object is maintained." );
416
+ },
417
+ success: true
418
+ });
419
+
420
+ ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function() {
421
+ var obj = {};
422
+ return {
423
+ setup: function() {
424
+ jQuery.ajaxSetup({
425
+ context: obj
426
+ });
427
+ strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." );
428
+ },
429
+ requests: [{
430
+ url: url("data/name.html"),
431
+ success: function() {
432
+ strictEqual( this, obj, "Make sure the original object is maintained." );
433
+ }
434
+ }, {
435
+ url: url("data/name.html"),
436
+ context: {},
437
+ success: function() {
438
+ ok( this !== obj, "Make sure overriding context is possible." );
439
+ }
440
+ }]
441
+ };
442
+ });
443
+
444
+ ajaxTest( "jQuery.ajax() - disabled globals", 3, {
445
+ setup: addGlobalEvents(""),
446
+ global: false,
447
+ url: url("data/name.html"),
448
+ beforeSend: function() {
449
+ ok( true, "beforeSend" );
450
+ },
451
+ success: function() {
452
+ ok( true, "success" );
453
+ },
454
+ complete: function() {
455
+ ok( true, "complete" );
456
+ }
457
+ });
458
+
459
+ ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, {
460
+ url: url("data/with_fries.xml"),
461
+ dataType: "xml",
462
+ success: function( resp ) {
463
+ equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" );
464
+ equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" );
465
+ equal( jQuery( "thing", resp ).length, 2, "things in responseXML" );
466
+ }
467
+ });
468
+
469
+ ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, {
470
+ url: url("data/with_fries_over_jsonp.php"),
471
+ dataType: "jsonp xml",
472
+ success: function( resp ) {
473
+ equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" );
474
+ equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" );
475
+ equal( jQuery( "thing", resp ).length, 2, "things in responseXML" );
476
+ }
477
+ });
478
+
479
+ ajaxTest( "jQuery.ajax() - HEAD requests", 2, [
480
+ {
481
+ url: url("data/name.html"),
482
+ type: "HEAD",
483
+ success: function( data, status, xhr ) {
484
+ ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response" );
485
+ }
486
+ },
487
+ {
488
+ url: url("data/name.html"),
489
+ data: {
490
+ "whip_it": "good"
491
+ },
492
+ type: "HEAD",
493
+ success: function( data, status, xhr ) {
494
+ ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response with data" );
495
+ }
496
+ }
497
+ ]);
498
+
499
+ ajaxTest( "jQuery.ajax() - beforeSend", 1, {
500
+ url: url("data/name.html"),
501
+ beforeSend: function() {
502
+ this.check = true;
503
+ },
504
+ success: function() {
505
+ ok( this.check, "check beforeSend was executed" );
506
+ }
507
+ });
508
+
509
+ ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, {
510
+ create: function() {
511
+ return jQuery.ajax({
512
+ url: url("data/name.html"),
513
+ beforeSend: function( xhr ) {
514
+ ok( true, "beforeSend got called, canceling" );
515
+ xhr.abort();
516
+ },
517
+ success: function() {
518
+ ok( false, "request didn't get canceled" );
519
+ },
520
+ complete: function() {
521
+ ok( false, "request didn't get canceled" );
522
+ },
523
+ error: function() {
524
+ ok( false, "request didn't get canceled" );
525
+ }
526
+ });
527
+ },
528
+ fail: function( _, reason ) {
529
+ strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" );
530
+ }
531
+ });
532
+
533
+ ajaxTest( "jQuery.ajax() - dataType html", 5, {
534
+ setup: function() {
535
+ Globals.register("testFoo");
536
+ Globals.register("testBar");
537
+ },
538
+ dataType: "html",
539
+ url: url("data/test.html"),
540
+ success: function( data ) {
541
+ ok( data.match( /^html text/ ), "Check content for datatype html" );
542
+ jQuery("#ap").html( data );
543
+ strictEqual( window["testFoo"], "foo", "Check if script was evaluated for datatype html" );
544
+ strictEqual( window["testBar"], "bar", "Check if script src was evaluated for datatype html" );
545
+ }
546
+ });
547
+
548
+ ajaxTest( "jQuery.ajax() - synchronous request", 1, {
549
+ url: url("data/json_obj.js"),
550
+ dataType: "text",
551
+ async: false,
552
+ success: true,
553
+ afterSend: function( xhr ) {
554
+ ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" );
555
+ }
556
+ });
557
+
558
+ ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, {
559
+ url: url("data/json_obj.js"),
560
+ async: false,
561
+ dataType: "text",
562
+ success: true,
563
+ afterSend: function( xhr ) {
564
+ var result;
565
+ xhr.done(function( data ) {
566
+ ok( true, "success callback executed" );
567
+ result = data;
568
+ });
569
+ ok( /^\{ "data"/.test( result ), "check returned text" );
570
+ }
571
+ });
572
+
573
+ asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function() {
574
+ var target = "data/name.html",
575
+ successCount = 0,
576
+ errorCount = 0,
577
+ errorEx = "",
578
+ success = function() {
579
+ successCount++;
580
+ };
581
+ jQuery( document ).on( "ajaxError.passthru", function( e, xml ) {
582
+ errorCount++;
583
+ errorEx += ": " + xml.status;
584
+ });
585
+ jQuery( document ).one( "ajaxStop", function() {
586
+ equal( successCount, 5, "Check all ajax calls successful" );
587
+ equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" );
588
+ jQuery( document ).off("ajaxError.passthru");
589
+ start();
590
+ });
591
+ Globals.register("testBar");
592
+
593
+ ok( jQuery.get( url(target), success ), "get" );
594
+ ok( jQuery.post( url(target), success ), "post" );
595
+ ok( jQuery.getScript( url("data/test.js"), success ), "script" );
596
+ ok( jQuery.getJSON( url("data/json_obj.js"), success ), "json" );
597
+ ok( jQuery.ajax({
598
+ url: url( target ),
599
+ success: success
600
+ }), "generic" );
601
+ });
602
+
603
+ ajaxTest( "jQuery.ajax() - cache", 12, function() {
604
+
605
+ var re = /_=(.*?)(&|$)/g;
606
+
607
+ function request( url, title ) {
608
+ return {
609
+ url: url,
610
+ cache: false,
611
+ beforeSend: function() {
612
+ var parameter, tmp;
613
+ while(( tmp = re.exec( this.url ) )) {
614
+ strictEqual( parameter, undefined, title + ": only one 'no-cache' parameter" );
615
+ parameter = tmp[ 1 ];
616
+ notStrictEqual( parameter, "tobereplaced555", title + ": parameter (if it was there) was replaced" );
617
+ }
618
+ return false;
619
+ },
620
+ error: true
621
+ };
622
+ }
623
+
624
+ return [
625
+ request(
626
+ "data/text.php",
627
+ "no parameter"
628
+ ),
629
+ request(
630
+ "data/text.php?pizza=true",
631
+ "1 parameter"
632
+ ),
633
+ request(
634
+ "data/text.php?_=tobereplaced555",
635
+ "_= parameter"
636
+ ),
637
+ request(
638
+ "data/text.php?pizza=true&_=tobereplaced555",
639
+ "1 parameter and _="
640
+ ),
641
+ request(
642
+ "data/text.php?_=tobereplaced555&tv=false",
643
+ "_= and 1 parameter"
644
+ ),
645
+ request(
646
+ "data/text.php?name=David&_=tobereplaced555&washere=true",
647
+ "2 parameters surrounding _="
648
+ )
649
+ ];
650
+ });
651
+
652
+ jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) {
653
+
654
+ ajaxTest( "jQuery.ajax() - JSONP - Query String (?n)" + label, 4, [
655
+ {
656
+ url: "data/jsonp.php?callback=?",
657
+ dataType: "jsonp",
658
+ crossDomain: crossDomain,
659
+ success: function( data ) {
660
+ ok( data.data, "JSON results returned (GET, url callback)" );
661
+ }
662
+ },
663
+ {
664
+ url: "data/jsonp.php?callback=??",
665
+ dataType: "jsonp",
666
+ crossDomain: crossDomain,
667
+ success: function( data ) {
668
+ ok( data.data, "JSON results returned (GET, url context-free callback)" );
669
+ }
670
+ },
671
+ {
672
+ url: "data/jsonp.php/??",
673
+ dataType: "jsonp",
674
+ crossDomain: crossDomain,
675
+ success: function( data ) {
676
+ ok( data.data, "JSON results returned (GET, REST-like)" );
677
+ }
678
+ },
679
+ {
680
+ url: "data/jsonp.php/???json=1",
681
+ dataType: "jsonp",
682
+ crossDomain: crossDomain,
683
+ success: function( data ) {
684
+ strictEqual( jQuery.type( data ), "array", "JSON results returned (GET, REST-like with param)" );
685
+ }
686
+ }
687
+ ]);
688
+
689
+ ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 9, {
690
+ setup: function() {
691
+ Globals.register("functionToCleanUp");
692
+ Globals.register("XXX");
693
+ Globals.register("jsonpResults");
694
+ window["jsonpResults"] = function( data ) {
695
+ ok( data["data"], "JSON results returned (GET, custom callback function)" );
696
+ };
697
+ },
698
+ requests: [{
699
+ url: "data/jsonp.php",
700
+ dataType: "jsonp",
701
+ crossDomain: crossDomain,
702
+ jsonp: "callback",
703
+ success: function( data ) {
704
+ ok( data["data"], "JSON results returned (GET, data obj callback)" );
705
+ }
706
+ }, {
707
+ url: "data/jsonp.php",
708
+ dataType: "jsonp",
709
+ crossDomain: crossDomain,
710
+ jsonpCallback: "jsonpResults",
711
+ success: function( data ) {
712
+ ok( data.data, "JSON results returned (GET, custom callback name)" );
713
+ }
714
+ }, {
715
+ url: "data/jsonp.php",
716
+ dataType: "jsonp",
717
+ crossDomain: crossDomain,
718
+ jsonpCallback: "functionToCleanUp",
719
+ success: function( data ) {
720
+ ok( data["data"], "JSON results returned (GET, custom callback name to be cleaned up)" );
721
+ strictEqual( window["functionToCleanUp"], undefined, "Callback was removed (GET, custom callback name to be cleaned up)" );
722
+ var xhr;
723
+ jQuery.ajax({
724
+ url: "data/jsonp.php",
725
+ dataType: "jsonp",
726
+ crossDomain: crossDomain,
727
+ jsonpCallback: "functionToCleanUp",
728
+ beforeSend: function( jqXHR ) {
729
+ xhr = jqXHR;
730
+ return false;
731
+ }
732
+ });
733
+ xhr.fail(function() {
734
+ ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" );
735
+ strictEqual( window["functionToCleanUp"], undefined, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" );
736
+ });
737
+ }
738
+ }, {
739
+ url: "data/jsonp.php?callback=XXX",
740
+ dataType: "jsonp",
741
+ jsonp: false,
742
+ jsonpCallback: "XXX",
743
+ crossDomain: crossDomain,
744
+ beforeSend: function() {
745
+ ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" );
746
+ },
747
+ success: function( data ) {
748
+ ok( data["data"], "JSON results returned (GET, custom callback name with no url manipulation)" );
749
+ }
750
+ }]
751
+ });
752
+
753
+ ajaxTest( "jQuery.ajax() - JSONP - Callback in data" + label, 2, [
754
+ {
755
+ url: "data/jsonp.php",
756
+ dataType: "jsonp",
757
+ crossDomain: crossDomain,
758
+ data: "callback=?",
759
+ success: function( data ) {
760
+ ok( data.data, "JSON results returned (GET, data callback)" );
761
+ }
762
+ },
763
+ {
764
+ url: "data/jsonp.php",
765
+ dataType: "jsonp",
766
+ crossDomain: crossDomain,
767
+ data: "callback=??",
768
+ success: function( data ) {
769
+ ok( data.data, "JSON results returned (GET, data context-free callback)" );
770
+ }
771
+ }
772
+ ]);
773
+
774
+
775
+ ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [
776
+ {
777
+ type: "POST",
778
+ url: "data/jsonp.php",
779
+ dataType: "jsonp",
780
+ crossDomain: crossDomain,
781
+ success: function( data ) {
782
+ ok( data["data"], "JSON results returned (POST, no callback)" );
783
+ }
784
+ },
785
+ {
786
+ type: "POST",
787
+ url: "data/jsonp.php",
788
+ data: "callback=?",
789
+ dataType: "jsonp",
790
+ crossDomain: crossDomain,
791
+ success: function( data ) {
792
+ ok( data["data"], "JSON results returned (POST, data callback)" );
793
+ }
794
+ },
795
+ {
796
+ type: "POST",
797
+ url: "data/jsonp.php",
798
+ jsonp: "callback",
799
+ dataType: "jsonp",
800
+ crossDomain: crossDomain,
801
+ success: function( data ) {
802
+ ok( data["data"], "JSON results returned (POST, data obj callback)" );
803
+ }
804
+ }
805
+ ]);
806
+
807
+ ajaxTest( "jQuery.ajax() - JSONP" + label, 3, [
808
+ {
809
+ url: "data/jsonp.php",
810
+ dataType: "jsonp",
811
+ crossDomain: crossDomain,
812
+ success: function( data ) {
813
+ ok( data.data, "JSON results returned (GET, no callback)" );
814
+ }
815
+ },
816
+ {
817
+ create: function( options ) {
818
+ var request = jQuery.ajax( options ),
819
+ promise = request.then(function( data ) {
820
+ ok( data.data, "first request: JSON results returned (GET, no callback)" );
821
+ request = jQuery.ajax( this ).done(function( data ) {
822
+ ok( data.data, "this re-used: JSON results returned (GET, no callback)" );
823
+ });
824
+ promise.abort = request.abort;
825
+ return request;
826
+ });
827
+ promise.abort = request.abort;
828
+ return promise;
829
+ },
830
+ url: "data/jsonp.php",
831
+ dataType: "jsonp",
832
+ crossDomain: crossDomain,
833
+ success: true
834
+ }
835
+ ]);
836
+
837
+ });
838
+
839
+ ajaxTest( "jQuery.ajax() - script, Remote", 2, {
840
+ setup: function() {
841
+ Globals.register("testBar");
842
+ },
843
+ url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js",
844
+ dataType: "script",
845
+ success: function() {
846
+ strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" );
847
+ }
848
+ });
849
+
850
+ ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, {
851
+ setup: function() {
852
+ Globals.register("testBar");
853
+ },
854
+ url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js",
855
+ type: "POST",
856
+ dataType: "script",
857
+ success: function( data, status ) {
858
+ strictEqual( window["testBar"], "bar", "Script results returned (POST, no callback)" );
859
+ strictEqual( status, "success", "Script results returned (POST, no callback)" );
860
+ }
861
+ });
862
+
863
+ ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, {
864
+ setup: function() {
865
+ Globals.register("testBar");
866
+ },
867
+ url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/test.js",
868
+ dataType: "script",
869
+ success: function() {
870
+ strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" );
871
+ }
872
+ });
873
+
874
+ ajaxTest( "jQuery.ajax() - malformed JSON", 2, {
875
+ url: "data/badjson.js",
876
+ dataType: "json",
877
+ error: function( xhr, msg, detailedMsg ) {
878
+ strictEqual( msg, "parsererror", "A parse error occurred." );
879
+ ok( /(invalid|error|exception)/i.test( detailedMsg ), "Detailed parsererror message provided" );
880
+ }
881
+ });
882
+
883
+ ajaxTest( "jQuery.ajax() - script by content-type", 2, [
884
+ {
885
+ url: "data/script.php",
886
+ data: {
887
+ "header": "script"
888
+ },
889
+ success: true
890
+ },
891
+ {
892
+ url: "data/script.php",
893
+ data: {
894
+ "header": "ecma"
895
+ },
896
+ success: true
897
+ }
898
+ ]);
899
+
900
+ ajaxTest( "jQuery.ajax() - JSON by content-type", 5, {
901
+ url: "data/json.php",
902
+ data: {
903
+ "header": "json",
904
+ "json": "array"
905
+ },
906
+ success: function( json ) {
907
+ ok( json.length >= 2, "Check length" );
908
+ strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" );
909
+ strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" );
910
+ strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" );
911
+ strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" );
912
+ }
913
+ });
914
+
915
+ ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, {
916
+ url: url("data/json.php"),
917
+ data: {
918
+ "header": "json",
919
+ "json": "array"
920
+ },
921
+ contents: {
922
+ "json": false
923
+ },
924
+ success: function( text ) {
925
+ strictEqual( typeof text, "string", "json wasn't auto-determined" );
926
+ var json = jQuery.parseJSON( text );
927
+ ok( json.length >= 2, "Check length");
928
+ strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" );
929
+ strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" );
930
+ strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" );
931
+ strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" );
932
+ }
933
+ });
934
+
935
+ ajaxTest( "jQuery.ajax() - simple get", 1, {
936
+ type: "GET",
937
+ url: url("data/name.php?name=foo"),
938
+ success: function( msg ) {
939
+ strictEqual( msg, "bar", "Check for GET" );
940
+ }
941
+ });
942
+
943
+ ajaxTest( "jQuery.ajax() - simple post", 1, {
944
+ type: "POST",
945
+ url: url("data/name.php"),
946
+ data: "name=peter",
947
+ success: function( msg ) {
948
+ strictEqual( msg, "pan", "Check for POST" );
949
+ }
950
+ });
951
+
952
+ ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, {
953
+ url: "data/echoData.php",
954
+ data: undefined,
955
+ type: "post",
956
+ success: function( result ) {
957
+ strictEqual( result, "" );
958
+ }
959
+ });
960
+
961
+ var ifModifiedNow = new Date();
962
+
963
+ jQuery.each(
964
+ /* jQuery.each arguments start */
965
+ {
966
+ " (cache)": true,
967
+ " (no cache)": false
968
+ },
969
+ function( label, cache ) {
970
+ var isOpera = !!window.opera;
971
+
972
+ asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 3, function() {
973
+ var url = "data/if_modified_since.php?ts=" + ifModifiedNow++;
974
+
975
+ jQuery.ajax({
976
+ url: url,
977
+ ifModified: true,
978
+ cache: cache,
979
+ success: function( data, status ) {
980
+ strictEqual( status, "success" );
981
+
982
+ jQuery.ajax({
983
+ url: url,
984
+ ifModified: true,
985
+ cache: cache,
986
+ success: function( data, status ) {
987
+ if ( data === "FAIL" ) {
988
+ ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
989
+ ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')." );
990
+ } else {
991
+ strictEqual( status, "notmodified" );
992
+ ok( data == null, "response body should be empty" );
993
+ }
994
+ start();
995
+ },
996
+ error: function() {
997
+ // Do this because opera simply refuses to implement 304 handling :(
998
+ // A feature-driven way of detecting this would be appreciated
999
+ // See: http://gist.github.com/599419
1000
+ ok( isOpera, "error" );
1001
+ ok( isOpera, "error" );
1002
+ start();
1003
+ }
1004
+ });
1005
+ },
1006
+ error: function() {
1007
+ strictEqual( false, "error" );
1008
+ // Do this because opera simply refuses to implement 304 handling :(
1009
+ // A feature-driven way of detecting this would be appreciated
1010
+ // See: http://gist.github.com/599419
1011
+ ok( isOpera, "error" );
1012
+ start();
1013
+ }
1014
+ });
1015
+ });
1016
+
1017
+ asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() {
1018
+ var url = "data/etag.php?ts=" + ifModifiedNow++;
1019
+
1020
+ jQuery.ajax({
1021
+ url: url,
1022
+ ifModified: true,
1023
+ cache: cache,
1024
+ success: function( data, status ) {
1025
+ strictEqual( status, "success" );
1026
+
1027
+ jQuery.ajax({
1028
+ url: url,
1029
+ ifModified: true,
1030
+ cache: cache,
1031
+ success: function( data, status ) {
1032
+ if ( data === "FAIL" ) {
1033
+ ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." );
1034
+ ok( isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')." );
1035
+ } else {
1036
+ strictEqual( status, "notmodified" );
1037
+ ok( data == null, "response body should be empty" );
1038
+ }
1039
+ start();
1040
+ },
1041
+ error: function() {
1042
+ // Do this because opera simply refuses to implement 304 handling :(
1043
+ // A feature-driven way of detecting this would be appreciated
1044
+ // See: http://gist.github.com/599419
1045
+ ok( isOpera, "error" );
1046
+ ok( isOpera, "error" );
1047
+ start();
1048
+ }
1049
+ });
1050
+ },
1051
+ error: function() {
1052
+ // Do this because opera simply refuses to implement 304 handling :(
1053
+ // A feature-driven way of detecting this would be appreciated
1054
+ // See: http://gist.github.com/599419
1055
+ ok( isOpera, "error" );
1056
+ start();
1057
+ }
1058
+ });
1059
+ });
1060
+ }
1061
+ /* jQuery.each arguments end */
1062
+ );
1063
+
1064
+ ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, {
1065
+ // see RFC 2606
1066
+ url: "http://example.invalid",
1067
+ error: function( xhr, _, e ) {
1068
+ ok( true, "file not found: " + xhr.status + " => " + e );
1069
+ }
1070
+ });
1071
+
1072
+ ajaxTest( "jQuery.ajax() - failing cross-domain", 1, {
1073
+ url: "http://" + externalHost,
1074
+ error: function( xhr, _, e ) {
1075
+ ok( true, "access denied: " + xhr.status + " => " + e );
1076
+ }
1077
+ });
1078
+
1079
+ ajaxTest( "jQuery.ajax() - atom+xml", 1, {
1080
+ url: url("data/atom+xml.php"),
1081
+ success: function() {
1082
+ ok( true, "success" );
1083
+ }
1084
+ });
1085
+
1086
+ asyncTest( "jQuery.ajax() - statusText", 3, function() {
1087
+ jQuery.ajax( url("data/statusText.php?status=200&text=Hello") ).done(function( _, statusText, jqXHR ) {
1088
+ strictEqual( statusText, "success", "callback status text ok for success" );
1089
+ ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" );
1090
+ jQuery.ajax( url("data/statusText.php?status=404&text=World") ).fail(function( jqXHR, statusText ) {
1091
+ strictEqual( statusText, "error", "callback status text ok for error" );
1092
+ // ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" );
1093
+ start();
1094
+ });
1095
+ });
1096
+ });
1097
+
1098
+ asyncTest( "jQuery.ajax() - statusCode", 20, function() {
1099
+
1100
+ var count = 12;
1101
+
1102
+ function countComplete() {
1103
+ if ( ! --count ) {
1104
+ start();
1105
+ }
1106
+ }
1107
+
1108
+ function createStatusCodes( name, isSuccess ) {
1109
+ name = "Test " + name + " " + ( isSuccess ? "success" : "error" );
1110
+ return {
1111
+ 200: function() {
1112
+ ok( isSuccess, name );
1113
+ },
1114
+ 404: function() {
1115
+ ok( !isSuccess, name );
1116
+ }
1117
+ };
1118
+ }
1119
+
1120
+ jQuery.each(
1121
+ /* jQuery.each arguments start */
1122
+ {
1123
+ "data/name.html": true,
1124
+ "data/someFileThatDoesNotExist.html": false
1125
+ },
1126
+ function( uri, isSuccess ) {
1127
+
1128
+ jQuery.ajax( url(uri), {
1129
+ statusCode: createStatusCodes( "in options", isSuccess ),
1130
+ complete: countComplete
1131
+ });
1132
+
1133
+ jQuery.ajax( url(uri), {
1134
+ complete: countComplete
1135
+ }).statusCode( createStatusCodes("immediately with method", isSuccess) );
1136
+
1137
+ jQuery.ajax( url(uri), {
1138
+ complete: function( jqXHR ) {
1139
+ jqXHR.statusCode( createStatusCodes("on complete", isSuccess) );
1140
+ countComplete();
1141
+ }
1142
+ });
1143
+
1144
+ jQuery.ajax( url(uri), {
1145
+ complete: function( jqXHR ) {
1146
+ setTimeout(function() {
1147
+ jqXHR.statusCode( createStatusCodes("very late binding", isSuccess) );
1148
+ countComplete();
1149
+ }, 100 );
1150
+ }
1151
+ });
1152
+
1153
+ jQuery.ajax( url(uri), {
1154
+ statusCode: createStatusCodes( "all (options)", isSuccess ),
1155
+ complete: function( jqXHR ) {
1156
+ jqXHR.statusCode( createStatusCodes("all (on complete)", isSuccess) );
1157
+ setTimeout(function() {
1158
+ jqXHR.statusCode( createStatusCodes("all (very late binding)", isSuccess) );
1159
+ countComplete();
1160
+ }, 100 );
1161
+ }
1162
+ }).statusCode( createStatusCodes("all (immediately with method)", isSuccess) );
1163
+
1164
+ var testString = "";
1165
+
1166
+ jQuery.ajax( url(uri), {
1167
+ success: function( a, b, jqXHR ) {
1168
+ ok( isSuccess, "success" );
1169
+ var statusCode = {};
1170
+ statusCode[ jqXHR.status ] = function() {
1171
+ testString += "B";
1172
+ };
1173
+ jqXHR.statusCode( statusCode );
1174
+ testString += "A";
1175
+ },
1176
+ error: function( jqXHR ) {
1177
+ ok( !isSuccess, "error" );
1178
+ var statusCode = {};
1179
+ statusCode[ jqXHR.status ] = function() {
1180
+ testString += "B";
1181
+ };
1182
+ jqXHR.statusCode( statusCode );
1183
+ testString += "A";
1184
+ },
1185
+ complete: function() {
1186
+ strictEqual(
1187
+ testString,
1188
+ "AB",
1189
+ "Test statusCode callbacks are ordered like " + ( isSuccess ? "success" : "error" ) + " callbacks"
1190
+ );
1191
+ countComplete();
1192
+ }
1193
+ });
1194
+
1195
+ }
1196
+ /* jQuery.each arguments end*/
1197
+ );
1198
+ });
1199
+
1200
+ ajaxTest( "jQuery.ajax() - transitive conversions", 8, [
1201
+ {
1202
+ url: url("data/json.php"),
1203
+ converters: {
1204
+ "json myJson": function( data ) {
1205
+ ok( true, "converter called" );
1206
+ return data;
1207
+ }
1208
+ },
1209
+ dataType: "myJson",
1210
+ success: function() {
1211
+ ok( true, "Transitive conversion worked" );
1212
+ strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text" );
1213
+ strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType" );
1214
+ }
1215
+ },
1216
+ {
1217
+ url: url("data/json.php"),
1218
+ converters: {
1219
+ "json myJson": function( data ) {
1220
+ ok( true, "converter called (*)" );
1221
+ return data;
1222
+ }
1223
+ },
1224
+ contents: false, /* headers are wrong so we ignore them */
1225
+ dataType: "* myJson",
1226
+ success: function() {
1227
+ ok( true, "Transitive conversion worked (*)" );
1228
+ strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text (*)" );
1229
+ strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" );
1230
+ }
1231
+ }
1232
+ ]);
1233
+
1234
+ ajaxTest( "jQuery.ajax() - overrideMimeType", 2, [
1235
+ {
1236
+ url: url("data/json.php"),
1237
+ beforeSend: function( xhr ) {
1238
+ xhr.overrideMimeType( "application/json" );
1239
+ },
1240
+ success: function( json ) {
1241
+ ok( json.data, "Mimetype overridden using beforeSend" );
1242
+ }
1243
+ },
1244
+ {
1245
+ url: url("data/json.php"),
1246
+ mimeType: "application/json",
1247
+ success: function( json ) {
1248
+ ok( json.data, "Mimetype overridden using mimeType option" );
1249
+ }
1250
+ }
1251
+ ]);
1252
+
1253
+ ajaxTest( "jQuery.ajax() - empty json gets to error callback instead of success callback.", 1, {
1254
+ url: url("data/echoData.php"),
1255
+ error: function( _, __, error ) {
1256
+ equal( typeof error === "object", true, "Didn't get back error object for empty json response" );
1257
+ },
1258
+ dataType: "json"
1259
+ });
1260
+
1261
+ ajaxTest( "#2688 - jQuery.ajax() - beforeSend, cancel request", 2, {
1262
+ create: function() {
1263
+ return jQuery.ajax({
1264
+ url: url("data/name.html"),
1265
+ beforeSend: function() {
1266
+ ok( true, "beforeSend got called, canceling" );
1267
+ return false;
1268
+ },
1269
+ success: function() {
1270
+ ok( false, "request didn't get canceled" );
1271
+ },
1272
+ complete: function() {
1273
+ ok( false, "request didn't get canceled" );
1274
+ },
1275
+ error: function() {
1276
+ ok( false, "request didn't get canceled" );
1277
+ }
1278
+ });
1279
+ },
1280
+ fail: function( _, reason ) {
1281
+ strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" );
1282
+ }
1283
+ });
1284
+
1285
+ ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, {
1286
+ url: "data/echoQuery.php",
1287
+ data: {
1288
+ key: function() {
1289
+ return "value";
1290
+ }
1291
+ },
1292
+ success: function( result ) {
1293
+ strictEqual( result, "key=value" );
1294
+ }
1295
+ });
1296
+
1297
+ test( "#7531 - jQuery.ajax() - Location object as url", 1, function () {
1298
+ var xhr,
1299
+ success = false;
1300
+ try {
1301
+ xhr = jQuery.ajax({
1302
+ url: window.location
1303
+ });
1304
+ success = true;
1305
+ xhr.abort();
1306
+ } catch (e) {
1307
+
1308
+ }
1309
+ ok( success, "document.location did not generate exception" );
1310
+ });
1311
+
1312
+ jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) {
1313
+ ajaxTest( "#7578 - jQuery.ajax() - JSONP - default for cache option" + label, 1, {
1314
+ url: "data/jsonp.php",
1315
+ dataType: "jsonp",
1316
+ crossDomain: crossDomain,
1317
+ beforeSend: function() {
1318
+ strictEqual( this.cache, false, "cache must be false on JSON request" );
1319
+ return false;
1320
+ },
1321
+ error: true
1322
+ });
1323
+ });
1324
+
1325
+ ajaxTest( "#8107 - jQuery.ajax() - multiple method signatures introduced in 1.5", 4, [
1326
+ {
1327
+ create: function() {
1328
+ return jQuery.ajax();
1329
+ },
1330
+ done: function() {
1331
+ ok( true, "With no arguments" );
1332
+ }
1333
+ },
1334
+ {
1335
+ create: function() {
1336
+ return jQuery.ajax("data/name.html");
1337
+ },
1338
+ done: function() {
1339
+ ok( true, "With only string URL argument" );
1340
+ }
1341
+ },
1342
+ {
1343
+ create: function() {
1344
+ return jQuery.ajax( "data/name.html", {});
1345
+ },
1346
+ done: function() {
1347
+ ok( true, "With string URL param and map" );
1348
+ }
1349
+ },
1350
+ {
1351
+ create: function( options ) {
1352
+ return jQuery.ajax( options );
1353
+ },
1354
+ url: "data/name.html",
1355
+ success: function() {
1356
+ ok( true, "With only map" );
1357
+ }
1358
+ }
1359
+ ]);
1360
+
1361
+ jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) {
1362
+ ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 2, {
1363
+ url: "data/jsonp.php",
1364
+ dataType: "jsonp",
1365
+ crossDomain: crossDomain,
1366
+ beforeSend: function( jqXHR, s ) {
1367
+ s.callback = s.jsonpCallback;
1368
+ },
1369
+ success: function() {
1370
+ var previous = this;
1371
+ strictEqual( previous.jsonpCallback, undefined, "jsonpCallback option is set back to default in callbacks" );
1372
+ jQuery.ajax({
1373
+ url: "data/jsonp.php",
1374
+ dataType: "jsonp",
1375
+ crossDomain: crossDomain,
1376
+ beforeSend: function() {
1377
+ strictEqual( this.jsonpCallback, previous.callback, "JSONP callback name is re-used" );
1378
+ return false;
1379
+ }
1380
+ });
1381
+ }
1382
+ });
1383
+ });
1384
+
1385
+ test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", 2, function () {
1386
+ var success = false,
1387
+ context = {};
1388
+ context.field = context;
1389
+ try {
1390
+ jQuery.ajax( "non-existing", {
1391
+ context: context,
1392
+ beforeSend: function() {
1393
+ ok( this === context, "context was not deep extended" );
1394
+ return false;
1395
+ }
1396
+ });
1397
+ success = true;
1398
+ } catch ( e ) {
1399
+ console.log( e );
1400
+ }
1401
+ ok( success, "context with circular reference did not generate an exception" );
1402
+ });
1403
+
1404
+ jQuery.each( [ "as argument", "in settings object" ], function( inSetting, title ) {
1405
+
1406
+ function request( url, test ) {
1407
+ return {
1408
+ create: function() {
1409
+ return jQuery.ajax( inSetting ? { url: url } : url );
1410
+ },
1411
+ done: function() {
1412
+ ok( true, ( test || url ) + " " + title );
1413
+ }
1414
+ };
1415
+ }
1416
+
1417
+ ajaxTest( "#10093 - jQuery.ajax() - falsy url " + title, 4, [
1418
+ request( "", "empty string" ),
1419
+ request( false ),
1420
+ request( null ),
1421
+ request( undefined )
1422
+ ]);
1423
+
1424
+ });
1425
+
1426
+ ajaxTest( "#11151 - jQuery.ajax() - parse error body", 2, {
1427
+ url: url("data/errorWithJSON.php"),
1428
+ dataFilter: function( string ) {
1429
+ ok( false, "dataFilter called" );
1430
+ return string;
1431
+ },
1432
+ error: function( jqXHR ) {
1433
+ strictEqual( jqXHR.responseText, "{ \"code\": 40, \"message\": \"Bad Request\" }", "Error body properly set" );
1434
+ deepEqual( jqXHR.responseJSON, { code: 40, message: "Bad Request" }, "Error body properly parsed" );
1435
+ }
1436
+ });
1437
+
1438
+ ajaxTest( "#11426 - jQuery.ajax() - loading binary data shouldn't throw an exception in IE", 1, {
1439
+ url: url("data/1x1.jpg"),
1440
+ success: function( data ) {
1441
+ ok( data === undefined || /JFIF/.test( data ), "success callback reached" );
1442
+ }
1443
+ });
1444
+
1445
+ test( "#11743 - jQuery.ajax() - script, throws exception", 1, function() {
1446
+ raises(function() {
1447
+ jQuery.ajax({
1448
+ url: "data/badjson.js",
1449
+ dataType: "script",
1450
+ throws: true,
1451
+ // TODO find a way to test this asynchronously, too
1452
+ async: false,
1453
+ // Global events get confused by the exception
1454
+ global: false,
1455
+ success: function() {
1456
+ ok( false, "Success." );
1457
+ },
1458
+ error: function() {
1459
+ ok( false, "Error." );
1460
+ }
1461
+ });
1462
+ }, "exception bubbled" );
1463
+ });
1464
+
1465
+ jQuery.each( [ "method", "type" ], function( _, globalOption ) {
1466
+
1467
+ function request( option ) {
1468
+ var options = {
1469
+ url: url("data/echoData.php"),
1470
+ data: "hello",
1471
+ success: function( msg ) {
1472
+ strictEqual( msg, "hello", "Check for POST (no override)" );
1473
+ }
1474
+ };
1475
+ if ( option ) {
1476
+ options[ option ] = "GET";
1477
+ options.success = function( msg ) {
1478
+ strictEqual( msg, "", "Check for no POST (overriding with " + option + ")" );
1479
+ };
1480
+ }
1481
+ return options;
1482
+ }
1483
+
1484
+ ajaxTest( "#12004 - jQuery.ajax() - method is an alias of type - " + globalOption + " set globally", 3, {
1485
+ setup: function() {
1486
+ var options = {};
1487
+ options[ globalOption ] = "POST";
1488
+ jQuery.ajaxSetup( options );
1489
+ },
1490
+ requests: [
1491
+ request("type"),
1492
+ request("method"),
1493
+ request()
1494
+ ]
1495
+ });
1496
+
1497
+ });
1498
+
1499
+ ajaxTest( "#13276 - jQuery.ajax() - compatibility between XML documents from ajax requests and parsed string", 1, {
1500
+ url: "data/dashboard.xml",
1501
+ dataType: "xml",
1502
+ success: function( ajaxXML ) {
1503
+ var parsedXML = jQuery( jQuery.parseXML("<tab title=\"Added\">blibli</tab>") ).find("tab");
1504
+ ajaxXML = jQuery( ajaxXML );
1505
+ try {
1506
+ ajaxXML.find("infowindowtab").append( parsedXML );
1507
+ } catch( e ) {
1508
+ strictEqual( e, undefined, "error" );
1509
+ return;
1510
+ }
1511
+ strictEqual( ajaxXML.find("tab").length, 3, "Parsed node was added properly" );
1512
+ }
1513
+ });
1514
+
1515
+ ajaxTest( "#13292 - jQuery.ajax() - converter is bypassed for 204 requests", 3, {
1516
+ url: "data/nocontent.php",
1517
+ dataType: "testing",
1518
+ converters: {
1519
+ "* testing": function() {
1520
+ throw "converter was called";
1521
+ }
1522
+ },
1523
+ success: function( data, status, jqXHR ) {
1524
+ strictEqual( jqXHR.status, 204, "status code is 204" );
1525
+ strictEqual( status, "nocontent", "status text is 'nocontent'" );
1526
+ strictEqual( data, undefined, "data is undefined" );
1527
+ },
1528
+ error: function( _, status, error ) {
1529
+ ok( false, "error" );
1530
+ strictEqual( status, "parsererror", "Parser Error" );
1531
+ strictEqual( error, "converter was called", "Converter was called" );
1532
+ }
1533
+ });
1534
+
1535
+ ajaxTest( "#13388 - jQuery.ajax() - responseXML", 3, {
1536
+ url: url("data/with_fries.xml"),
1537
+ dataType: "xml",
1538
+ success: function( resp, _, jqXHR ) {
1539
+ notStrictEqual( resp, undefined, "XML document exists" );
1540
+ ok( "responseXML" in jqXHR, "jqXHR.responseXML exists" );
1541
+ strictEqual( resp, jqXHR.responseXML, "jqXHR.responseXML is set correctly" );
1542
+ }
1543
+ });
1544
+
1545
+ ajaxTest( "#13922 - jQuery.ajax() - converter is bypassed for HEAD requests", 3, {
1546
+ url: "data/json.php",
1547
+ method: "HEAD",
1548
+ data: {
1549
+ header: "yes"
1550
+ },
1551
+ converters: {
1552
+ "text json": function() {
1553
+ throw "converter was called";
1554
+ }
1555
+ },
1556
+ success: function( data, status ) {
1557
+ ok( true, "success" );
1558
+ strictEqual( status, "nocontent", "data is undefined" );
1559
+ strictEqual( data, undefined, "data is undefined" );
1560
+ },
1561
+ error: function( _, status, error ) {
1562
+ ok( false, "error" );
1563
+ strictEqual( status, "parsererror", "Parser Error" );
1564
+ strictEqual( error, "converter was called", "Converter was called" );
1565
+ }
1566
+ } );
1567
+
1568
+ //----------- jQuery.ajaxPrefilter()
1569
+
1570
+ ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {
1571
+ setup: function() {
1572
+ jQuery.ajaxPrefilter(function( options, _, jqXHR ) {
1573
+ if ( options.abortInPrefilter ) {
1574
+ jqXHR.abort();
1575
+ }
1576
+ });
1577
+ },
1578
+ abortInPrefilter: true,
1579
+ error: function() {
1580
+ ok( false, "error callback called" );
1581
+ },
1582
+ fail: function( _, reason ) {
1583
+ strictEqual( reason, "canceled", "Request aborted by the prefilter must fail with 'canceled' status text" );
1584
+ }
1585
+ });
1586
+
1587
+ //----------- jQuery.ajaxSetup()
1588
+
1589
+ asyncTest( "jQuery.ajaxSetup()", 1, function() {
1590
+ jQuery.ajaxSetup({
1591
+ url: url("data/name.php?name=foo"),
1592
+ success: function( msg ) {
1593
+ strictEqual( msg, "bar", "Check for GET" );
1594
+ start();
1595
+ }
1596
+ });
1597
+ jQuery.ajax();
1598
+ });
1599
+
1600
+ asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function() {
1601
+ var passed = 0,
1602
+ pass = function() {
1603
+ ok( passed++ < 2, "Error callback executed" );
1604
+ if ( passed === 2 ) {
1605
+ jQuery( document ).off("ajaxError.setupTest");
1606
+ start();
1607
+ }
1608
+ },
1609
+ fail = function( a, b ) {
1610
+ ok( false, "Check for timeout failed " + a + " " + b );
1611
+ start();
1612
+ };
1613
+
1614
+ jQuery( document ).on( "ajaxError.setupTest", pass );
1615
+
1616
+ jQuery.ajaxSetup({
1617
+ timeout: 1000
1618
+ });
1619
+
1620
+ jQuery.ajax({
1621
+ type: "GET",
1622
+ url: url("data/name.php?wait=5"),
1623
+ error: pass,
1624
+ success: fail
1625
+ });
1626
+ });
1627
+
1628
+ asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function() {
1629
+ jQuery.ajaxSetup({
1630
+ timeout: 50
1631
+ });
1632
+ jQuery.ajax({
1633
+ type: "GET",
1634
+ timeout: 15000,
1635
+ url: url("data/name.php?wait=1"),
1636
+ error: function() {
1637
+ ok( false, "Check for local timeout failed" );
1638
+ start();
1639
+ },
1640
+ success: function() {
1641
+ ok( true, "Check for local timeout" );
1642
+ start();
1643
+ }
1644
+ });
1645
+ });
1646
+
1647
+ //----------- jQuery.domManip()
1648
+
1649
+ test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", 1, function() {
1650
+ jQuery.ajaxSetup({
1651
+ type: "POST"
1652
+ });
1653
+
1654
+ jQuery( document ).on( "ajaxStart ajaxStop", function() {
1655
+ ok( false, "Global event triggered" );
1656
+ });
1657
+
1658
+ jQuery("#qunit-fixture").append("<script src='data/evalScript.php'></script>");
1659
+
1660
+ jQuery( document ).off("ajaxStart ajaxStop");
1661
+ });
1662
+
1663
+ asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() {
1664
+ jQuery("#qunit-fixture").load( "data/cleanScript.html", start );
1665
+ });
1666
+
1667
+ //----------- jQuery.get()
1668
+
1669
+ asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function() {
1670
+ jQuery.get( url("data/dashboard.xml"), function( xml ) {
1671
+ var content = [];
1672
+ jQuery( "tab", xml ).each(function() {
1673
+ content.push( jQuery( this ).text() );
1674
+ });
1675
+ strictEqual( content[ 0 ], "blabla", "Check first tab" );
1676
+ strictEqual( content[ 1 ], "blublu", "Check second tab" );
1677
+ start();
1678
+ });
1679
+ });
1680
+
1681
+ asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function() {
1682
+ jQuery.ajaxSetup({
1683
+ data: "helloworld"
1684
+ });
1685
+ jQuery.get( url("data/echoQuery.php"), function( data ) {
1686
+ ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" );
1687
+ start();
1688
+ });
1689
+ });
1690
+
1691
+ //----------- jQuery.getJSON()
1692
+
1693
+ asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function() {
1694
+ jQuery.getJSON(
1695
+ url("data/json.php"),
1696
+ {
1697
+ "json": "array"
1698
+ },
1699
+ function( json ) {
1700
+ ok( json.length >= 2, "Check length" );
1701
+ strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" );
1702
+ strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" );
1703
+ strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" );
1704
+ strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" );
1705
+ start();
1706
+ }
1707
+ );
1708
+ });
1709
+
1710
+ asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function() {
1711
+ jQuery.getJSON( url("data/json.php"), function( json ) {
1712
+ if ( json && json["data"] ) {
1713
+ strictEqual( json["data"]["lang"], "en", "Check JSON: lang" );
1714
+ strictEqual( json["data"].length, 25, "Check JSON: length" );
1715
+ start();
1716
+ }
1717
+ });
1718
+ });
1719
+
1720
+ asyncTest( "jQuery.getJSON() - Using Native JSON", 2, function() {
1721
+ var restore = "JSON" in window,
1722
+ old = window.JSON;
1723
+ if ( !restore ) {
1724
+ Globals.register("JSON");
1725
+ }
1726
+ window.JSON = {
1727
+ parse: function() {
1728
+ ok( true, "Verifying that parse method was run" );
1729
+ window.JSON = old;
1730
+ return true;
1731
+ }
1732
+ };
1733
+ jQuery.getJSON( url("data/json.php"), function( json ) {
1734
+ strictEqual( json, true, "Verifying return value" );
1735
+ start();
1736
+ });
1737
+ });
1738
+
1739
+ asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function() {
1740
+ jQuery.getJSON( url( window.location.href.replace( /[^\/]*$/, "" ) + "data/json.php" ), function( json ) {
1741
+ strictEqual( json.data.lang, "en", "Check JSON: lang" );
1742
+ strictEqual( json.data.length, 25, "Check JSON: length" );
1743
+ start();
1744
+ });
1745
+ });
1746
+
1747
+ //----------- jQuery.getScript()
1748
+
1749
+ asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() {
1750
+ Globals.register("testBar");
1751
+ jQuery.getScript( url("data/test.js"), function() {
1752
+ strictEqual( window["testBar"], "bar", "Check if script was evaluated" );
1753
+ start();
1754
+ });
1755
+ });
1756
+
1757
+ asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() {
1758
+ Globals.register("testBar");
1759
+ jQuery.getScript( url("data/test.js") ).done( start );
1760
+ });
1761
+
1762
+ asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() {
1763
+ Globals.register("testBar");
1764
+ jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
1765
+ strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" );
1766
+ start();
1767
+ });
1768
+ });
1769
+
1770
+ //----------- jQuery.fn.load()
1771
+
1772
+ // check if load can be called with only url
1773
+ asyncTest( "jQuery.fn.load( String )", 2, function() {
1774
+ jQuery.ajaxSetup({
1775
+ beforeSend: function() {
1776
+ strictEqual( this.type, "GET", "no data means GET request" );
1777
+ }
1778
+ });
1779
+ jQuery("#first").load( "data/name.html", start );
1780
+ });
1781
+
1782
+ asyncTest( "jQuery.fn.load() - 404 error callbacks", 6, function() {
1783
+ addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError")();
1784
+ jQuery( document ).ajaxStop( start );
1785
+ jQuery("<div/>").load( "data/404.html", function() {
1786
+ ok( true, "complete" );
1787
+ });
1788
+ });
1789
+
1790
+ // check if load can be called with url and null data
1791
+ asyncTest( "jQuery.fn.load( String, null )", 2, function() {
1792
+ jQuery.ajaxSetup({
1793
+ beforeSend: function() {
1794
+ strictEqual( this.type, "GET", "no data means GET request" );
1795
+ }
1796
+ });
1797
+ jQuery("#first").load( "data/name.html", null, start );
1798
+ });
1799
+
1800
+ // check if load can be called with url and undefined data
1801
+ asyncTest( "jQuery.fn.load( String, undefined )", 2, function() {
1802
+ jQuery.ajaxSetup({
1803
+ beforeSend: function() {
1804
+ strictEqual( this.type, "GET", "no data means GET request" );
1805
+ }
1806
+ });
1807
+ jQuery("#first").load( "data/name.html", undefined, start );
1808
+ });
1809
+
1810
+ // check if load can be called with only url
1811
+ asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function() {
1812
+ jQuery("#first").load( "data/test3.html div.user", function() {
1813
+ strictEqual( jQuery( this ).children("div").length, 2, "Verify that specific elements were injected" );
1814
+ start();
1815
+ });
1816
+ });
1817
+
1818
+ asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() {
1819
+ jQuery("#first").load( url("data/name.html"), function() {
1820
+ ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" );
1821
+ start();
1822
+ });
1823
+ });
1824
+
1825
+ asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function() {
1826
+ var verifyEvaluation = function() {
1827
+ strictEqual( window["testBar"], "bar", "Check if script src was evaluated after load" );
1828
+ strictEqual( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM");
1829
+ start();
1830
+ };
1831
+
1832
+ Globals.register("testFoo");
1833
+ Globals.register("testBar");
1834
+
1835
+ jQuery("#first").load( url("data/test.html"), function() {
1836
+ ok( jQuery("#first").html().match( /^html text/ ), "Check content after loading html" );
1837
+ strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM" );
1838
+ strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" );
1839
+ setTimeout( verifyEvaluation, 600 );
1840
+ });
1841
+ });
1842
+
1843
+ asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() {
1844
+ Globals.register("testFoo");
1845
+
1846
+ jQuery("#first").load( url("data/test2.html"), function() {
1847
+ strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
1848
+ strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" );
1849
+ start();
1850
+ });
1851
+ });
1852
+
1853
+ asyncTest( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", 2, function() {
1854
+ jQuery.ajaxSetup({
1855
+ dataFilter: function() {
1856
+ return "Hello World";
1857
+ }
1858
+ });
1859
+ jQuery("<div/>").load( url("data/name.html"), function( responseText ) {
1860
+ strictEqual( jQuery( this ).html(), "Hello World", "Test div was filled with filtered data" );
1861
+ strictEqual( responseText, "Hello World", "Test callback receives filtered data" );
1862
+ start();
1863
+ });
1864
+ });
1865
+
1866
+ asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function() {
1867
+ jQuery("<div />").load( url("data/params_html.php"), {
1868
+ "foo": 3,
1869
+ "bar": "ok"
1870
+ }, function() {
1871
+ var $post = jQuery( this ).find("#post");
1872
+ strictEqual( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly" );
1873
+ strictEqual( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly" );
1874
+ start();
1875
+ });
1876
+ });
1877
+
1878
+ asyncTest( "jQuery.fn.load( String, String, Function )", 2, function() {
1879
+ jQuery("<div />").load( url("data/params_html.php"), "foo=3&bar=ok", function() {
1880
+ var $get = jQuery( this ).find("#get");
1881
+ strictEqual( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly" );
1882
+ strictEqual( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly" );
1883
+ start();
1884
+ });
1885
+ });
1886
+
1887
+ asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() {
1888
+ var completeArgs = {};
1889
+
1890
+ jQuery.ajaxSetup({
1891
+ success: function( _, status, jqXHR ) {
1892
+ completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ];
1893
+ },
1894
+ error: function( jqXHR, status ) {
1895
+ completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ];
1896
+ }
1897
+ });
1898
+
1899
+ jQuery.when.apply(
1900
+ jQuery,
1901
+ jQuery.map([
1902
+ {
1903
+ type: "success",
1904
+ url: "data/echoQuery.php?arg=pop"
1905
+ },
1906
+ {
1907
+ type: "error",
1908
+ url: "data/404.php"
1909
+ }
1910
+ ],
1911
+ function( options ) {
1912
+ return jQuery.Deferred(function( defer ) {
1913
+ jQuery("#foo").load( options.url, function() {
1914
+ var args = arguments;
1915
+ strictEqual( completeArgs[ options.url ].length, args.length, "same number of arguments (" + options.type + ")" );
1916
+ jQuery.each( completeArgs[ options.url ], function( i, value ) {
1917
+ strictEqual( args[ i ], value, "argument #" + i + " is the same (" + options.type + ")" );
1918
+ });
1919
+ defer.resolve();
1920
+ });
1921
+ });
1922
+ })
1923
+ ).always( start );
1924
+ });
1925
+
1926
+ asyncTest( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", 1, function() {
1927
+ jQuery.ajaxSetup({
1928
+ dataType: "json"
1929
+ });
1930
+ jQuery( document ).ajaxComplete(function( e, xml, s ) {
1931
+ strictEqual( s.dataType, "html", "Verify the load() dataType was html" );
1932
+ jQuery( document ).off("ajaxComplete");
1933
+ start();
1934
+ });
1935
+ jQuery("#first").load("data/test3.html");
1936
+ });
1937
+
1938
+ asyncTest( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() {
1939
+ var data = {
1940
+ "baz": 1
1941
+ };
1942
+ jQuery.ajaxSetup({
1943
+ data: {
1944
+ "foo": "bar"
1945
+ }
1946
+ });
1947
+ jQuery("#foo").load( "data/echoQuery.php", data );
1948
+ jQuery( document ).ajaxComplete(function( event, jqXHR, options ) {
1949
+ ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" );
1950
+ start();
1951
+ });
1952
+ });
1953
+
1954
+ //----------- jQuery.post()
1955
+
1956
+ asyncTest( "jQuery.post() - data", 3, function() {
1957
+ jQuery.when(
1958
+ jQuery.post(
1959
+ url("data/name.php"),
1960
+ {
1961
+ xml: "5-2",
1962
+ length: 3
1963
+ },
1964
+ function( xml ) {
1965
+ jQuery( "math", xml ).each(function() {
1966
+ strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
1967
+ strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" );
1968
+ });
1969
+ }
1970
+ ),
1971
+ jQuery.ajax({
1972
+ url: url("data/echoData.php"),
1973
+ type: "POST",
1974
+ data: {
1975
+ "test": {
1976
+ "length": 7,
1977
+ "foo": "bar"
1978
+ }
1979
+ },
1980
+ success: function( data ) {
1981
+ strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" );
1982
+ }
1983
+ })
1984
+ ).always( start );
1985
+ });
1986
+
1987
+ asyncTest( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function() {
1988
+ jQuery.when(
1989
+ jQuery.post(
1990
+ url("data/name.php"),
1991
+ {
1992
+ "xml": "5-2"
1993
+ },
1994
+ function( xml ) {
1995
+ jQuery( "math", xml ).each(function() {
1996
+ strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
1997
+ strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" );
1998
+ });
1999
+ }
2000
+ ),
2001
+ jQuery.post( url("data/name.php?xml=5-2"), {}, function( xml ) {
2002
+ jQuery( "math", xml ).each(function() {
2003
+ strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
2004
+ strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" );
2005
+ });
2006
+ })
2007
+ ).always( start );
2008
+ });
2009
+
2010
+ //----------- jQuery.active
2011
+
2012
+ test( "jQuery.active", 1, function() {
2013
+ ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
2014
+ });
2015
+
2016
+ })();