smparkes-envjs 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/envjsrb +157 -73
- data/bin/jquery-1.3.2-test.js +11 -4
- data/lib/envjs/env.js +935 -11028
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +4 -4
- data/lib/envjs/runtime.rb +80 -24
- data/test/call-load-test.js +0 -2
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -0
- data/test/html/malformed.html +1 -0
- data/test/index.html +21 -19
- data/test/{primaryTests.js → primary-tests.js} +1 -3
- data/test/{prototype.js → prototype-test.js} +0 -2
- data/test/qunit/qunit/qunit.css +0 -0
- data/test/qunit/qunit/qunit.js +2 -2
- data/test/{qunit/qunit/qunit.js.smp → specs/dist/env.spec.js} +539 -7
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/{qunit.smp/qunit → specs}/qunit.css +0 -0
- data/test/{qunit.smp/qunit → specs}/qunit.js +2 -2
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/elementmembers.js +31 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +1 -3
- data/test/unit/parser.js +106 -98
- data/test/unit/prototypecompat.js +2 -2
- data/test/vendor/jQuery/1.3.2/ChangeLog.txt +98 -0
- data/test/vendor/jQuery/1.3.2/GPL-LICENSE.txt +278 -0
- data/test/vendor/jQuery/1.3.2/MIT-LICENSE.txt +20 -0
- data/test/vendor/jQuery/1.3.2/Makefile +154 -0
- data/test/vendor/jQuery/1.3.2/README +67 -0
- data/test/vendor/jQuery/1.3.2/build/ant-contrib-0.6.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build/build/min.js +11 -0
- data/test/vendor/jQuery/1.3.2/build/build/pack.js +19 -0
- data/test/vendor/jQuery/1.3.2/build/js/Packer.js +209 -0
- data/test/vendor/jQuery/1.3.2/build/js/ParseMaster.js +106 -0
- data/test/vendor/jQuery/1.3.2/build/js/Words.js +62 -0
- data/test/vendor/jQuery/1.3.2/build/js/base2.js +978 -0
- data/test/vendor/jQuery/1.3.2/build/js/jsmin.js +316 -0
- data/test/vendor/jQuery/1.3.2/build/js/json.js +117 -0
- data/test/vendor/jQuery/1.3.2/build/js/pack.js +316 -0
- data/test/vendor/jQuery/1.3.2/build/js/parse.js +105 -0
- data/test/vendor/jQuery/1.3.2/build/js/writeFile.js +19 -0
- data/test/vendor/jQuery/1.3.2/build/js/xml.js +25 -0
- data/test/vendor/jQuery/1.3.2/build/js.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/env.js +1 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/test.js +106 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/testrunner.js +197 -0
- data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.css +65 -0
- data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.js +181 -0
- data/test/vendor/jQuery/1.3.2/build/speed/index.html +72 -0
- data/test/vendor/jQuery/1.3.2/build/speed/jquery-basis.js +3549 -0
- data/test/vendor/jQuery/1.3.2/build/style.xsl +99 -0
- data/test/vendor/jQuery/1.3.2/build/yuicompressor-2.4.2.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build.xml +123 -0
- data/test/vendor/jQuery/1.3.2/dist/jquery.js +4376 -0
- data/test/vendor/jQuery/1.3.2/reminder.txt +3 -0
- data/test/vendor/jQuery/1.3.2/src/ajax.js +541 -0
- data/test/vendor/jQuery/1.3.2/src/core.js +1255 -0
- data/test/vendor/jQuery/1.3.2/src/data.js +145 -0
- data/test/vendor/jQuery/1.3.2/src/dimensions.js +49 -0
- data/test/vendor/jQuery/1.3.2/src/event.js +684 -0
- data/test/vendor/jQuery/1.3.2/src/fx.js +407 -0
- data/test/vendor/jQuery/1.3.2/src/intro.js +13 -0
- data/test/vendor/jQuery/1.3.2/src/offset.js +155 -0
- data/test/vendor/jQuery/1.3.2/src/outro.js +1 -0
- data/test/vendor/jQuery/1.3.2/src/selector.js +1015 -0
- data/test/vendor/jQuery/1.3.2/src/support.js +112 -0
- data/test/vendor/jQuery/1.3.2/test/data/cow.jpg +0 -0
- data/test/vendor/jQuery/1.3.2/test/data/dashboard.xml +11 -0
- data/test/vendor/jQuery/1.3.2/test/data/echoQuery.php +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/iframe.html +8 -0
- data/test/vendor/jQuery/1.3.2/test/data/json.php +9 -0
- data/test/vendor/jQuery/1.3.2/test/data/json_assigned_obj.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/json_obj.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/jsonp.php +10 -0
- data/test/vendor/jQuery/1.3.2/test/data/name.html +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/name.php +29 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/absolute.html +39 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/body.html +24 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/fixed.html +33 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/relative.html +31 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/scroll.html +39 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/static.html +31 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/table.html +43 -0
- data/test/vendor/jQuery/1.3.2/test/data/params_html.php +12 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.html +7 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.js +3 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.php +7 -0
- data/test/vendor/jQuery/1.3.2/test/data/test2.html +5 -0
- data/test/vendor/jQuery/1.3.2/test/data/test3.html +3 -0
- data/test/vendor/jQuery/1.3.2/test/data/testrunner.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/text.php +12 -0
- data/test/vendor/jQuery/1.3.2/test/data/with_fries.xml +25 -0
- data/test/vendor/jQuery/1.3.2/test/index.html +229 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259090275493.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259091671501.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259175319655.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/offset.html +28 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.1/jquery.js +11 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.3/jquery.js +11 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/mootools/1.11/mootools.js +1577 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/prototype/1.6.0.2/prototype.js +4221 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/builder.js +131 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/controls.js +835 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/dragdrop.js +944 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/effects.js +1090 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/scriptaculous.js +51 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/slider.js +278 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/unittest.js +564 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/builder.js +136 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/controls.js +965 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/dragdrop.js +974 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/effects.js +1122 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/scriptaculous.js +58 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/slider.js +275 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/sound.js +55 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/unittest.js +568 -0
- data/test/vendor/jQuery/1.3.2/test/polluted.php +64 -0
- data/test/vendor/jQuery/1.3.2/test/qunit/testrunner.js +780 -0
- data/test/vendor/jQuery/1.3.2/test/qunit/testsuite.css +120 -0
- data/test/vendor/jQuery/1.3.2/test/test.js +41 -0
- data/test/vendor/jQuery/1.3.2/test/unit/ajax.js +856 -0
- data/test/vendor/jQuery/1.3.2/test/unit/core.js +1872 -0
- data/test/vendor/jQuery/1.3.2/test/unit/data.js +160 -0
- data/test/vendor/jQuery/1.3.2/test/unit/dimensions.js +86 -0
- data/test/vendor/jQuery/1.3.2/test/unit/event.js +670 -0
- data/test/vendor/jQuery/1.3.2/test/unit/fx.js +451 -0
- data/test/vendor/jQuery/1.3.2/test/unit/offset.js +173 -0
- data/test/vendor/jQuery/1.3.2/test/unit/selector.js +395 -0
- data/test/vendor/jQuery/1.3.2/test/xhtml.php +5 -0
- data/test/vendor/jQuery/1.3.2/version.txt +1 -0
- metadata +158 -22
- data/lib/envjs/runtime.rb.smp +0 -133
- data/test/envjs-call-load-test.js +0 -5
- data/test/envjs-prototype.js +0 -5
- data/test/qunit/package.json +0 -21
- data/test/qunit/test/index.html +0 -17
- data/test/qunit/test/same.js +0 -1368
- data/test/qunit/test/test.js +0 -136
- data/test/qunit.smp/package.json +0 -21
- data/test/qunit.smp/test/index.html +0 -17
- data/test/qunit.smp/test/same.js +0 -1368
- data/test/qunit.smp/test/test.js +0 -136
- data/test/rhino-call-load-test.js +0 -5
- data/test/rhino-prototype.js +0 -5
- data/test/test-with-envs-jar.js +0 -8
- data/test/test-with-rhino-jar.js +0 -9
@@ -0,0 +1,856 @@
|
|
1
|
+
module("ajax");
|
2
|
+
|
3
|
+
// Safari 3 randomly crashes when running these tests,
|
4
|
+
// but only in the full suite - you can run just the Ajax
|
5
|
+
// tests and they'll pass
|
6
|
+
//if ( !jQuery.browser.safari ) {
|
7
|
+
|
8
|
+
if ( !isLocal ) {
|
9
|
+
|
10
|
+
test("jQuery.ajax() - success callbacks", function() {
|
11
|
+
expect( 8 );
|
12
|
+
|
13
|
+
jQuery.ajaxSetup({ timeout: 0 });
|
14
|
+
|
15
|
+
stop();
|
16
|
+
|
17
|
+
setTimeout(function(){
|
18
|
+
jQuery('#foo').ajaxStart(function(){
|
19
|
+
ok( true, "ajaxStart" );
|
20
|
+
}).ajaxStop(function(){
|
21
|
+
ok( true, "ajaxStop" );
|
22
|
+
start();
|
23
|
+
}).ajaxSend(function(){
|
24
|
+
ok( true, "ajaxSend" );
|
25
|
+
}).ajaxComplete(function(){
|
26
|
+
ok( true, "ajaxComplete" );
|
27
|
+
}).ajaxError(function(){
|
28
|
+
ok( false, "ajaxError" );
|
29
|
+
}).ajaxSuccess(function(){
|
30
|
+
ok( true, "ajaxSuccess" );
|
31
|
+
});
|
32
|
+
|
33
|
+
jQuery.ajax({
|
34
|
+
url: url("data/name.html"),
|
35
|
+
beforeSend: function(){ ok(true, "beforeSend"); },
|
36
|
+
success: function(){ ok(true, "success"); },
|
37
|
+
error: function(){ ok(false, "error"); },
|
38
|
+
complete: function(){ ok(true, "complete"); }
|
39
|
+
});
|
40
|
+
}, 13);
|
41
|
+
});
|
42
|
+
|
43
|
+
test("jQuery.ajax() - error callbacks", function() {
|
44
|
+
expect( 8 );
|
45
|
+
stop();
|
46
|
+
|
47
|
+
jQuery('#foo').ajaxStart(function(){
|
48
|
+
ok( true, "ajaxStart" );
|
49
|
+
}).ajaxStop(function(){
|
50
|
+
ok( true, "ajaxStop" );
|
51
|
+
start();
|
52
|
+
}).ajaxSend(function(){
|
53
|
+
ok( true, "ajaxSend" );
|
54
|
+
}).ajaxComplete(function(){
|
55
|
+
ok( true, "ajaxComplete" );
|
56
|
+
}).ajaxError(function(){
|
57
|
+
ok( true, "ajaxError" );
|
58
|
+
}).ajaxSuccess(function(){
|
59
|
+
ok( false, "ajaxSuccess" );
|
60
|
+
});
|
61
|
+
|
62
|
+
jQuery.ajaxSetup({ timeout: 500 });
|
63
|
+
|
64
|
+
jQuery.ajax({
|
65
|
+
url: url("data/name.php?wait=5"),
|
66
|
+
beforeSend: function(){ ok(true, "beforeSend"); },
|
67
|
+
success: function(){ ok(false, "success"); },
|
68
|
+
error: function(){ ok(true, "error"); },
|
69
|
+
complete: function(){ ok(true, "complete"); }
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
test("jQuery.ajax() - disabled globals", function() {
|
74
|
+
expect( 3 );
|
75
|
+
stop();
|
76
|
+
|
77
|
+
jQuery('#foo').ajaxStart(function(){
|
78
|
+
ok( false, "ajaxStart" );
|
79
|
+
}).ajaxStop(function(){
|
80
|
+
ok( false, "ajaxStop" );
|
81
|
+
}).ajaxSend(function(){
|
82
|
+
ok( false, "ajaxSend" );
|
83
|
+
}).ajaxComplete(function(){
|
84
|
+
ok( false, "ajaxComplete" );
|
85
|
+
}).ajaxError(function(){
|
86
|
+
ok( false, "ajaxError" );
|
87
|
+
}).ajaxSuccess(function(){
|
88
|
+
ok( false, "ajaxSuccess" );
|
89
|
+
});
|
90
|
+
|
91
|
+
jQuery.ajax({
|
92
|
+
global: false,
|
93
|
+
url: url("data/name.html"),
|
94
|
+
beforeSend: function(){ ok(true, "beforeSend"); },
|
95
|
+
success: function(){ ok(true, "success"); },
|
96
|
+
error: function(){ ok(false, "error"); },
|
97
|
+
complete: function(){
|
98
|
+
ok(true, "complete");
|
99
|
+
setTimeout(function(){ start(); }, 13);
|
100
|
+
}
|
101
|
+
});
|
102
|
+
});
|
103
|
+
|
104
|
+
test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
|
105
|
+
expect(3);
|
106
|
+
stop();
|
107
|
+
jQuery.ajax({
|
108
|
+
url: url("data/with_fries.xml"),
|
109
|
+
dataType: "xml",
|
110
|
+
success: function(resp) {
|
111
|
+
equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
|
112
|
+
equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
|
113
|
+
equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
|
114
|
+
start();
|
115
|
+
}
|
116
|
+
});
|
117
|
+
});
|
118
|
+
|
119
|
+
test("jQuery.ajax - beforeSend", function() {
|
120
|
+
expect(1);
|
121
|
+
stop();
|
122
|
+
|
123
|
+
var check = false;
|
124
|
+
|
125
|
+
jQuery.ajaxSetup({ timeout: 0 });
|
126
|
+
|
127
|
+
jQuery.ajax({
|
128
|
+
url: url("data/name.html"),
|
129
|
+
beforeSend: function(xml) {
|
130
|
+
check = true;
|
131
|
+
},
|
132
|
+
success: function(data) {
|
133
|
+
ok( check, "check beforeSend was executed" );
|
134
|
+
start();
|
135
|
+
}
|
136
|
+
});
|
137
|
+
});
|
138
|
+
|
139
|
+
test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
|
140
|
+
expect(2);
|
141
|
+
var request = jQuery.ajax({
|
142
|
+
url: url("data/name.html"),
|
143
|
+
beforeSend: function() {
|
144
|
+
ok( true, "beforeSend got called, canceling" );
|
145
|
+
return false;
|
146
|
+
},
|
147
|
+
success: function() {
|
148
|
+
ok( false, "request didn't get canceled" );
|
149
|
+
},
|
150
|
+
complete: function() {
|
151
|
+
ok( false, "request didn't get canceled" );
|
152
|
+
},
|
153
|
+
error: function() {
|
154
|
+
ok( false, "request didn't get canceled" );
|
155
|
+
}
|
156
|
+
});
|
157
|
+
ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
|
158
|
+
});
|
159
|
+
|
160
|
+
window.foobar = null;
|
161
|
+
window.testFoo = undefined;
|
162
|
+
|
163
|
+
test("jQuery.ajax - dataType html", function() {
|
164
|
+
expect(5);
|
165
|
+
stop();
|
166
|
+
|
167
|
+
var verifyEvaluation = function() {
|
168
|
+
equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
|
169
|
+
equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
|
170
|
+
|
171
|
+
start();
|
172
|
+
};
|
173
|
+
|
174
|
+
jQuery.ajax({
|
175
|
+
dataType: "html",
|
176
|
+
url: url("data/test.html"),
|
177
|
+
success: function(data) {
|
178
|
+
jQuery("#ap").html(data);
|
179
|
+
ok( data.match(/^html text/), 'Check content for datatype html' );
|
180
|
+
setTimeout(verifyEvaluation, 600);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
});
|
184
|
+
|
185
|
+
test("serialize()", function() {
|
186
|
+
expect(6);
|
187
|
+
|
188
|
+
equals( jQuery('#form').serialize(),
|
189
|
+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
|
190
|
+
'Check form serialization as query string');
|
191
|
+
|
192
|
+
equals( jQuery('#form :input').serialize(),
|
193
|
+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
|
194
|
+
'Check input serialization as query string');
|
195
|
+
|
196
|
+
equals( jQuery('#testForm').serialize(),
|
197
|
+
'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
|
198
|
+
'Check form serialization as query string');
|
199
|
+
|
200
|
+
equals( jQuery('#testForm :input').serialize(),
|
201
|
+
'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
|
202
|
+
'Check input serialization as query string');
|
203
|
+
|
204
|
+
equals( jQuery('#form, #testForm').serialize(),
|
205
|
+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
206
|
+
'Multiple form serialization as query string');
|
207
|
+
|
208
|
+
equals( jQuery('#form, #testForm :input').serialize(),
|
209
|
+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
210
|
+
'Mixed form/input serialization as query string');
|
211
|
+
});
|
212
|
+
|
213
|
+
test("jQuery.param()", function() {
|
214
|
+
expect(4);
|
215
|
+
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
|
216
|
+
equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
217
|
+
|
218
|
+
params = {someName: [1, 2, 3], regularThing: "blah" };
|
219
|
+
equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
220
|
+
|
221
|
+
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
|
222
|
+
equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
223
|
+
|
224
|
+
params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
|
225
|
+
equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
226
|
+
});
|
227
|
+
|
228
|
+
test("synchronous request", function() {
|
229
|
+
expect(1);
|
230
|
+
ok( /^{ "data"/.test( jQuery.ajax({url: url("data/json_obj.js"), async: false}).responseText ), "check returned text" );
|
231
|
+
});
|
232
|
+
|
233
|
+
test("synchronous request with callbacks", function() {
|
234
|
+
expect(2);
|
235
|
+
var result;
|
236
|
+
jQuery.ajax({url: url("data/json_obj.js"), async: false, success: function(data) { ok(true, "sucess callback executed"); result = data; } });
|
237
|
+
ok( /^{ "data"/.test( result ), "check returned text" );
|
238
|
+
});
|
239
|
+
|
240
|
+
test("pass-through request object", function() {
|
241
|
+
expect(8);
|
242
|
+
stop();
|
243
|
+
|
244
|
+
var target = "data/name.html";
|
245
|
+
var successCount = 0;
|
246
|
+
var errorCount = 0;
|
247
|
+
var errorEx = "";
|
248
|
+
var success = function() {
|
249
|
+
successCount++;
|
250
|
+
};
|
251
|
+
jQuery("#foo").ajaxError(function (e, xml, s, ex) {
|
252
|
+
errorCount++;
|
253
|
+
errorEx += ": " + xml.status;
|
254
|
+
});
|
255
|
+
jQuery("#foo").one('ajaxStop', function () {
|
256
|
+
equals(successCount, 5, "Check all ajax calls successful");
|
257
|
+
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
|
258
|
+
jQuery("#foo").unbind('ajaxError');
|
259
|
+
|
260
|
+
start();
|
261
|
+
});
|
262
|
+
|
263
|
+
ok( jQuery.get(url(target), success), "get" );
|
264
|
+
ok( jQuery.post(url(target), success), "post" );
|
265
|
+
ok( jQuery.getScript(url("data/test.js"), success), "script" );
|
266
|
+
ok( jQuery.getJSON(url("data/json_obj.js"), success), "json" );
|
267
|
+
ok( jQuery.ajax({url: url(target), success: success}), "generic" );
|
268
|
+
});
|
269
|
+
|
270
|
+
test("ajax cache", function () {
|
271
|
+
expect(18);
|
272
|
+
stop();
|
273
|
+
|
274
|
+
var count = 0;
|
275
|
+
|
276
|
+
jQuery("#firstp").bind("ajaxSuccess", function (e, xml, s) {
|
277
|
+
var re = /_=(.*?)(&|$)/g;
|
278
|
+
var oldOne = null;
|
279
|
+
for (var i = 0; i < 6; i++) {
|
280
|
+
var ret = re.exec(s.url);
|
281
|
+
if (!ret) {
|
282
|
+
break;
|
283
|
+
}
|
284
|
+
oldOne = ret[1];
|
285
|
+
}
|
286
|
+
equals(i, 1, "Test to make sure only one 'no-cache' parameter is there");
|
287
|
+
ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced");
|
288
|
+
if(++count == 6)
|
289
|
+
start();
|
290
|
+
});
|
291
|
+
|
292
|
+
ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
|
293
|
+
ok( jQuery.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
|
294
|
+
ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
|
295
|
+
ok( jQuery.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
|
296
|
+
ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
|
297
|
+
ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
|
298
|
+
});
|
299
|
+
|
300
|
+
test("global ajaxSettings", function() {
|
301
|
+
expect(2);
|
302
|
+
|
303
|
+
var tmp = jQuery.extend({}, jQuery.ajaxSettings);
|
304
|
+
var orig = { url: "data/with_fries.xml" };
|
305
|
+
var t;
|
306
|
+
|
307
|
+
jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
|
308
|
+
|
309
|
+
t = jQuery.extend({}, orig);
|
310
|
+
t.data = {};
|
311
|
+
jQuery.ajax(t);
|
312
|
+
ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
|
313
|
+
|
314
|
+
t = jQuery.extend({}, orig);
|
315
|
+
t.data = { zoo: 'a', ping: 'b' };
|
316
|
+
jQuery.ajax(t);
|
317
|
+
ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
|
318
|
+
|
319
|
+
jQuery.ajaxSettings = tmp;
|
320
|
+
});
|
321
|
+
|
322
|
+
test("load(String)", function() {
|
323
|
+
expect(1);
|
324
|
+
stop(); // check if load can be called with only url
|
325
|
+
jQuery('#first').load("data/name.html", start);
|
326
|
+
});
|
327
|
+
|
328
|
+
test("load('url selector')", function() {
|
329
|
+
expect(1);
|
330
|
+
stop(); // check if load can be called with only url
|
331
|
+
jQuery('#first').load("data/test3.html div.user", function(){
|
332
|
+
equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
|
333
|
+
start();
|
334
|
+
});
|
335
|
+
});
|
336
|
+
|
337
|
+
test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
|
338
|
+
expect(1);
|
339
|
+
stop();
|
340
|
+
jQuery.ajaxSetup({ dataType: "json" });
|
341
|
+
jQuery("#first").ajaxComplete(function (e, xml, s) {
|
342
|
+
equals( s.dataType, "html", "Verify the load() dataType was html" );
|
343
|
+
jQuery("#first").unbind("ajaxComplete");
|
344
|
+
jQuery.ajaxSetup({ dataType: "" });
|
345
|
+
start();
|
346
|
+
});
|
347
|
+
jQuery('#first').load("data/test3.html");
|
348
|
+
});
|
349
|
+
|
350
|
+
test("load(String, Function) - simple: inject text into DOM", function() {
|
351
|
+
expect(2);
|
352
|
+
stop();
|
353
|
+
jQuery('#first').load(url("data/name.html"), function() {
|
354
|
+
ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
|
355
|
+
start();
|
356
|
+
});
|
357
|
+
});
|
358
|
+
|
359
|
+
test("load(String, Function) - check scripts", function() {
|
360
|
+
expect(7);
|
361
|
+
stop();
|
362
|
+
|
363
|
+
var verifyEvaluation = function() {
|
364
|
+
equals( foobar, "bar", 'Check if script src was evaluated after load' );
|
365
|
+
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
|
366
|
+
|
367
|
+
start();
|
368
|
+
};
|
369
|
+
jQuery('#first').load(url('data/test.html'), function() {
|
370
|
+
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
|
371
|
+
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
372
|
+
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
373
|
+
setTimeout(verifyEvaluation, 600);
|
374
|
+
});
|
375
|
+
});
|
376
|
+
|
377
|
+
test("load(String, Function) - check file with only a script tag", function() {
|
378
|
+
expect(3);
|
379
|
+
stop();
|
380
|
+
|
381
|
+
jQuery('#first').load(url('data/test2.html'), function() {
|
382
|
+
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
383
|
+
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
384
|
+
|
385
|
+
start();
|
386
|
+
});
|
387
|
+
});
|
388
|
+
|
389
|
+
test("load(String, Object, Function)", function() {
|
390
|
+
expect(2);
|
391
|
+
stop();
|
392
|
+
|
393
|
+
jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
|
394
|
+
var $post = jQuery(this).find('#post');
|
395
|
+
equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
|
396
|
+
equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
|
397
|
+
start();
|
398
|
+
});
|
399
|
+
});
|
400
|
+
|
401
|
+
test("load(String, String, Function)", function() {
|
402
|
+
expect(2);
|
403
|
+
stop();
|
404
|
+
|
405
|
+
jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
|
406
|
+
var $get = jQuery(this).find('#get');
|
407
|
+
equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
|
408
|
+
equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
|
409
|
+
start();
|
410
|
+
});
|
411
|
+
});
|
412
|
+
|
413
|
+
test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
|
414
|
+
expect(2);
|
415
|
+
stop();
|
416
|
+
jQuery.get(url('data/dashboard.xml'), function(xml) {
|
417
|
+
var content = [];
|
418
|
+
jQuery('tab', xml).each(function() {
|
419
|
+
content.push(jQuery(this).text());
|
420
|
+
});
|
421
|
+
equals( content[0], 'blabla', 'Check first tab');
|
422
|
+
equals( content[1], 'blublu', 'Check second tab');
|
423
|
+
start();
|
424
|
+
});
|
425
|
+
});
|
426
|
+
|
427
|
+
test("jQuery.getScript(String, Function) - with callback", function() {
|
428
|
+
expect(2);
|
429
|
+
stop();
|
430
|
+
jQuery.getScript(url("data/test.js"), function() {
|
431
|
+
equals( foobar, "bar", 'Check if script was evaluated' );
|
432
|
+
setTimeout(start, 100);
|
433
|
+
});
|
434
|
+
});
|
435
|
+
|
436
|
+
test("jQuery.getScript(String, Function) - no callback", function() {
|
437
|
+
expect(1);
|
438
|
+
stop();
|
439
|
+
jQuery.getScript(url("data/test.js"), function(){
|
440
|
+
start();
|
441
|
+
});
|
442
|
+
});
|
443
|
+
|
444
|
+
test("jQuery.ajax() - JSONP, Local", function() {
|
445
|
+
expect(7);
|
446
|
+
|
447
|
+
var count = 0;
|
448
|
+
function plus(){ if ( ++count == 7 ) start(); }
|
449
|
+
|
450
|
+
stop();
|
451
|
+
|
452
|
+
jQuery.ajax({
|
453
|
+
url: "data/jsonp.php",
|
454
|
+
dataType: "jsonp",
|
455
|
+
success: function(data){
|
456
|
+
ok( data.data, "JSON results returned (GET, no callback)" );
|
457
|
+
plus();
|
458
|
+
},
|
459
|
+
error: function(data){
|
460
|
+
ok( false, "Ajax error JSON (GET, no callback)" );
|
461
|
+
plus();
|
462
|
+
}
|
463
|
+
});
|
464
|
+
|
465
|
+
jQuery.ajax({
|
466
|
+
url: "data/jsonp.php?callback=?",
|
467
|
+
dataType: "jsonp",
|
468
|
+
success: function(data){
|
469
|
+
ok( data.data, "JSON results returned (GET, url callback)" );
|
470
|
+
plus();
|
471
|
+
},
|
472
|
+
error: function(data){
|
473
|
+
ok( false, "Ajax error JSON (GET, url callback)" );
|
474
|
+
plus();
|
475
|
+
}
|
476
|
+
});
|
477
|
+
|
478
|
+
jQuery.ajax({
|
479
|
+
url: "data/jsonp.php",
|
480
|
+
dataType: "jsonp",
|
481
|
+
data: "callback=?",
|
482
|
+
success: function(data){
|
483
|
+
ok( data.data, "JSON results returned (GET, data callback)" );
|
484
|
+
plus();
|
485
|
+
},
|
486
|
+
error: function(data){
|
487
|
+
ok( false, "Ajax error JSON (GET, data callback)" );
|
488
|
+
plus();
|
489
|
+
}
|
490
|
+
});
|
491
|
+
|
492
|
+
jQuery.ajax({
|
493
|
+
url: "data/jsonp.php",
|
494
|
+
dataType: "jsonp",
|
495
|
+
jsonp: "callback",
|
496
|
+
success: function(data){
|
497
|
+
ok( data.data, "JSON results returned (GET, data obj callback)" );
|
498
|
+
plus();
|
499
|
+
},
|
500
|
+
error: function(data){
|
501
|
+
ok( false, "Ajax error JSON (GET, data obj callback)" );
|
502
|
+
plus();
|
503
|
+
}
|
504
|
+
});
|
505
|
+
|
506
|
+
jQuery.ajax({
|
507
|
+
type: "POST",
|
508
|
+
url: "data/jsonp.php",
|
509
|
+
dataType: "jsonp",
|
510
|
+
success: function(data){
|
511
|
+
ok( data.data, "JSON results returned (POST, no callback)" );
|
512
|
+
plus();
|
513
|
+
},
|
514
|
+
error: function(data){
|
515
|
+
ok( false, "Ajax error JSON (GET, data obj callback)" );
|
516
|
+
plus();
|
517
|
+
}
|
518
|
+
});
|
519
|
+
|
520
|
+
jQuery.ajax({
|
521
|
+
type: "POST",
|
522
|
+
url: "data/jsonp.php",
|
523
|
+
data: "callback=?",
|
524
|
+
dataType: "jsonp",
|
525
|
+
success: function(data){
|
526
|
+
ok( data.data, "JSON results returned (POST, data callback)" );
|
527
|
+
plus();
|
528
|
+
},
|
529
|
+
error: function(data){
|
530
|
+
ok( false, "Ajax error JSON (POST, data callback)" );
|
531
|
+
plus();
|
532
|
+
}
|
533
|
+
});
|
534
|
+
|
535
|
+
jQuery.ajax({
|
536
|
+
type: "POST",
|
537
|
+
url: "data/jsonp.php",
|
538
|
+
jsonp: "callback",
|
539
|
+
dataType: "jsonp",
|
540
|
+
success: function(data){
|
541
|
+
ok( data.data, "JSON results returned (POST, data obj callback)" );
|
542
|
+
plus();
|
543
|
+
},
|
544
|
+
error: function(data){
|
545
|
+
ok( false, "Ajax error JSON (POST, data obj callback)" );
|
546
|
+
plus();
|
547
|
+
}
|
548
|
+
});
|
549
|
+
});
|
550
|
+
|
551
|
+
test("jQuery.ajax() - JSONP, Remote", function() {
|
552
|
+
expect(4);
|
553
|
+
|
554
|
+
var count = 0;
|
555
|
+
function plus(){ if ( ++count == 4 ) start(); }
|
556
|
+
|
557
|
+
var base = window.location.href.replace(/\?.*$/, "");
|
558
|
+
|
559
|
+
stop();
|
560
|
+
|
561
|
+
jQuery.ajax({
|
562
|
+
url: base + "data/jsonp.php",
|
563
|
+
dataType: "jsonp",
|
564
|
+
success: function(data){
|
565
|
+
ok( data.data, "JSON results returned (GET, no callback)" );
|
566
|
+
plus();
|
567
|
+
},
|
568
|
+
error: function(data){
|
569
|
+
ok( false, "Ajax error JSON (GET, no callback)" );
|
570
|
+
plus();
|
571
|
+
}
|
572
|
+
});
|
573
|
+
|
574
|
+
jQuery.ajax({
|
575
|
+
url: base + "data/jsonp.php?callback=?",
|
576
|
+
dataType: "jsonp",
|
577
|
+
success: function(data){
|
578
|
+
ok( data.data, "JSON results returned (GET, url callback)" );
|
579
|
+
plus();
|
580
|
+
},
|
581
|
+
error: function(data){
|
582
|
+
ok( false, "Ajax error JSON (GET, url callback)" );
|
583
|
+
plus();
|
584
|
+
}
|
585
|
+
});
|
586
|
+
|
587
|
+
jQuery.ajax({
|
588
|
+
url: base + "data/jsonp.php",
|
589
|
+
dataType: "jsonp",
|
590
|
+
data: "callback=?",
|
591
|
+
success: function(data){
|
592
|
+
ok( data.data, "JSON results returned (GET, data callback)" );
|
593
|
+
plus();
|
594
|
+
},
|
595
|
+
error: function(data){
|
596
|
+
ok( false, "Ajax error JSON (GET, data callback)" );
|
597
|
+
plus();
|
598
|
+
}
|
599
|
+
});
|
600
|
+
|
601
|
+
jQuery.ajax({
|
602
|
+
url: base + "data/jsonp.php",
|
603
|
+
dataType: "jsonp",
|
604
|
+
jsonp: "callback",
|
605
|
+
success: function(data){
|
606
|
+
ok( data.data, "JSON results returned (GET, data obj callback)" );
|
607
|
+
plus();
|
608
|
+
},
|
609
|
+
error: function(data){
|
610
|
+
ok( false, "Ajax error JSON (GET, data obj callback)" );
|
611
|
+
plus();
|
612
|
+
}
|
613
|
+
});
|
614
|
+
});
|
615
|
+
|
616
|
+
test("jQuery.ajax() - script, Remote", function() {
|
617
|
+
expect(2);
|
618
|
+
|
619
|
+
var base = window.location.href.replace(/\?.*$/, "");
|
620
|
+
|
621
|
+
stop();
|
622
|
+
|
623
|
+
jQuery.ajax({
|
624
|
+
url: base + "data/test.js",
|
625
|
+
dataType: "script",
|
626
|
+
success: function(data){
|
627
|
+
ok( foobar, "Script results returned (GET, no callback)" );
|
628
|
+
start();
|
629
|
+
}
|
630
|
+
});
|
631
|
+
});
|
632
|
+
|
633
|
+
test("jQuery.ajax() - script, Remote with POST", function() {
|
634
|
+
expect(3);
|
635
|
+
|
636
|
+
var base = window.location.href.replace(/\?.*$/, "");
|
637
|
+
|
638
|
+
stop();
|
639
|
+
|
640
|
+
jQuery.ajax({
|
641
|
+
url: base + "data/test.js",
|
642
|
+
type: "POST",
|
643
|
+
dataType: "script",
|
644
|
+
success: function(data, status){
|
645
|
+
ok( foobar, "Script results returned (GET, no callback)" );
|
646
|
+
equals( status, "success", "Script results returned (GET, no callback)" );
|
647
|
+
start();
|
648
|
+
}
|
649
|
+
});
|
650
|
+
});
|
651
|
+
|
652
|
+
test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
|
653
|
+
expect(2);
|
654
|
+
|
655
|
+
var base = window.location.href.replace(/\?.*$/, "");
|
656
|
+
base = base.replace(/^.*?\/\//, "//");
|
657
|
+
|
658
|
+
stop();
|
659
|
+
|
660
|
+
jQuery.ajax({
|
661
|
+
url: base + "data/test.js",
|
662
|
+
dataType: "script",
|
663
|
+
success: function(data){
|
664
|
+
ok( foobar, "Script results returned (GET, no callback)" );
|
665
|
+
start();
|
666
|
+
}
|
667
|
+
});
|
668
|
+
});
|
669
|
+
|
670
|
+
test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
671
|
+
expect(4);
|
672
|
+
stop();
|
673
|
+
jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
|
674
|
+
equals( json[0].name, 'John', 'Check JSON: first, name' );
|
675
|
+
equals( json[0].age, 21, 'Check JSON: first, age' );
|
676
|
+
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
|
677
|
+
equals( json[1].age, 25, 'Check JSON: second, age' );
|
678
|
+
start();
|
679
|
+
});
|
680
|
+
});
|
681
|
+
|
682
|
+
test("jQuery.getJSON(String, Function) - JSON object", function() {
|
683
|
+
expect(2);
|
684
|
+
stop();
|
685
|
+
jQuery.getJSON(url("data/json.php"), function(json) {
|
686
|
+
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
687
|
+
equals( json.data.length, 25, 'Check JSON: length' );
|
688
|
+
start();
|
689
|
+
});
|
690
|
+
});
|
691
|
+
|
692
|
+
test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() {
|
693
|
+
expect(2);
|
694
|
+
|
695
|
+
var base = window.location.href.replace(/\?.*$/, "");
|
696
|
+
|
697
|
+
stop();
|
698
|
+
jQuery.getJSON(url(base + "data/json.php"), function(json) {
|
699
|
+
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
700
|
+
equals( json.data.length, 25, 'Check JSON: length' );
|
701
|
+
start();
|
702
|
+
});
|
703
|
+
});
|
704
|
+
|
705
|
+
test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
706
|
+
expect(4);
|
707
|
+
stop();
|
708
|
+
var done = 0;
|
709
|
+
|
710
|
+
jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
|
711
|
+
jQuery('math', xml).each(function() {
|
712
|
+
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
|
713
|
+
equals( jQuery('result', this).text(), '3', 'Check for XML' );
|
714
|
+
});
|
715
|
+
if ( ++done === 2 ) start();
|
716
|
+
});
|
717
|
+
|
718
|
+
jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
|
719
|
+
jQuery('math', xml).each(function() {
|
720
|
+
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
|
721
|
+
equals( jQuery('result', this).text(), '3', 'Check for XML' );
|
722
|
+
});
|
723
|
+
if ( ++done === 2 ) start();
|
724
|
+
});
|
725
|
+
});
|
726
|
+
|
727
|
+
test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
728
|
+
stop();
|
729
|
+
|
730
|
+
var passed = 0;
|
731
|
+
|
732
|
+
jQuery.ajaxSetup({timeout: 1000});
|
733
|
+
|
734
|
+
var pass = function() {
|
735
|
+
passed++;
|
736
|
+
if ( passed == 2 ) {
|
737
|
+
ok( true, 'Check local and global callbacks after timeout' );
|
738
|
+
jQuery('#main').unbind("ajaxError");
|
739
|
+
start();
|
740
|
+
}
|
741
|
+
};
|
742
|
+
|
743
|
+
var fail = function(a,b,c) {
|
744
|
+
ok( false, 'Check for timeout failed ' + a + ' ' + b );
|
745
|
+
start();
|
746
|
+
};
|
747
|
+
|
748
|
+
jQuery('#main').ajaxError(pass);
|
749
|
+
|
750
|
+
jQuery.ajax({
|
751
|
+
type: "GET",
|
752
|
+
url: url("data/name.php?wait=5"),
|
753
|
+
error: pass,
|
754
|
+
success: fail
|
755
|
+
});
|
756
|
+
|
757
|
+
// reset timeout
|
758
|
+
jQuery.ajaxSetup({timeout: 0});
|
759
|
+
});
|
760
|
+
|
761
|
+
test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
|
762
|
+
stop();
|
763
|
+
jQuery.ajaxSetup({timeout: 50});
|
764
|
+
|
765
|
+
jQuery.ajax({
|
766
|
+
type: "GET",
|
767
|
+
timeout: 5000,
|
768
|
+
url: url("data/name.php?wait=1"),
|
769
|
+
error: function() {
|
770
|
+
ok( false, 'Check for local timeout failed' );
|
771
|
+
start();
|
772
|
+
},
|
773
|
+
success: function() {
|
774
|
+
ok( true, 'Check for local timeout' );
|
775
|
+
start();
|
776
|
+
}
|
777
|
+
});
|
778
|
+
|
779
|
+
// reset timeout
|
780
|
+
jQuery.ajaxSetup({timeout: 0});
|
781
|
+
});
|
782
|
+
|
783
|
+
test("jQuery.ajax - simple get", function() {
|
784
|
+
expect(1);
|
785
|
+
stop();
|
786
|
+
jQuery.ajax({
|
787
|
+
type: "GET",
|
788
|
+
url: url("data/name.php?name=foo"),
|
789
|
+
success: function(msg){
|
790
|
+
equals( msg, 'bar', 'Check for GET' );
|
791
|
+
start();
|
792
|
+
}
|
793
|
+
});
|
794
|
+
});
|
795
|
+
|
796
|
+
test("jQuery.ajax - simple post", function() {
|
797
|
+
expect(1);
|
798
|
+
stop();
|
799
|
+
jQuery.ajax({
|
800
|
+
type: "POST",
|
801
|
+
url: url("data/name.php"),
|
802
|
+
data: "name=peter",
|
803
|
+
success: function(msg){
|
804
|
+
equals( msg, 'pan', 'Check for POST' );
|
805
|
+
start();
|
806
|
+
}
|
807
|
+
});
|
808
|
+
});
|
809
|
+
|
810
|
+
test("ajaxSetup()", function() {
|
811
|
+
expect(1);
|
812
|
+
stop();
|
813
|
+
jQuery.ajaxSetup({
|
814
|
+
url: url("data/name.php?name=foo"),
|
815
|
+
success: function(msg){
|
816
|
+
equals( msg, 'bar', 'Check for GET' );
|
817
|
+
start();
|
818
|
+
}
|
819
|
+
});
|
820
|
+
jQuery.ajax();
|
821
|
+
});
|
822
|
+
|
823
|
+
/*
|
824
|
+
test("custom timeout does not set error message when timeout occurs, see #970", function() {
|
825
|
+
stop();
|
826
|
+
jQuery.ajax({
|
827
|
+
url: "data/name.php?wait=1",
|
828
|
+
timeout: 500,
|
829
|
+
error: function(request, status) {
|
830
|
+
ok( status != null, "status shouldn't be null in error handler" );
|
831
|
+
equals( "timeout", status );
|
832
|
+
start();
|
833
|
+
}
|
834
|
+
});
|
835
|
+
});
|
836
|
+
*/
|
837
|
+
|
838
|
+
test("data option: evaluate function values (#2806)", function() {
|
839
|
+
stop();
|
840
|
+
jQuery.ajax({
|
841
|
+
url: "data/echoQuery.php",
|
842
|
+
data: {
|
843
|
+
key: function() {
|
844
|
+
return "value";
|
845
|
+
}
|
846
|
+
},
|
847
|
+
success: function(result) {
|
848
|
+
equals( result, "key=value" );
|
849
|
+
start();
|
850
|
+
}
|
851
|
+
})
|
852
|
+
});
|
853
|
+
|
854
|
+
}
|
855
|
+
|
856
|
+
//}
|