diff options
author | John Resig <jeresig@gmail.com> | 2010-01-16 10:11:01 -0500 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-01-16 10:11:01 -0500 |
commit | 155ecf42a0033785160e071507f0795b3c86a32b (patch) | |
tree | 9bce2301a430841c137d864d27ab32bce216f109 /test/unit | |
parent | 6618ff0b0abe38a0914d8afe0a2b271c977adf6b (diff) | |
download | jquery-155ecf42a0033785160e071507f0795b3c86a32b.tar.gz jquery-155ecf42a0033785160e071507f0795b3c86a32b.zip |
Make sure regular settings object is set as context for all Ajax requests, if none is specified. Fixes #5838.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/ajax.js | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 582aa37b6..4f901265e 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -95,7 +95,7 @@ test("jQuery.ajax() - abort", function() { }); test("Ajax events with context", function() { - expect(6); + expect(14); stop(); var context = document.createElement("div"); @@ -104,8 +104,16 @@ test("Ajax events with context", function() { equals( this, context, e.type ); } - function callback(){ - equals( this, context, "context is preserved on callback" ); + function callback(msg){ + return function(){ + equals( this, context, "context is preserved on callback " + msg ); + }; + } + + function nocallback(msg){ + return function(){ + equals( typeof this.url, "string", "context is settings on callback " + msg ); + }; } jQuery('#foo').add(context) @@ -116,20 +124,36 @@ test("Ajax events with context", function() { jQuery.ajax({ url: url("data/name.html"), - beforeSend: callback, - success: callback, - error: callback, + beforeSend: callback("beforeSend"), + success: callback("success"), + error: callback("error"), complete:function(){ - callback.call(this); - setTimeout(proceed, 300); + callback("complete").call(this); + + jQuery.ajax({ + url: url("data/404.html"), + context: context, + beforeSend: callback("beforeSend"), + error: callback("error"), + complete: function(){ + callback("complete").call(this); + + jQuery('#foo').add(context).unbind(); + + jQuery.ajax({ + url: url("data/404.html"), + beforeSend: nocallback("beforeSend"), + error: nocallback("error"), + complete: function(){ + nocallback("complete").call(this); + start(); + } + }); + } + }); }, context:context }); - - function proceed(){ - jQuery('#foo').add(context).unbind(); - start(); - } }); test("jQuery.ajax() - disabled globals", function() { |