Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.client.test.js |
— | — | @@ -5,8 +5,7 @@ |
6 | 6 | ok( jQuery.client, 'jQuery.client defined' ); |
7 | 7 | }); |
8 | 8 | |
9 | | -test( 'profile userAgent support', function() { |
10 | | - expect(8); |
| 9 | +var uacount = 0, uas = (function() { |
11 | 10 | |
12 | 11 | // Object keyed by userAgent. Value is an array (human-readable name, client-profile object, navigator.platform value) |
13 | 12 | // Info based on results from http://toolserver.org/~krinkle/testswarm/job/174/ |
— | — | @@ -24,11 +23,32 @@ |
25 | 24 | "version": "7.0", |
26 | 25 | "versionBase": "7", |
27 | 26 | "versionNumber": 7 |
| 27 | + }, |
| 28 | + wikiEditor: { |
| 29 | + ltr: true, |
| 30 | + rtl: false |
28 | 31 | } |
29 | 32 | }, |
30 | 33 | // Internet Explorer 8 |
31 | 34 | // Internet Explorer 9 |
32 | 35 | // Internet Explorer 10 |
| 36 | + 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)': { |
| 37 | + title: 'Internet Explorer 10', |
| 38 | + platform: 'Win32', |
| 39 | + profile: { |
| 40 | + "name": "msie", |
| 41 | + "layout": "trident", |
| 42 | + "layoutVersion": "unknown", // should be able to report 6? |
| 43 | + "platform": "win", |
| 44 | + "version": "10.0", |
| 45 | + "versionBase": "10", |
| 46 | + "versionNumber": 10 |
| 47 | + }, |
| 48 | + wikiEditor: { |
| 49 | + ltr: true, |
| 50 | + rtl: true |
| 51 | + } |
| 52 | + }, |
33 | 53 | // Firefox 2 |
34 | 54 | // Firefox 3.5 |
35 | 55 | 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19': { |
— | — | @@ -42,6 +62,10 @@ |
43 | 63 | "version": "3.5.19", |
44 | 64 | "versionBase": "3", |
45 | 65 | "versionNumber": 3.5 |
| 66 | + }, |
| 67 | + wikiEditor: { |
| 68 | + ltr: true, |
| 69 | + rtl: true |
46 | 70 | } |
47 | 71 | }, |
48 | 72 | // Firefox 3.6 |
— | — | @@ -56,6 +80,10 @@ |
57 | 81 | "version": "3.6.17", |
58 | 82 | "versionBase": "3", |
59 | 83 | "versionNumber": 3.6 |
| 84 | + }, |
| 85 | + wikiEditor: { |
| 86 | + ltr: true, |
| 87 | + rtl: true |
60 | 88 | } |
61 | 89 | }, |
62 | 90 | // Firefox 4 |
— | — | @@ -70,8 +98,30 @@ |
71 | 99 | "version": "4.0.1", |
72 | 100 | "versionBase": "4", |
73 | 101 | "versionNumber": 4 |
| 102 | + }, |
| 103 | + wikiEditor: { |
| 104 | + ltr: true, |
| 105 | + rtl: true |
74 | 106 | } |
75 | 107 | }, |
| 108 | + // Firefox 10 nightly build |
| 109 | + 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0a1) Gecko/20111103 Firefox/10.0a1': { |
| 110 | + title: 'Firefox 10 nightly', |
| 111 | + platform: 'Linux', |
| 112 | + profile: { |
| 113 | + "name": "firefox", |
| 114 | + "layout": "gecko", |
| 115 | + "layoutVersion": 20111103, |
| 116 | + "platform": "linux", |
| 117 | + "version": "10.0a1", |
| 118 | + "versionBase": "10", |
| 119 | + "versionNumber": 10 |
| 120 | + }, |
| 121 | + wikiEditor: { |
| 122 | + ltr: true, |
| 123 | + rtl: true |
| 124 | + } |
| 125 | + }, |
76 | 126 | // Firefox 5 |
77 | 127 | // Safari 3 |
78 | 128 | // Safari 4 |
— | — | @@ -86,6 +136,10 @@ |
87 | 137 | "version": "4.0.5", |
88 | 138 | "versionBase": "4", |
89 | 139 | "versionNumber": 4 |
| 140 | + }, |
| 141 | + wikiEditor: { |
| 142 | + ltr: true, |
| 143 | + rtl: true |
90 | 144 | } |
91 | 145 | }, |
92 | 146 | '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': { |
— | — | @@ -99,6 +153,10 @@ |
100 | 154 | "version": "4.0.5", |
101 | 155 | "versionBase": "4", |
102 | 156 | "versionNumber": 4 |
| 157 | + }, |
| 158 | + wikiEditor: { |
| 159 | + ltr: true, |
| 160 | + rtl: true |
103 | 161 | } |
104 | 162 | }, |
105 | 163 | // Safari 5 |
— | — | @@ -122,6 +180,10 @@ |
123 | 181 | "version": "12.0.742.112", |
124 | 182 | "versionBase": "12", |
125 | 183 | "versionNumber": 12 |
| 184 | + }, |
| 185 | + wikiEditor: { |
| 186 | + ltr: true, |
| 187 | + rtl: true |
126 | 188 | } |
127 | 189 | }, |
128 | 190 | 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30': { |
— | — | @@ -135,10 +197,20 @@ |
136 | 198 | "version": "12.0.742.68", |
137 | 199 | "versionBase": "12", |
138 | 200 | "versionNumber": 12 |
| 201 | + }, |
| 202 | + wikiEditor: { |
| 203 | + ltr: true, |
| 204 | + rtl: true |
139 | 205 | } |
140 | 206 | } |
141 | 207 | }; |
| 208 | + $.each( uas, function() { uacount++ }); |
| 209 | + return uas; |
| 210 | +})(); |
142 | 211 | |
| 212 | +test( 'profile userAgent support', function() { |
| 213 | + expect(uacount); |
| 214 | + |
143 | 215 | // Generate a client profile object and compare recursively |
144 | 216 | var uaTest = function( rawUserAgent, data ) { |
145 | 217 | var ret = $.client.profile( { |
— | — | @@ -168,34 +240,35 @@ |
169 | 241 | equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' ); |
170 | 242 | }); |
171 | 243 | |
| 244 | +// Example from WikiEditor |
| 245 | +var testMap = { |
| 246 | + 'ltr': { |
| 247 | + 'msie': [['>=', 7.0]], |
| 248 | + 'firefox': [['>=', 2]], |
| 249 | + 'opera': [['>=', 9.6]], |
| 250 | + 'safari': [['>=', 3]], |
| 251 | + 'chrome': [['>=', 3]], |
| 252 | + 'netscape': [['>=', 9]], |
| 253 | + 'blackberry': false, |
| 254 | + 'ipod': false, |
| 255 | + 'iphone': false |
| 256 | + }, |
| 257 | + 'rtl': { |
| 258 | + 'msie': [['>=', 8]], |
| 259 | + 'firefox': [['>=', 2]], |
| 260 | + 'opera': [['>=', 9.6]], |
| 261 | + 'safari': [['>=', 3]], |
| 262 | + 'chrome': [['>=', 3]], |
| 263 | + 'netscape': [['>=', 9]], |
| 264 | + 'blackberry': false, |
| 265 | + 'ipod': false, |
| 266 | + 'iphone': false |
| 267 | + } |
| 268 | +}; |
| 269 | + |
172 | 270 | test( 'test', function() { |
173 | 271 | expect(1); |
174 | 272 | |
175 | | - // Example from WikiEditor |
176 | | - var testMap = { |
177 | | - 'ltr': { |
178 | | - 'msie': [['>=', 7]], |
179 | | - 'firefox': [['>=', 2]], |
180 | | - 'opera': [['>=', 9.6]], |
181 | | - 'safari': [['>=', 3]], |
182 | | - 'chrome': [['>=', 3]], |
183 | | - 'netscape': [['>=', 9]], |
184 | | - 'blackberry': false, |
185 | | - 'ipod': false, |
186 | | - 'iphone': false |
187 | | - }, |
188 | | - 'rtl': { |
189 | | - 'msie': [['>=', 8]], |
190 | | - 'firefox': [['>=', 2]], |
191 | | - 'opera': [['>=', 9.6]], |
192 | | - 'safari': [['>=', 3]], |
193 | | - 'chrome': [['>=', 3]], |
194 | | - 'netscape': [['>=', 9]], |
195 | | - 'blackberry': false, |
196 | | - 'ipod': false, |
197 | | - 'iphone': false |
198 | | - } |
199 | | - }; |
200 | 273 | // .test() uses eval, make sure no exceptions are thrown |
201 | 274 | // then do a basic return value type check |
202 | 275 | var testMatch = $.client.test( testMap ); |
— | — | @@ -203,3 +276,23 @@ |
204 | 277 | equal( typeof testMatch, 'boolean', 'test returns a boolean value' ); |
205 | 278 | |
206 | 279 | }); |
| 280 | + |
| 281 | +test( 'User-agent matches against WikiEditor\'s compatibility map', function() { |
| 282 | + expect( uacount * 2 ); |
| 283 | + |
| 284 | + // Loop through and run tests |
| 285 | + $.each( uas, function( agent, data ) { |
| 286 | + $.each( ['ltr', 'rtl'], function( i, dir ) { |
| 287 | + $('body').addClass(dir); |
| 288 | + var profile = $.client.profile( { |
| 289 | + userAgent: agent, |
| 290 | + platform: data.platform |
| 291 | + } ); |
| 292 | + var testMatch = $.client.test( testMap, profile ); |
| 293 | + $('body').removeClass(dir); |
| 294 | + |
| 295 | + equal( testMatch, data.wikiEditor[dir], 'testing comparison based on ' + dir + ', ' + agent ); |
| 296 | + }); |
| 297 | + }); |
| 298 | +}); |
| 299 | + |