diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/data/ua.txt | 4 | ||||
-rw-r--r-- | test/index.html | 1 | ||||
-rw-r--r-- | test/unit/ajax.js | 31 | ||||
-rw-r--r-- | test/unit/core.js | 22 | ||||
-rw-r--r-- | test/unit/deprecated.js | 28 |
5 files changed, 49 insertions, 37 deletions
diff --git a/test/data/ua.txt b/test/data/ua.txt index b6a9dff66..95e522e25 100644 --- a/test/data/ua.txt +++ b/test/data/ua.txt @@ -37,8 +37,8 @@ mozilla 1.0.1 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) G mozilla 1.8.0.10 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.10) Gecko/20070228 Camino/1.0.4 webkit 418.9 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko, Safari) Safari/419.3 Cheshire/1.0.ALPHA webkit 419 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko, Safari/419.3) Cheshire/1.0.ALPHA -webkit 525.19 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.36 Safari/525.19 -webkit 525.19 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19 +chrome 1.0.154.36 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.36 Safari/525.19 +chrome 1.0.154.53 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.53 Safari/525.19 mozilla 1.9.0.10 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042815 Firefox/3.0.10 CometBird/3.0.10 mozilla 1.9.0.5 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2009011615 Firefox/3.0.5 CometBird/3.0.5 msie 7.0 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Crazy Browser 3.0.0 Beta2) diff --git a/test/index.html b/test/index.html index 9d1e70344..a3a2b6f58 100644 --- a/test/index.html +++ b/test/index.html @@ -49,6 +49,7 @@ <script src="unit/effects.js"></script> <script src="unit/offset.js"></script> <script src="unit/dimensions.js"></script> + <script src="unit/deprecated.js"></script> <script src="unit/exports.js"></script> <script> 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 |