diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2012-06-25 10:02:28 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2012-06-25 10:02:28 -0400 |
commit | a2758377df7eef02d155a30f869bdc3d8b7c02b9 (patch) | |
tree | 659eefc1136c5523219b7640d8848461f74ed058 /test/unit | |
parent | b47147118c8f291e7db34b377706b6f48ac45b3e (diff) | |
download | jquery-a2758377df7eef02d155a30f869bdc3d8b7c02b9.tar.gz jquery-a2758377df7eef02d155a30f869bdc3d8b7c02b9.zip |
Adds src/deprecated.js, test/unit/deprecated.js; -deprecated flag; Moves jQuery.browser and removes use in test/unit/ajax.js. Fixes #11965
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/ajax.js | 31 | ||||
-rw-r--r-- | test/unit/core.js | 22 | ||||
-rw-r--r-- | test/unit/deprecated.js | 28 |
3 files changed, 46 insertions, 35 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 1293f2c83..e5eae9a47 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -2,6 +2,8 @@ module("ajax", { teardown: moduleTeardown }); if ( jQuery.ajax && ( !isLocal || hasPHP ) ) { +var isOpera = !!window.opera; + test("jQuery.ajax() - success callbacks", function() { expect( 8 ); @@ -381,7 +383,8 @@ test(".ajax() - headers" , function() { headers: requestHeaders, success: function( data , _ , xhr ) { - var tmp = [], i; + var i, emptyHeader, + tmp = []; for ( i in requestHeaders ) { tmp.push( i , ": " , requestHeaders[ i ] , "\n" ); } @@ -390,10 +393,12 @@ test(".ajax() - headers" , function() { strictEqual( data , tmp , "Headers were sent" ); strictEqual( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" ); - if ( jQuery.browser.mozilla ) { + + emptyHeader = xhr.getResponseHeader( "Empty-Header" ); + if ( emptyHeader === null ) { ok( true, "Firefox doesn't support empty headers" ); } else { - strictEqual( xhr.getResponseHeader( "Empty-Header" ) , "" , "Empty header received" ); + strictEqual( emptyHeader , "" , "Empty header received" ); } strictEqual( xhr.getResponseHeader( "Sample-Header2" ) , "Hello World 2" , "Second sample header received" ); }, @@ -2124,8 +2129,8 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache cache: cache, success: function(data, status) { if ( data === "FAIL" ) { - ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); - ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); + ok(isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); + ok(isOpera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); } else { equal(status, "notmodified"); ok(data == null, "response body should be empty"); @@ -2136,8 +2141,8 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache // Do this because opera simply refuses to implement 304 handling :( // A feature-driven way of detecting this would be appreciated // See: http://gist.github.com/599419 - ok(jQuery.browser.opera, "error"); - ok(jQuery.browser.opera, "error"); + ok(isOpera, "error"); + ok(isOpera, "error"); start(); } }); @@ -2147,7 +2152,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache // Do this because opera simply refuses to implement 304 handling :( // A feature-driven way of detecting this would be appreciated // See: http://gist.github.com/599419 - ok(jQuery.browser.opera, "error"); + ok(isOpera, "error"); start(); } }); @@ -2173,8 +2178,8 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache cache: cache, success: function(data, status) { if ( data === "FAIL" ) { - ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); - ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); + ok(isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); + ok(isOpera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); } else { equal(status, "notmodified"); ok(data == null, "response body should be empty"); @@ -2185,8 +2190,8 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache // Do this because opera simply refuses to implement 304 handling :( // A feature-driven way of detecting this would be appreciated // See: http://gist.github.com/599419 - ok(jQuery.browser.opera, "error"); - ok(jQuery.browser.opera, "error"); + ok(isOpera, "error"); + ok(isOpera, "error"); start(); } }); @@ -2195,7 +2200,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache // Do this because opera simply refuses to implement 304 handling :( // A feature-driven way of detecting this would be appreciated // See: http://gist.github.com/599419 - ok(jQuery.browser.opera, "error"); + ok(isOpera, "error"); start(); } }); diff --git a/test/unit/core.js b/test/unit/core.js index f2f5f41c4..7b2ad27e7 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -236,28 +236,6 @@ test( "globalEval", function() { window.globalEvalTest = undefined; }); -if ( jQuery.get && !isLocal ) { - test("browser", function() { - stop(); - - jQuery.get("data/ua.txt", function(data){ - var uas = data.split("\n"); - expect( (uas.length - 1) * 2 ); - - jQuery.each(uas, function(){ - var parts = this.split("\t"); - if ( parts[2] ) { - var ua = jQuery.uaMatch( parts[2] ); - equal( ua.browser, parts[0], "Checking browser for " + parts[2] ); - equal( ua.version, parts[1], "Checking version string for " + parts[2] ); - } - }); - - start(); - }); - }); -} - test("noConflict", function() { expect(7); diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js new file mode 100644 index 000000000..0f77040c1 --- /dev/null +++ b/test/unit/deprecated.js @@ -0,0 +1,28 @@ +module("deprecated"); + +// Start jQuery.browser tests +if ( jQuery.browser && jQuery.uaMatch ) { + if ( jQuery.get && !isLocal ) { + asyncTest( "browser", function() { + jQuery.get( "data/ua.txt", function( data ) { + var uas = data.split( "\n" ); + expect( (uas.length - 1) * 2 ); + + jQuery.each(uas, function() { + var parts = this.split( "\t" ), + agent = parts[2], + ua; + + if ( agent ) { + ua = jQuery.uaMatch( agent ); + equal( ua.browser, parts[0], "browser (" + agent + ")" ); + equal( ua.version, parts[1], "version (" + agent + ")" ); + } + }); + + start(); + }); + }); + } +} +// End of jQuery.browser tests |