1 QUnit
.module( "support", { afterEach
: moduleTeardown
} );
3 var computedSupport
= getComputedSupport( jQuery
.support
);
5 function getComputedSupport( support
) {
9 for ( prop
in support
) {
10 if ( typeof support
[ prop
] === "function" ) {
11 result
[ prop
] = support
[ prop
]();
13 result
[ prop
] = support
[ prop
];
20 if ( includesModule( "css" ) ) {
22 "body background is not lost if set prior to loading jQuery (trac-9239)",
23 "support/bodyBackground.html",
24 function( assert
, jQuery
, window
, document
, color
, support
) {
30 assert
.ok( okValue
[ color
], "color was not reset (" + color
+ ")" );
32 assert
.deepEqual( jQuery
.extend( {}, support
), computedSupport
,
33 "Same support properties" );
38 // This test checks CSP only for browsers with "Content-Security-Policy" header support
41 "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
42 "mock.php?action=cspFrame",
43 function( assert
, jQuery
, window
, document
, support
) {
44 var done
= assert
.async();
47 assert
.deepEqual( jQuery
.extend( {}, support
), computedSupport
,
48 "No violations of CSP polices" );
50 supportjQuery
.get( baseURL
+ "support/csp.log" ).done( function( data
) {
51 assert
.equal( data
, "", "No log request should be sent" );
52 supportjQuery
.get( baseURL
+ "mock.php?action=cspClean" ).done( done
);
58 "Verify correctness of support tests with bootstrap CSS on the page",
59 "support/bootstrap.html",
60 function( assert
, jQuery
, window
, document
, bodyStyle
, support
) {
62 assert
.strictEqual( bodyStyle
.boxSizing
, "border-box",
63 "border-box applied on body by Bootstrap" );
64 assert
.deepEqual( jQuery
.extend( {}, support
), computedSupport
,
65 "Same support properties" );
70 "Verify correctness of support tests with CSS zoom on the root element",
72 function( assert
, jQuery
, window
, document
, htmlStyle
, support
) {
74 assert
.deepEqual( jQuery
.extend( {}, support
), computedSupport
,
75 "Same support properties" );
80 var expected
, browserKey
,
81 userAgent
= window
.navigator
.userAgent
,
85 reliableTrDimensions
: false
89 reliableTrDimensions
: true
93 reliableTrDimensions
: true
97 reliableTrDimensions
: true
101 reliableTrDimensions
: true
105 reliableTrDimensions
: false
109 reliableTrDimensions
: true
113 reliableTrDimensions
: true
117 reliableTrDimensions
: true
121 // Make the selector-native build pass tests.
122 for ( browserKey
in expectedMap
) {
123 if ( !includesModule( "selector" ) ) {
124 delete expectedMap
[ browserKey
].cssHas
;
128 if ( document
.documentMode
) {
129 expected
= expectedMap
.ie_11
;
130 } else if ( /\b(?:headless)?chrome\/(?:10\d|11[01])\b/i.test( userAgent
) ) {
131 expected
= expectedMap
.chrome_111
;
132 } else if ( /\b(?:headless)?chrome\//i.test( userAgent
) ) {
134 // Catches Edge, Chrome on Android & Opera as well.
135 expected
= expectedMap
.chrome
;
136 } else if ( /\bfirefox\//i.test( userAgent
) ) {
137 expected
= expectedMap
.firefox
;
138 } else if ( /\biphone os (?:14_|15_[0123])/i.test( userAgent
) ) {
139 expected
= expectedMap
.ios_14_15_3
;
140 } else if ( /\biphone os (?:15_|16_[0123])/i.test( userAgent
) ) {
141 expected
= expectedMap
.ios_15_4_16_3
;
142 } else if ( /\b(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent
) ) {
143 expected
= expectedMap
.ios
;
144 } else if ( /\bversion\/(?:15|16\.[0123])(?:\.\d+)* safari/i.test( userAgent
) ) {
145 expected
= expectedMap
.safari_16_3
;
146 } else if ( /\bversion\/\d+(?:\.\d+)+ safari/i.test( userAgent
) ) {
147 expected
= expectedMap
.safari
;
150 QUnit
.test( "Verify that support tests resolve as expected per browser", function( assert
) {
153 assert
.ok( false, "Known client: " + userAgent
);
159 for ( prop
in computedSupport
) {
163 // Add an assertion per undefined support prop as it may
164 // not even exist on computedSupport but we still want to run
166 for ( prop
in expected
) {
167 if ( expected
[ prop
] === undefined ) {
174 for ( i
in expected
) {
175 assert
.equal( computedSupport
[ i
], expected
[ i
],
176 "jQuery.support['" + i
+ "']: " + computedSupport
[ i
] +
177 ", expected['" + i
+ "']: " + expected
[ i
] +
178 ";\nUser Agent: " + navigator
.userAgent
);
182 QUnit
.test( "Verify support tests are failing in one of tested browsers",
185 var prop
, browserKey
, supportTestName
,
188 failingSupportProps
= {};
190 for ( prop
in computedSupport
) {
194 // Add an assertion per undefined support prop as it may
195 // not even exist on computedSupport but we still want to run
197 for ( prop
in expected
) {
198 if ( expected
[ prop
] === undefined ) {
205 // Record all support props and the failing ones and ensure every test
206 // is failing at least once.
207 for ( browserKey
in expectedMap
) {
208 for ( supportTestName
in expectedMap
[ browserKey
] ) {
209 supportProps
[ supportTestName
] = true;
210 if ( !expectedMap
[ browserKey
][ supportTestName
] ) {
211 failingSupportProps
[ supportTestName
] = true;
216 for ( supportTestName
in supportProps
) {
217 assert
.ok( failingSupportProps
[ supportTestName
],
218 "jQuery.support['" + supportTestName
+
219 "'] is expected to fail at least in one browser" );