]> source.dussan.org Git - jquery.git/commitdiff
Follow-up for 22a4e5bd0a7c0a92b54b9965984b582fd42099f2, fix .checkOn, add support...
authorOleg <markelog@gmail.com>
Thu, 7 Mar 2013 14:15:12 +0000 (18:15 +0400)
committerDave Methvin <dave.methvin@gmail.com>
Thu, 4 Apr 2013 02:27:16 +0000 (22:27 -0400)
src/support.js
test/unit/support.js

index 67ba005dcac5245dba880ffb3f2cc6e0e69ace60..52f832f427f7c90a521995931bc169f0f2cb7738 100644 (file)
@@ -13,7 +13,7 @@ jQuery.support = (function( support ) {
        input.type = "checkbox";
 
        // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
-       support.checkOn = input.value === "";
+       support.checkOn = input.value !== "";
 
        // Must access the parent to make an option select properly
        // Support: IE9, IE10
index 4754a68c9075ed92bf4159285180941c7cf42efb..f557a954b233eff24406678f6a6085e250a97ee0 100644 (file)
@@ -34,6 +34,143 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
        strictEqual( shrinkWrapBlocks, jQuery.support.shrinkWrapBlocks, "jQuery.support.shrinkWrapBlocks properties are the same" );
 });
 
+(function() {
+       var expected,
+               userAgent = window.navigator.userAgent;
+
+       if ( /chrome/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":true,
+                       "optSelected":true,
+                       "optDisabled":true,
+                       "focusinBubbles":false,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":true,
+                       "radioValue":true,
+                       "checkClone":true,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":true,
+                       "clearCloneStyle": true,
+                       "boxSizing": true,
+                       "boxSizingReliable": true,
+                       "pixelPosition": false
+               };
+       } else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":true,
+                       "optSelected":true,
+                       "optDisabled":true,
+                       "focusinBubbles":false,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":true,
+                       "radioValue":false,
+                       "checkClone":true,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":true,
+                       "clearCloneStyle": true,
+                       "boxSizing": true,
+                       "boxSizingReliable": true,
+                       "pixelPosition": true
+               };
+       } else if ( /msie 10\.0/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":true,
+                       "optSelected":false,
+                       "optDisabled":true,
+                       "focusinBubbles":true,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":false,
+                       "radioValue":false,
+                       "checkClone":true,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":true,
+                       "clearCloneStyle": false,
+                       "boxSizing": true,
+                       "boxSizingReliable": false,
+                       "pixelPosition": true
+               };
+       } else if ( /msie 9\.0/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":true,
+                       "optSelected":false,
+                       "optDisabled":true,
+                       "focusinBubbles":true,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":false,
+                       "radioValue":false,
+                       "checkClone":true,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":false,
+                       "clearCloneStyle": false,
+                       "boxSizing": true,
+                       "boxSizingReliable": false,
+                       "pixelPosition": true
+               };
+       } else if ( /5\.1\.\d+ safari/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":false,
+                       "optSelected":true,
+                       "optDisabled":true,
+                       "focusinBubbles":false,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":true,
+                       "radioValue":true,
+                       "checkClone":false,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":true,
+                       "clearCloneStyle": true,
+                       "boxSizing": true,
+                       "boxSizingReliable": true,
+                       "pixelPosition": false
+               };
+       } else if ( /firefox/i.test( userAgent ) ) {
+               expected = {
+                       "checkOn":true,
+                       "optSelected":true,
+                       "optDisabled":true,
+                       "focusinBubbles":false,
+                       "reliableMarginRight":true,
+                       "noCloneChecked":true,
+                       "radioValue":true,
+                       "checkClone":true,
+                       "boxModel":true,
+                       "ajax":true,
+                       "cors":true,
+                       "clearCloneStyle": true,
+                       "boxSizing": true,
+                       "boxSizingReliable": false,
+                       "pixelPosition": true
+               };
+       }
+
+       if ( expected ) {
+               test("Verify that the support tests resolve as expected per browser", function() {
+                       var i, prop,
+                               j = 0;
+
+                       for ( prop in jQuery.support ) {
+                               j++;
+                       }
+
+                       expect( j );
+
+                       for ( i in expected ) {
+                               if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
+                                       equal( jQuery.support[i], expected[i], "jQuery.support['" + i + "']: " + jQuery.support[i] + ", expected['" + i + "']: " + expected[i]);
+                               } else {
+                                       ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
+                               }
+                       }
+               });
+       }
+
+})();
+
 // Support: Safari 5.1
 // Shameless browser-sniff, but Safari 5.1 mishandles CSP
 if ( !( typeof navigator !== "undefined" &&