From c8c6ab6924b48832bfc2b94d40887b2f1b6c891e Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 17 Dec 2012 18:17:39 +0400 Subject: Fix #12569. Improve feature detect for event bubbling. Close gh-1076. --- test/csp.php | 5 ++- test/unit/event.js | 28 ++++++++++++ test/unit/support.js | 121 ++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 142 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/csp.php b/test/csp.php index e3245149c..9ab18f392 100644 --- a/test/csp.php +++ b/test/csp.php @@ -1,4 +1,7 @@ - + diff --git a/test/unit/event.js b/test/unit/event.js index 32355c9ad..ff2ea1dd5 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2601,3 +2601,31 @@ test( "make sure events cloned correctly", 18, function() { clone.find("p:first").click(); // 0 should be fired clone.find("#check1").change(); // 0 events should fire }); + +test( "Check order of focusin/focusout events", 2, function() { + var focus, blur, + input = jQuery("#name"); + + input.on("focus", function() { + focus = true; + + }).on("focusin", function() { + ok( !focus, "Focusin event should fire before focus does" ); + + }).on("blur", function() { + blur = true; + + }).on("focusout", function() { + ok( !blur, "Focusout event should fire before blur does" ); + }); + + // gain focus + input.focus(); + + // then lose it + jQuery("#search").focus(); + + // cleanup + input.off(); +}); + diff --git a/test/unit/support.js b/test/unit/support.js index 8d4ac21bc..94a871ee9 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -7,7 +7,7 @@ test("boxModel", function() { }); if ( jQuery.css ) { - testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground.html", function( color, support ) { + testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) { expect( 2 ); var i, passed = true, @@ -29,6 +29,7 @@ if ( jQuery.css ) { strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i ); } } + ok( passed, "Same support properties" ); }); } @@ -44,13 +45,12 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo }); (function() { - - var userAgent = window.navigator.userAgent, - expected; + var expected, + userAgent = window.navigator.userAgent; // These tests do not have to stay // They are here to help with upcoming support changes for 1.8 - if ( /chrome\/19\.0/i.test(userAgent) ) { + if ( /chrome/i.test( userAgent ) ) { expected = { "leadingWhitespace":true, "tbody":true, @@ -83,7 +83,106 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "cors":true, "doesNotIncludeMarginInBodyOffset":true }; - } else if ( /msie 8\.0/i.test(userAgent) ) { + } else if ( /opera/i.test( userAgent ) ) { + expected = { + "leadingWhitespace":true, + "tbody":true, + "htmlSerialize":true, + "style":true, + "hrefNormalized":true, + "opacity":true, + "cssFloat":true, + "checkOn":true, + "optSelected":true, + "getSetAttribute":true, + "enctype":true, + "html5Clone":true, + "submitBubbles":true, + "changeBubbles":true, + "focusinBubbles":false, + "deleteExpando":true, + "noCloneEvent":true, + "inlineBlockNeedsLayout":false, + "shrinkWrapBlocks":false, + "reliableMarginRight":true, + "noCloneChecked":true, + "optDisabled":true, + "radioValue":false, + "checkClone":true, + "appendChecked":true, + "boxModel":true, + "reliableHiddenOffsets":true, + "ajax":true, + "cors":true, + "doesNotIncludeMarginInBodyOffset":true + }; + } else if ( /msie 10\.0/i.test( userAgent ) ) { + expected = { + "leadingWhitespace":true, + "tbody":true, + "htmlSerialize":true, + "style":true, + "hrefNormalized":true, + "opacity":true, + "cssFloat":true, + "checkOn":true, + "optSelected":false, + "getSetAttribute":true, + "enctype":true, + "html5Clone":true, + "submitBubbles":true, + "changeBubbles":true, + "focusinBubbles":true, + "deleteExpando":true, + "noCloneEvent":true, + "inlineBlockNeedsLayout":false, + "shrinkWrapBlocks":false, + "reliableMarginRight":true, + "noCloneChecked":false, + "optDisabled":true, + "radioValue":false, + "checkClone":true, + "appendChecked":true, + "boxModel":true, + "reliableHiddenOffsets":true, + "ajax":true, + "cors":true, + "doesNotIncludeMarginInBodyOffset":true + }; + } else if ( /msie 9\.0/i.test( userAgent ) ) { + expected = { + "leadingWhitespace":true, + "tbody":true, + "htmlSerialize":true, + "style":true, + "hrefNormalized":true, + "opacity":true, + "cssFloat":true, + "checkOn":true, + "optSelected":false, + "getSetAttribute":true, + "enctype":true, + "html5Clone":true, + "submitBubbles":true, + "changeBubbles":true, + "focusinBubbles":true, + "deleteExpando":true, + "noCloneEvent":true, + "inlineBlockNeedsLayout":false, + "shrinkWrapBlocks":false, + "reliableMarginRight":true, + "noCloneChecked":false, + "optDisabled":true, + "radioValue":false, + "checkClone":true, + "appendChecked":true, + "boxModel":true, + "reliableHiddenOffsets":true, + "ajax":true, + "cors":false, + "doesNotIncludeMarginInBodyOffset":true + }; + } else if ( /msie 8\.0/i.test( userAgent ) ) { expected = { "leadingWhitespace":false, "tbody":true, @@ -116,7 +215,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "cors":false, "doesNotIncludeMarginInBodyOffset":true }; - } else if ( /msie 7\.0/i.test(userAgent) ) { + } else if ( /msie 7\.0/i.test( userAgent ) ) { expected = { "ajax": true, "appendChecked": false, @@ -149,7 +248,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "tbody": false, "style": false }; - } else if ( /msie 6\.0/i.test(userAgent) ) { + } else if ( /msie 6\.0/i.test( userAgent ) ) { expected = { "leadingWhitespace":false, "tbody":false, @@ -182,7 +281,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "cors":false, "doesNotIncludeMarginInBodyOffset":true }; - } else if ( /5\.1\.1 safari/i.test(userAgent) ) { + } else if ( /5\.1\.1 safari/i.test( userAgent ) ) { expected = { "leadingWhitespace":true, "tbody":true, @@ -215,7 +314,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "cors":true, "doesNotIncludeMarginInBodyOffset":true }; - } else if ( /firefox\/3\.6/i.test(userAgent) ) { + } else if ( /firefox/i.test( userAgent ) ) { expected = { "leadingWhitespace":true, "tbody":true, @@ -227,7 +326,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo "checkOn":true, "optSelected":true, "getSetAttribute":true, - "enctype":false, + "enctype":true, "html5Clone":true, "submitBubbles":true, "changeBubbles":true, -- cgit v1.2.3