Data: camelCasing should not ignore case
[jquery.git] / test / unit / support.js
blob81ae0d05329d84499580c663319bdc821ad66ac0
1 module("support", { teardown: moduleTeardown });
3 var computedSupport = getComputedSupport( jQuery.support );
5 function getComputedSupport( support ) {
6         var prop,
7                 result = {};
9         for ( prop in support ) {
10                 if ( typeof support[ prop ] === "function" ) {
11                         result[ prop ] = support[ prop ]();
12                 } else {
13                         result[ prop ] = support[ prop ];
14                 }
15         }
17         return result;
20 if ( jQuery.css ) {
21         testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) {
22                 expect( 2 );
23                 var okValue = {
24                         "#000000": true,
25                         "rgb(0, 0, 0)": true
26                 };
27                 ok( okValue[ color ], "color was not reset (" + color + ")" );
29                 deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
30         });
33 // This test checks CSP only for browsers with "Content-Security-Policy" header support
34 // i.e. no old WebKit or old Firefox
35 testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
36         "support/csp.php",
37         function( support ) {
38                 expect( 2 );
39                 deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" );
41                 stop();
43                 supportjQuery.get( "data/support/csp.log" ).done(function( data ) {
44                         equal( data, "", "No log request should be sent" );
45                         supportjQuery.get( "data/support/csp-clean.php" ).done( start );
46                 });
47         }
50 (function() {
51         var expected,
52                 userAgent = window.navigator.userAgent;
54         if ( /chrome/i.test( userAgent ) ) {
55                 // Catches Chrome on Android as well (i.e. the default
56                 // Android browser on Android >= 4.4).
57                 expected = {
58                         "ajax": true,
59                         "boxSizingReliable": true,
60                         "checkClone": true,
61                         "checkOn": true,
62                         "clearCloneStyle": true,
63                         "cors": true,
64                         "createHTMLDocument": true,
65                         "focusinBubbles": false,
66                         "noCloneChecked": true,
67                         "optDisabled": true,
68                         "optSelected": true,
69                         "pixelMarginRight": true,
70                         "pixelPosition": true,
71                         "radioValue": true,
72                         "reliableMarginRight": true
73                 };
74         } else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
75                 expected = {
76                         "ajax": true,
77                         "boxSizingReliable": false,
78                         "checkClone": true,
79                         "checkOn": true,
80                         "clearCloneStyle": false,
81                         "cors": true,
82                         "createHTMLDocument": true,
83                         "focusinBubbles": true,
84                         "noCloneChecked": false,
85                         "optDisabled": true,
86                         "optSelected": false,
87                         "pixelMarginRight": true,
88                         "pixelPosition": true,
89                         "radioValue": false,
90                         "reliableMarginRight": true
91                 };
92         } else if ( /msie 9\.0/i.test( userAgent ) ) {
93                 expected = {
94                         "ajax": true,
95                         "boxSizingReliable": false,
96                         "checkClone": true,
97                         "checkOn": true,
98                         "clearCloneStyle": false,
99                         "cors": false,
100                         "createHTMLDocument": true,
101                         "focusinBubbles": true,
102                         "noCloneChecked": false,
103                         "optDisabled": true,
104                         "optSelected": false,
105                         "pixelMarginRight": true,
106                         "pixelPosition": true,
107                         "radioValue": false,
108                         "reliableMarginRight": true
109                 };
110         } else if ( /8.0(\.\d+|) safari/i.test( userAgent ) ) {
111                 expected = {
112                         "ajax": true,
113                         "boxSizingReliable": true,
114                         "checkClone": true,
115                         "checkOn": true,
116                         "clearCloneStyle": true,
117                         "cors": true,
118                         "createHTMLDocument": false,
119                         "focusinBubbles": false,
120                         "noCloneChecked": true,
121                         "optDisabled": true,
122                         "optSelected": true,
123                         "pixelMarginRight": true,
124                         "pixelPosition": false,
125                         "radioValue": true,
126                         "reliableMarginRight": true
127                 };
128         } else if ( /(6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
129                 expected = {
130                         "ajax": true,
131                         "boxSizingReliable": true,
132                         "checkClone": true,
133                         "checkOn": true,
134                         "clearCloneStyle": true,
135                         "cors": true,
136                         "createHTMLDocument": true,
137                         "focusinBubbles": false,
138                         "noCloneChecked": true,
139                         "optDisabled": true,
140                         "optSelected": true,
141                         "pixelMarginRight": true,
142                         "pixelPosition": false,
143                         "radioValue": true,
144                         "reliableMarginRight": true
145                 };
146         } else if ( /firefox/i.test( userAgent ) ) {
147                 expected = {
148                         "ajax": true,
149                         "boxSizingReliable": true,
150                         "checkClone": true,
151                         "checkOn": true,
152                         "clearCloneStyle": true,
153                         "cors": true,
154                         "createHTMLDocument": true,
155                         "focusinBubbles": false,
156                         "noCloneChecked": true,
157                         "optDisabled": true,
158                         "optSelected": true,
159                         "pixelMarginRight": true,
160                         "pixelPosition": true,
161                         "radioValue": true,
162                         "reliableMarginRight": true
163                 };
164         } else if ( /iphone os 8/i.test( userAgent ) ) {
165                 expected = {
166                         "ajax": true,
167                         "boxSizingReliable": true,
168                         "checkClone": true,
169                         "checkOn": true,
170                         "clearCloneStyle": true,
171                         "cors": true,
172                         "createHTMLDocument": false,
173                         "focusinBubbles": false,
174                         "noCloneChecked": true,
175                         "optDisabled": true,
176                         "optSelected": true,
177                         "pixelMarginRight": true,
178                         "pixelPosition": false,
179                         "radioValue": true,
180                         "reliableMarginRight": true
181                 };
182         } else if ( /iphone os (6|7)/i.test( userAgent ) ) {
183                 expected = {
184                         "ajax": true,
185                         "boxSizingReliable": true,
186                         "checkClone": true,
187                         "checkOn": true,
188                         "clearCloneStyle": true,
189                         "cors": true,
190                         "createHTMLDocument": true,
191                         "focusinBubbles": false,
192                         "noCloneChecked": true,
193                         "optDisabled": true,
194                         "optSelected": true,
195                         "pixelMarginRight": true,
196                         "pixelPosition": false,
197                         "radioValue": true,
198                         "reliableMarginRight": true
199                 };
200         } else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
201                 expected = {
202                         "ajax": true,
203                         "boxSizingReliable": true,
204                         "checkClone": false,
205                         "checkOn": false,
206                         "clearCloneStyle": true,
207                         "cors": true,
208                         "createHTMLDocument": true,
209                         "focusinBubbles": false,
210                         "noCloneChecked": true,
211                         "optDisabled": true,
212                         "optSelected": true,
213                         "pixelMarginRight": false,
214                         "pixelPosition": false,
215                         "radioValue": true,
216                         "reliableMarginRight": true
217                 };
218         } else if ( /android 2\.3/i.test( userAgent ) ) {
219                 expected = {
220                         "ajax": true,
221                         "boxSizingReliable": true,
222                         "checkClone": true,
223                         "checkOn": false,
224                         "clearCloneStyle": false,
225                         "cors": true,
226                         "createHTMLDocument": true,
227                         "focusinBubbles": false,
228                         "noCloneChecked": true,
229                         "optDisabled": false,
230                         "optSelected": true,
231                         "pixelMarginRight": true,
232                         "pixelPosition": false,
233                         "radioValue": true,
234                         "reliableMarginRight": false
235                 };
236         }
238         if ( expected ) {
239                 test( "Verify that the support tests resolve as expected per browser", function() {
240                         var i, prop,
241                                 j = 0;
243                         for ( prop in computedSupport ) {
244                                 j++;
245                         }
247                         expect( j );
249                         for ( i in expected ) {
250                                 // TODO check for all modules containing support properties
251                                 if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
252                                         equal( computedSupport[ i ], expected[ i ],
253                                                 "jQuery.support['" + i + "']: " + computedSupport[ i ] +
254                                                         ", expected['" + i + "']: " + expected[ i ]);
255                                 } else {
256                                         ok( true, "no ajax; skipping jQuery.support[' " + i + " ']" );
257                                 }
258                         }
259                 });
260         }
262 })();