support.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. module("support", { teardown: moduleTeardown });
  2. if ( jQuery.css ) {
  3. testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) {
  4. expect( 2 );
  5. var okValue = {
  6. "#000000": true,
  7. "rgb(0, 0, 0)": true
  8. };
  9. ok( okValue[ color ], "color was not reset (" + color + ")" );
  10. deepEqual( jQuery.extend( {}, support ), jQuery.support, "Same support properties" );
  11. });
  12. }
  13. testIframeWithCallback( "A non-1 zoom on body doesn't cause WebKit to fail box-sizing test", "support/boxSizing.html", function( boxSizing ) {
  14. expect( 1 );
  15. equal( boxSizing, jQuery.support.boxSizing, "box-sizing properly detected on page with non-1 body zoom" );
  16. });
  17. testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash.html", function() {
  18. expect( 1 );
  19. ok( true, "IE8 does not crash" );
  20. });
  21. testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlocks", "support/shrinkWrapBlocks.html", function( shrinkWrapBlocks ) {
  22. expect( 1 );
  23. strictEqual( shrinkWrapBlocks, jQuery.support.shrinkWrapBlocks, "jQuery.support.shrinkWrapBlocks properties are the same" );
  24. });
  25. (function() {
  26. var expected, version,
  27. userAgent = window.navigator.userAgent;
  28. if ( /chrome/i.test( userAgent ) ) {
  29. expected = {
  30. "checkOn":true,
  31. "optSelected":true,
  32. "optDisabled":true,
  33. "focusinBubbles":false,
  34. "reliableMarginRight":true,
  35. "noCloneChecked":true,
  36. "radioValue":true,
  37. "checkClone":true,
  38. "ajax":true,
  39. "cors":true,
  40. "clearCloneStyle": true,
  41. "boxSizing": true,
  42. "boxSizingReliable": true,
  43. "pixelPosition": false
  44. };
  45. } else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
  46. expected = {
  47. "checkOn":true,
  48. "optSelected":true,
  49. "optDisabled":true,
  50. "focusinBubbles":false,
  51. "reliableMarginRight":true,
  52. "noCloneChecked":true,
  53. "radioValue":false,
  54. "checkClone":true,
  55. "ajax":true,
  56. "cors":true,
  57. "clearCloneStyle": true,
  58. "boxSizing": true,
  59. "boxSizingReliable": true,
  60. "pixelPosition": true
  61. };
  62. } else if ( /msie 10\.0/i.test( userAgent ) ) {
  63. expected = {
  64. "checkOn":true,
  65. "optSelected":false,
  66. "optDisabled":true,
  67. "focusinBubbles":true,
  68. "reliableMarginRight":true,
  69. "noCloneChecked":false,
  70. "radioValue":false,
  71. "checkClone":true,
  72. "ajax":true,
  73. "cors":true,
  74. "clearCloneStyle": false,
  75. "boxSizing": true,
  76. "boxSizingReliable": false,
  77. "pixelPosition": true
  78. };
  79. } else if ( /msie 9\.0/i.test( userAgent ) ) {
  80. expected = {
  81. "checkOn":true,
  82. "optSelected":false,
  83. "optDisabled":true,
  84. "focusinBubbles":true,
  85. "reliableMarginRight":true,
  86. "noCloneChecked":false,
  87. "radioValue":false,
  88. "checkClone":true,
  89. "ajax":true,
  90. "cors":false,
  91. "clearCloneStyle": false,
  92. "boxSizing": true,
  93. "boxSizingReliable": false,
  94. "pixelPosition": true
  95. };
  96. } else if ( /5\.1\.\d+ safari/i.test( userAgent ) ) {
  97. expected = {
  98. "checkOn":false,
  99. "optSelected":true,
  100. "optDisabled":true,
  101. "focusinBubbles":false,
  102. "reliableMarginRight":true,
  103. "noCloneChecked":true,
  104. "radioValue":true,
  105. "checkClone":false,
  106. "ajax":true,
  107. "cors":true,
  108. "clearCloneStyle": true,
  109. "boxSizing": true,
  110. "boxSizingReliable": true,
  111. "pixelPosition": false
  112. };
  113. } else if ( /firefox/i.test( userAgent ) ) {
  114. version = userAgent.match( /firefox\/(\d+)/i )[ 1 ];
  115. expected = {
  116. "checkOn":true,
  117. "optSelected":true,
  118. "optDisabled":true,
  119. "focusinBubbles":false,
  120. "reliableMarginRight":true,
  121. "noCloneChecked":true,
  122. "radioValue":true,
  123. "checkClone":true,
  124. "ajax":true,
  125. "cors":true,
  126. "clearCloneStyle": true,
  127. "boxSizing": true,
  128. "boxSizingReliable": version >= 23,
  129. "pixelPosition": true
  130. };
  131. }
  132. if ( expected ) {
  133. test("Verify that the support tests resolve as expected per browser", function() {
  134. var i, prop,
  135. j = 0;
  136. for ( prop in jQuery.support ) {
  137. j++;
  138. }
  139. expect( j );
  140. for ( i in expected ) {
  141. if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
  142. equal( jQuery.support[i], expected[i], "jQuery.support['" + i + "']: " + jQuery.support[i] + ", expected['" + i + "']: " + expected[i]);
  143. } else {
  144. ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
  145. }
  146. }
  147. });
  148. }
  149. })();
  150. // Support: Safari 5.1
  151. // Shameless browser-sniff, but Safari 5.1 mishandles CSP
  152. if ( !( typeof navigator !== "undefined" &&
  153. (/ AppleWebKit\/\d.*? Version\/(\d+)/.exec(navigator.userAgent) || [])[1] < 6 ) ) {
  154. testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions", "support/csp.php", function( support ) {
  155. expect( 1 );
  156. deepEqual( jQuery.extend( {}, support ), jQuery.support, "No violations of CSP polices" );
  157. });
  158. }