aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-07-10 20:58:43 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-07-13 04:09:31 +0300
commit3d850edb13b8dfea2c09327f4561ca05cb7dc3bd (patch)
tree1391ed788eea451fba83b2a36f9307d6065e3aba /test/unit/ajax.js
parent1682d36be2453007583c3c18d5ebbfa743322ff0 (diff)
downloadjquery-3d850edb13b8dfea2c09327f4561ca05cb7dc3bd.tar.gz
jquery-3d850edb13b8dfea2c09327f4561ca05cb7dc3bd.zip
Ajax: Remove jsonp callbacks through "jQuery#removeProp" method
Fixes gh-2323 Closes gh-2464 Ref a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r--test/unit/ajax.js35
1 files changed, 32 insertions, 3 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 1233f14ce..f9c5e0ed3 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1,5 +1,11 @@
+var isIE8 = /msie 8\.0/i.test( window.navigator.userAgent );
+
module( "ajax", {
setup: function() {
+ if ( !isIE8 ) {
+ return;
+ }
+
var jsonpCallback = this.jsonpCallback = jQuery.ajaxSettings.jsonpCallback;
jQuery.ajaxSettings.jsonpCallback = function() {
var callback = jsonpCallback.apply( this, arguments );
@@ -737,7 +743,7 @@ module( "ajax", {
}
]);
- ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 9, {
+ ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 10, {
setup: function() {
Globals.register("functionToCleanUp");
Globals.register("XXX");
@@ -760,6 +766,11 @@ module( "ajax", {
crossDomain: crossDomain,
jsonpCallback: "jsonpResults",
success: function( data ) {
+ strictEqual(
+ typeof window[ "jsonpResults" ],
+ "function",
+ "should not rewrite original function"
+ );
ok( data.data, "JSON results returned (GET, custom callback name)" );
}
}, {
@@ -1372,16 +1383,34 @@ module( "ajax", {
]);
jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) {
- ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 2, {
+ ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 4, {
url: "data/jsonp.php",
dataType: "jsonp",
crossDomain: crossDomain,
beforeSend: function( jqXHR, s ) {
s.callback = s.jsonpCallback;
+
+ ok( this.callback in window, "JSONP callback name is in the window" );
},
success: function() {
var previous = this;
- strictEqual( previous.jsonpCallback, undefined, "jsonpCallback option is set back to default in callbacks" );
+
+ strictEqual(
+ previous.jsonpCallback,
+ undefined,
+ "jsonpCallback option is set back to default in callbacks"
+ );
+
+ if ( isIE8 ) {
+ ok( true, "IE8 can't remove property from the window" );
+
+ } else {
+ ok(
+ !( this.callback in window ),
+ "JSONP callback name was removed from the window"
+ );
+ }
+
jQuery.ajax({
url: "data/jsonp.php",
dataType: "jsonp",