Make sure that SQLite uses no prefix
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.client.test.js
1 QUnit.module( 'jquery.client', QUnit.newMwEnvironment() );
2
3 /** Number of user-agent defined */
4 var uacount = 0;
5
6 var uas = (function () {
7
8 // Object keyed by userAgent. Value is an array (human-readable name, client-profile object, navigator.platform value)
9 // Info based on results from http://toolserver.org/~krinkle/testswarm/job/174/
10 var uas = {
11 // Internet Explorer 6
12 // Internet Explorer 7
13 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)': {
14 title: 'Internet Explorer 7',
15 platform: 'Win32',
16 profile: {
17 "name": "msie",
18 "layout": "trident",
19 "layoutVersion": "unknown",
20 "platform": "win",
21 "version": "7.0",
22 "versionBase": "7",
23 "versionNumber": 7
24 },
25 wikiEditor: {
26 ltr: true,
27 rtl: false
28 }
29 },
30 // Internet Explorer 8
31 // Internet Explorer 9
32 // Internet Explorer 10
33 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)': {
34 title: 'Internet Explorer 10',
35 platform: 'Win32',
36 profile: {
37 "name": "msie",
38 "layout": "trident",
39 "layoutVersion": "unknown", // should be able to report 6?
40 "platform": "win",
41 "version": "10.0",
42 "versionBase": "10",
43 "versionNumber": 10
44 },
45 wikiEditor: {
46 ltr: true,
47 rtl: true
48 }
49 },
50 // Firefox 2
51 // Firefox 3.5
52 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19': {
53 title: 'Firefox 3.5',
54 platform: 'MacIntel',
55 profile: {
56 "name": "firefox",
57 "layout": "gecko",
58 "layoutVersion": 20110420,
59 "platform": "mac",
60 "version": "3.5.19",
61 "versionBase": "3",
62 "versionNumber": 3.5
63 },
64 wikiEditor: {
65 ltr: true,
66 rtl: true
67 }
68 },
69 // Firefox 3.6
70 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17': {
71 title: 'Firefox 3.6',
72 platform: 'Linux i686',
73 profile: {
74 "name": "firefox",
75 "layout": "gecko",
76 "layoutVersion": 20110422,
77 "platform": "linux",
78 "version": "3.6.17",
79 "versionBase": "3",
80 "versionNumber": 3.6
81 },
82 wikiEditor: {
83 ltr: true,
84 rtl: true
85 }
86 },
87 // Firefox 4
88 'Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1': {
89 title: 'Firefox 4',
90 platform: 'Win32',
91 profile: {
92 "name": "firefox",
93 "layout": "gecko",
94 "layoutVersion": 20100101,
95 "platform": "win",
96 "version": "4.0.1",
97 "versionBase": "4",
98 "versionNumber": 4
99 },
100 wikiEditor: {
101 ltr: true,
102 rtl: true
103 }
104 },
105 // Firefox 10 nightly build
106 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0a1) Gecko/20111103 Firefox/10.0a1': {
107 title: 'Firefox 10 nightly',
108 platform: 'Linux',
109 profile: {
110 "name": "firefox",
111 "layout": "gecko",
112 "layoutVersion": 20111103,
113 "platform": "linux",
114 "version": "10.0a1",
115 "versionBase": "10",
116 "versionNumber": 10
117 },
118 wikiEditor: {
119 ltr: true,
120 rtl: true
121 }
122 },
123 // Firefox 5
124 // Safari 3
125 // Safari 4
126 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7': {
127 title: 'Safari 4',
128 platform: 'MacIntel',
129 profile: {
130 "name": "safari",
131 "layout": "webkit",
132 "layoutVersion": 531,
133 "platform": "mac",
134 "version": "4.0.5",
135 "versionBase": "4",
136 "versionNumber": 4
137 },
138 wikiEditor: {
139 ltr: true,
140 rtl: true
141 }
142 },
143 'Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7': {
144 title: 'Safari 4',
145 platform: 'Win32',
146 profile: {
147 "name": "safari",
148 "layout": "webkit",
149 "layoutVersion": 533,
150 "platform": "win",
151 "version": "4.0.5",
152 "versionBase": "4",
153 "versionNumber": 4
154 },
155 wikiEditor: {
156 ltr: true,
157 rtl: true
158 }
159 },
160 // Safari 5
161 // Opera 10
162 // Chrome 5
163 // Chrome 6
164 // Chrome 7
165 // Chrome 8
166 // Chrome 9
167 // Chrome 10
168 // Chrome 11
169 // Chrome 12
170 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30': {
171 title: 'Chrome 12',
172 platform: 'MacIntel',
173 profile: {
174 "name": "chrome",
175 "layout": "webkit",
176 "layoutVersion": 534,
177 "platform": "mac",
178 "version": "12.0.742.112",
179 "versionBase": "12",
180 "versionNumber": 12
181 },
182 wikiEditor: {
183 ltr: true,
184 rtl: true
185 }
186 },
187 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30': {
188 title: 'Chrome 12',
189 platform: 'Linux i686',
190 profile: {
191 "name": "chrome",
192 "layout": "webkit",
193 "layoutVersion": 534,
194 "platform": "linux",
195 "version": "12.0.742.68",
196 "versionBase": "12",
197 "versionNumber": 12
198 },
199 wikiEditor: {
200 ltr: true,
201 rtl: true
202 }
203 },
204 // Bug #34924
205 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) rekonq Safari/534.34': {
206 title: 'Rekonq',
207 platform: 'Linux i686',
208 profile: {
209 "name": "rekonq",
210 "layout": "webkit",
211 "layoutVersion": 534,
212 "platform": "linux",
213 "version": "534.34",
214 "versionBase": "534",
215 "versionNumber": 534.34
216 },
217 wikiEditor: {
218 ltr: true,
219 rtl: true
220 }
221 }
222 };
223 $.each( uas, function () {
224 uacount++;
225 });
226 return uas;
227 }());
228
229 QUnit.test( 'profile userAgent support', uacount, function ( assert ) {
230 // Generate a client profile object and compare recursively
231 var uaTest = function( rawUserAgent, data ) {
232 var ret = $.client.profile( {
233 userAgent: rawUserAgent,
234 platform: data.platform
235 } );
236 assert.deepEqual( ret, data.profile, 'Client profile support check for ' + data.title + ' (' + data.platform + '): ' + rawUserAgent );
237 };
238
239 // Loop through and run tests
240 $.each( uas, uaTest );
241 } );
242
243 QUnit.test( 'profile return validation for current user agent', 7, function ( assert ) {
244 var p = $.client.profile();
245 function unknownOrType( val, type, summary ) {
246 assert.ok( typeof val === type || val === 'unknown', summary );
247 }
248
249 assert.equal( typeof p, 'object', 'profile returns an object' );
250 unknownOrType( p.layout, 'string', 'p.layout is a string (or "unknown")' );
251 unknownOrType( p.layoutVersion, 'number', 'p.layoutVersion is a number (or "unknown")' );
252 unknownOrType( p.platform, 'string', 'p.platform is a string (or "unknown")' );
253 unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' );
254 unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' );
255 assert.equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' );
256 });
257
258 // Example from WikiEditor
259 // Make sure to use raw numbers, a string like "7.0" would fail on a
260 // version 10 browser since in string comparaison "10" is before "7.0" :)
261 var testMap = {
262 'ltr': {
263 'msie': [['>=', 7.0]],
264 'firefox': [['>=', 2]],
265 'opera': [['>=', 9.6]],
266 'safari': [['>=', 3]],
267 'chrome': [['>=', 3]],
268 'netscape': [['>=', 9]],
269 'blackberry': false,
270 'ipod': false,
271 'iphone': false
272 },
273 'rtl': {
274 'msie': [['>=', 8]],
275 'firefox': [['>=', 2]],
276 'opera': [['>=', 9.6]],
277 'safari': [['>=', 3]],
278 'chrome': [['>=', 3]],
279 'netscape': [['>=', 9]],
280 'blackberry': false,
281 'ipod': false,
282 'iphone': false
283 }
284 };
285
286 QUnit.test( 'test', 1, function ( assert ) {
287 // .test() uses eval, make sure no exceptions are thrown
288 // then do a basic return value type check
289 var testMatch = $.client.test( testMap );
290
291 assert.equal( typeof testMatch, 'boolean', 'test returns a boolean value' );
292
293 });
294
295 QUnit.test( 'User-agent matches against WikiEditor\'s compatibility map', uacount * 2, function ( assert ) {
296 var $body = $( 'body' ),
297 bodyClasses = $body.attr( 'class' );
298
299 // Loop through and run tests
300 $.each( uas, function ( agent, data ) {
301 $.each( ['ltr', 'rtl'], function ( i, dir ) {
302 $body.removeClass( 'ltr rtl' ).addClass( dir );
303 var profile = $.client.profile( {
304 userAgent: agent,
305 platform: data.platform
306 } );
307 var testMatch = $.client.test( testMap, profile );
308 $body.removeClass( dir );
309
310 assert.equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent );
311 });
312 });
313
314 // Restore body classes
315 $body.attr( 'class', bodyClasses );
316 });
317