diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-07-10 20:58:43 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-07-13 01:34:09 +0300 |
commit | a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e (patch) | |
tree | f4cdf3356d8aefe10f83f320f222e14d5a684933 /test/unit/ajax.js | |
parent | 3ec73efb26317239a4f22f0b023b0b99a4300a20 (diff) | |
download | jquery-a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e.tar.gz jquery-a2ae215d999637e8d9d0906abcbf6b1ca35c8e6e.zip |
Ajax: Remove jsonp callbacks through "jQuery#removeProp" method
Fixes gh-2323
Closes gh-2464
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r-- | test/unit/ajax.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 8a4ca7a65..359fa9d81 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1,12 +1,4 @@ module( "ajax", { - setup: function() { - var jsonpCallback = this.jsonpCallback = jQuery.ajaxSettings.jsonpCallback; - jQuery.ajaxSettings.jsonpCallback = function() { - var callback = jsonpCallback.apply( this, arguments ); - Globals.register( callback ); - return callback; - }; - }, teardown: function() { jQuery( document ).off( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess" ); moduleTeardown.apply( this, arguments ); @@ -742,7 +734,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"); @@ -765,6 +757,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)" ); } }, { @@ -1356,16 +1353,29 @@ 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" + ); + + ok( + !( this.callback in window ), + "JSONP callback name was removed from the window" + ); + jQuery.ajax({ url: "data/jsonp.php", dataType: "jsonp", |