detect.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  6. <link rel="stylesheet" href="test.css">
  7. <title>Zepto Detect unit tests</title>
  8. <script src="../vendor/evidence.js"></script>
  9. <script src="evidence_runner.js"></script>
  10. <script>
  11. // avoid caching
  12. (function(){
  13. function load(scripts){
  14. scripts.split(' ').forEach(function(script){
  15. document.write('<script src="../src/'+script+'.js?'+(+new Date)+'"></scr'+'ipt>')
  16. })
  17. }
  18. load('zepto detect ie')
  19. })()
  20. </script>
  21. </head>
  22. <body>
  23. <h1>Zepto Detect unit tests</h1>
  24. <p id="results">
  25. Running… see browser console for results
  26. </p>
  27. <script>
  28. (function(){
  29. var UA = {
  30. Safari_OSX_7_0_1: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11",
  31. Safari_OSX_7_0: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71",
  32. Safari_OSX_6_0: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25",
  33. Safari_Windows_NT: "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  34. WebOS_1_4_0_Pre: "Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1",
  35. WebOS_1_4_0_Pixi: "Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pixi/1.1",
  36. WebOS_1_2_9_Pixi: "Mozilla/5.0 (webOS/Palm webOS 1.2.9; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pixi/1.0",
  37. WebOS_3_0_0_TouchPad: "Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0",
  38. iOS_3_0_iPhone: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/1A542a Safari/419.3",
  39. iOS_4_0_iPhone: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7",
  40. iOS_3_1_1_iPod: "Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_1 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7C145",
  41. iOS_3_2_iPad: "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10",
  42. iOS_4_2_iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C134 Safari/6533.18.5",
  43. iOS_4_3_iPhone_Simulator: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F190 Safari/6533.18.5",
  44. iOS_5_0_iPhone: "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3",
  45. iOS_5_1_iPad_webView: "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/98176",
  46. iOS_6_0_iPad_mini: "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A406 Safari/8536.25",
  47. iOS_6_1_iPhone: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B143 Safari/8536.25",
  48. iOS_3_2_iPad_2: "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
  49. iOS_7_0_iPhone: "Mozilla 5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KTHML, like Gecko) Version/7.0 Mobile/11A449d Safari/9537.53",
  50. iOS_7_0_iPhone_Chrome: "Mozilla 5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/536.26 (KHTM, like Gecko) CriOS/28.0.1500.17 Mobile/11A4449d Safari/8536.25",
  51. Android_1_5: "Mozilla/5.0 (Linux; U; Android 1.5; de-; HTC Magic Build/PLAT-RC33) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1",
  52. Android_2_1: "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 Chrome/4.1.249.1025",
  53. Android_2_3: "Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/GRK39F) AppleWebKit/533.1 (KTHML, like Gecko) Version/4.0 Mobile Safari/533.1",
  54. Android_2_3_Lenovo_A750: "Lenovo-A750/S102 Linux/2.6.35.7 Android/2.3 Release/12.12.2011 Browser AppleWebkit533.1 Profile/ Configuration/",
  55. Android_4_1_1: "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03O) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
  56. Android_4_1_1_Tablet: "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03S) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19",
  57. Android_4_3: "Mozilla/5.0 (Linux; Android 4.3; Nexus 4 Build/JWR66Y) AppleWebKit/537.36 (KTHML, like Gecko) Chrome/29.0.1547.59 Mobile Safari/537.36",
  58. BlackBerry_6_0_0_141: "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-GB) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.141 Mobile Safari/534.1+",
  59. PlayBook_1_0_0: "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/0.0.1 Safari/534.8+",
  60. PlayBook_2_1_0: "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+",
  61. BB10: "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+",
  62. Opera_11_51: "Opera/9.80 (Macintosh; Intel Mac OS X 10.7.1; U; en) Presto/2.9.168 Version/11.51",
  63. Opera_Mobile_Simulator: "Opera/9.80 (Macintosh; Intel Mac OS X; Opera Mobi/[BUILD_NR]; U; en) Presto/2.7.81 Version/11.00",
  64. Kindle: "Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) Version/4.0 Kindle/3.0 (screen 600×800; rotate)",
  65. Silk_1_0_accel: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.13.328_10008910) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true",
  66. Silk_1_0: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  67. Chrome_Android_18_0: "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19",
  68. Chrome_iOS_19_0: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
  69. Chrome_OSX_24_0: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17",
  70. Firefox_13_Tablet: "Mozilla/5.0 (Android; Tablet; rv:13.0) Gecko/13.0 Firefox/13.0",
  71. Firefox_13_Phone: "Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0",
  72. Firefox_6_0_2: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2",
  73. Firefox_Mobile_Simulator: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:2.1.1) Gecko/ Firefox/4.0.2pre Fennec/4.0.1",
  74. Firefox_Os_Phone: "Mozilla/5.0 (Mobile; rv:18.0) Gecko/18.0 Firefox/18.0",
  75. Firefox_Os_Tablet: "Mozilla/5.0 (Tablet; rv:18.0) Gecko/18.0 Firefox/18.0",
  76. Windows_IE_9: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
  77. Windows_IE_9_Compat: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)",
  78. Windows_IE_10: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
  79. Windows_IE_11: "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko",
  80. Windows_RT_Surface: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)",
  81. Windows_Phone_8: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; Windows Phone 8X by HTC)"
  82. }
  83. function detect(ua, platform, callback){
  84. if (!callback) callback = platform, platform = ""
  85. var obj = {}
  86. $.__detect.call(obj, ua, platform)
  87. callback.call(null, obj.os, obj.browser)
  88. }
  89. Evidence('ZeptoDetectTest', {
  90. testSafariOSX: function(t){
  91. detect(UA.Safari_OSX_7_0_1, function(os, browser){
  92. t.assertUndefined(os.osx)
  93. t.assert(!os.ipad)
  94. t.assertTrue(browser.webkit)
  95. t.assertTrue(browser.safari)
  96. t.assertFalse(!!browser.chrome)
  97. t.assertEqual("7.0.1",browser.version)
  98. })
  99. detect(UA.Safari_OSX_7_0, function(os, browser){
  100. t.assert(!os.ipad)
  101. t.assertTrue(browser.webkit)
  102. t.assertTrue(browser.safari)
  103. t.assertFalse(!!browser.chrome)
  104. t.assertEqual("7.0",browser.version)
  105. })
  106. detect(UA.Safari_OSX_6_0, function(os, browser){
  107. t.assert(!os.ipad)
  108. t.assertTrue(browser.webkit)
  109. t.assertTrue(browser.safari)
  110. t.assertFalse(!!browser.chrome)
  111. t.assertEqual("6.0",browser.version)
  112. })
  113. },
  114. testSafariWindows: function(t){
  115. detect(UA.Safari_Windows_NT, "Windows", function(os, browser){
  116. t.assertUndefined(os.osx)
  117. t.assertUndefined(os.ios)
  118. t.assertUndefined(os.wp)
  119. t.assertTrue(browser.webkit)
  120. t.assertTrue(browser.safari)
  121. t.assertFalse(!!browser.chrome)
  122. t.assertEqual("5.0.4", browser.version)
  123. })
  124. },
  125. testWebOS: function(t){
  126. detect(UA.WebOS_1_4_0_Pre, function(os, browser){
  127. t.assertTrue(os.webos)
  128. t.assert(!os.touchpad)
  129. t.assertTrue(browser.webkit)
  130. t.assertEqual("1.4.0", os.version)
  131. })
  132. detect(UA.WebOS_1_4_0_Pixi, function(os){
  133. t.assertTrue(os.webos)
  134. t.assertEqual("1.4.0", os.version)
  135. })
  136. detect(UA.WebOS_1_2_9_Pixi, function(os){
  137. t.assertTrue(os.webos)
  138. t.assertEqual("1.2.9", os.version)
  139. })
  140. detect(UA.WebOS_3_0_0_TouchPad, function(os){
  141. t.assertTrue(os.webos)
  142. t.assertTrue(os.touchpad)
  143. t.assertEqual("3.0.0", os.version)
  144. })
  145. },
  146. testAndroid: function(t){
  147. detect(UA.Android_1_5, function(os, browser){
  148. t.assertTrue(os.android)
  149. t.assertTrue(browser.webkit)
  150. t.assertEqual("1.5", os.version)
  151. t.assertTrue(os.phone)
  152. t.assertFalse(!!browser.safari)
  153. })
  154. detect(UA.Android_2_1, function(os, browser){
  155. t.assertTrue(os.android)
  156. t.assertTrue(browser.webkit)
  157. t.assertEqual("2.1", os.version)
  158. t.assertTrue(os.phone)
  159. t.assertFalse(!!browser.safari)
  160. })
  161. detect(UA.Android_2_3, function(os, browser){
  162. t.assertTrue(os.android)
  163. t.assertTrue(browser.webkit)
  164. t.assertEqual("2.3.7", os.version)
  165. t.assertTrue(os.phone)
  166. t.assertFalse(!!browser.safari)
  167. })
  168. detect(UA.Android_2_3_Lenovo_A750, function(os, browser){
  169. t.assertTrue(os.android, 'Expected Android')
  170. t.assertTrue(browser.webkit, 'Expected WebKit')
  171. t.assertEqual("2.3", os.version)
  172. // FIXME: Unfortunately we can't detect if it's a phone, as there's
  173. // no "mobile" in the UA string.
  174. // t.assertTrue(os.phone, 'Expected phone')
  175. t.assertFalse(!!browser.safari, 'Expected browser to not be Safari')
  176. })
  177. detect(UA.Android_4_1_1, function(os, browser){
  178. t.assertTrue(os.android)
  179. t.assertTrue(browser.webkit)
  180. t.assertFalse(!!os.ios)
  181. t.assertEqual("4.1.1", os.version)
  182. t.assertTrue(os.phone)
  183. t.assertFalse(!!os.iphone)
  184. t.assertTrue(browser.chrome)
  185. t.assertFalse(!!browser.safari)
  186. })
  187. detect(UA.Android_4_1_1_Tablet, function(os, browser){
  188. t.assertTrue(os.android)
  189. t.assertTrue(browser.webkit)
  190. t.assertEqual("4.1.1", os.version)
  191. t.assertTrue(os.tablet)
  192. t.assertTrue(browser.chrome)
  193. t.assertFalse(!!browser.safari)
  194. })
  195. detect(UA.Android_4_3, function(os, browser){
  196. t.assertTrue(os.android)
  197. t.assertTrue(browser.webkit)
  198. t.assertFalse(!!os.ios)
  199. t.assertEqual("4.3", os.version)
  200. t.assertTrue(os.phone)
  201. t.assertFalse(!!os.iphone)
  202. t.assertTrue(browser.chrome)
  203. t.assertFalse(!!browser.safari)
  204. })
  205. },
  206. testIOS: function(t){
  207. detect(UA.iOS_3_0_iPhone, function(os, browser){
  208. t.assertTrue(os.ios)
  209. t.assertTrue(os.iphone)
  210. t.assertTrue(browser.webkit)
  211. t.assertEqual("3.0", os.version)
  212. t.assertEqual("420.1", browser.version)
  213. t.assertTrue(os.phone)
  214. t.assertTrue(browser.safari)
  215. t.assertFalse(!!os.android)
  216. t.assertFalse(!!browser.ie)
  217. t.assertFalse(!!browser.firefox)
  218. t.assertFalse(!!browser.silk)
  219. t.assertFalse(!!browser.chrome)
  220. t.assertFalse(!!browser.playbook)
  221. })
  222. detect(UA.iOS_3_1_1_iPod, function(os, browser){
  223. t.assertTrue(os.ios)
  224. t.assertUndefined(os.iphone)
  225. t.assertTrue(os.ipod)
  226. t.assertEqual("3.1.1", os.version)
  227. t.assertFalse(!!os.phone)
  228. t.assertTrue(browser.safari)
  229. })
  230. detect(UA.iOS_3_2_iPad, function(os, browser){
  231. t.assertTrue(os.ios)
  232. t.assertTrue(os.ipad)
  233. t.assertFalse(!!os.iphone)
  234. t.assertEqual("3.2", os.version)
  235. t.assertTrue(os.tablet)
  236. t.assertTrue(browser.safari)
  237. })
  238. detect(UA.iOS_3_2_iPad_2, function(os, browser){
  239. t.assertTrue(os.ios)
  240. t.assertTrue(os.ipad)
  241. t.assert(!os.iphone)
  242. t.assertEqual("3.2", os.version)
  243. t.assertTrue(os.tablet)
  244. t.assertTrue(browser.safari)
  245. })
  246. detect(UA.iOS_4_0_iPhone, function(os, browser){
  247. t.assertTrue(os.ios)
  248. t.assertTrue(os.iphone)
  249. t.assert(!os.ipad)
  250. t.assertEqual("4.0", os.version)
  251. t.assertTrue(os.phone)
  252. t.assertTrue(browser.safari)
  253. })
  254. detect(UA.iOS_4_2_iPad, function(os, browser){
  255. t.assertTrue(os.ios)
  256. t.assertTrue(os.ipad)
  257. t.assertEqual("4.2", os.version)
  258. t.assertFalse(os.phone)
  259. t.assertTrue(os.tablet)
  260. t.assertTrue(browser.safari)
  261. })
  262. detect(UA.iOS_4_3_iPhone_Simulator, function(os, browser){
  263. t.assertTrue(os.ios)
  264. t.assertTrue(os.iphone)
  265. t.assertEqual("4.3", os.version)
  266. t.assertTrue(os.phone)
  267. t.assertFalse(os.tablet)
  268. t.assertTrue(browser.safari)
  269. })
  270. detect(UA.iOS_5_0_iPhone, function(os, browser){
  271. t.assert(os.ios)
  272. t.assert(os.iphone)
  273. t.assertEqual("5.0", os.version)
  274. t.assertTrue(os.phone)
  275. t.assertFalse(os.tablet)
  276. t.assertTrue(browser.safari)
  277. })
  278. detect(UA.iOS_5_1_iPad_webView, function(os, browser){
  279. t.assert(os.ios)
  280. t.assert(os.ipad)
  281. t.assertEqual("5.1", os.version)
  282. t.assertTrue(browser.webview)
  283. t.assertTrue(browser.safari)
  284. })
  285. detect(UA.iOS_6_1_iPhone, function(os, browser){
  286. t.assert(os.ios)
  287. t.assert(os.iphone)
  288. t.assertEqual("6.1", os.version)
  289. t.assertTrue(os.phone)
  290. t.assertFalse(os.tablet)
  291. t.assertTrue(browser.safari)
  292. t.assertFalse(!!browser.webview)
  293. t.assertFalse(!!browser.chrome)
  294. t.assertFalse(!!browser.firefox)
  295. })
  296. detect(UA.iOS_6_0_iPad_mini, function(os, browser){
  297. t.assert(os.ios)
  298. t.assert(os.ipad)
  299. t.assertEqual("6.0", os.version)
  300. t.assertFalse(os.phone)
  301. t.assertTrue(os.tablet)
  302. t.assertTrue(browser.safari)
  303. })
  304. detect(UA.iOS_7_0_iPhone, function(os, browser){
  305. t.assert(os.ios)
  306. t.assert(os.iphone)
  307. t.assertEqual("7.0", os.version)
  308. t.assertTrue(os.phone)
  309. t.assertFalse(os.tablet)
  310. t.assertTrue(browser.safari)
  311. t.assertFalse(!!browser.chrome)
  312. t.assertFalse(!!browser.firefox)
  313. })
  314. detect(UA.iOS_7_0_iPhone_Chrome, function(os, browser){
  315. t.assert(os.ios)
  316. t.assert(os.iphone)
  317. t.assertEqual("7.0", os.version)
  318. t.assertTrue(os.phone)
  319. t.assertFalse(os.tablet)
  320. t.assertFalse(!!browser.safari)
  321. t.assertTrue(browser.chrome)
  322. t.assertFalse(!!browser.firefox)
  323. t.assertFalse(!!browser.webview)
  324. })
  325. },
  326. testBlackBerry: function(t) {
  327. detect(UA.BlackBerry_6_0_0_141, function(os, browser){
  328. t.assertTrue(os.blackberry)
  329. t.assertTrue(browser.webkit)
  330. t.assertEqual("6.0.0.141", os.version)
  331. }),
  332. detect(UA.PlayBook_1_0_0, function(os, browser){
  333. t.assertTrue(os.rimtabletos)
  334. t.assertTrue(browser.webkit)
  335. t.assertTrue(os.tablet)
  336. t.assertEqual("1.0.0", os.version)
  337. })
  338. detect(UA.PlayBook_2_1_0, function(os, browser){
  339. t.assertTrue(os.rimtabletos)
  340. t.assertTrue(browser.webkit)
  341. t.assertTrue(os.tablet)
  342. t.assertEqual("2.1.0", os.version)
  343. })
  344. detect(UA.BB10, function(os, browser){
  345. t.assertTrue(os.bb10)
  346. t.assertTrue(browser.webkit)
  347. t.assertTrue(os.phone)
  348. t.assertEqual("10.0.0.1337", os.version)
  349. })
  350. },
  351. testKindle: function(t) {
  352. detect(UA.Kindle, function(os, browser){
  353. t.assertTrue(os.kindle)
  354. t.assertTrue(browser.webkit)
  355. t.assertEqual("3.0", os.version)
  356. })
  357. detect(UA.Silk_1_0, function(os, browser){
  358. t.assertTrue(os.android)
  359. t.assertTrue(browser.webkit)
  360. t.assertTrue(browser.silk)
  361. t.assertEqual("2.3.4", os.version)
  362. })
  363. detect(UA.Silk_1_0_accel, function(os, browser){
  364. t.assert(!os.android)
  365. t.assertTrue(browser.webkit)
  366. t.assertTrue(browser.silk)
  367. t.assertEqual("1.0.13.328_10008910", browser.version)
  368. })
  369. },
  370. testFirefox: function(t) {
  371. detect(UA.Firefox_6_0_2, function(os, browser){
  372. t.assertFalse(browser.webkit)
  373. t.assertEqual('6.0.2', browser.version)
  374. t.assertTrue(browser.firefox)
  375. t.assertFalse(!!os.firefoxos)
  376. })
  377. detect(UA.Firefox_13_Tablet, function(os, browser){
  378. t.assertTrue(browser.firefox)
  379. t.assertFalse(browser.webkit)
  380. t.assertTrue(os.android)
  381. t.assertFalse(os.phone)
  382. t.assertTrue(os.tablet)
  383. t.assertFalse(!!os.firefoxos)
  384. })
  385. detect(UA.Firefox_13_Phone, function(os, browser){
  386. t.assertTrue(browser.firefox)
  387. t.assertFalse(browser.webkit)
  388. t.assertTrue(os.android)
  389. t.assertTrue(os.phone)
  390. t.assertFalse(os.tablet)
  391. t.assertFalse(!!os.firefoxos)
  392. })
  393. detect(UA.Firefox_Os_Phone, function(os, browser){
  394. t.assertTrue(browser.firefox)
  395. t.assertFalse(browser.webkit)
  396. t.assertTrue(os.firefoxos)
  397. t.assertTrue(os.phone)
  398. t.assertFalse(os.tablet)
  399. t.assertEqual('18.0', os.version)
  400. })
  401. detect(UA.Firefox_Os_Tablet, function(os, browser){
  402. t.assertTrue(browser.firefox)
  403. t.assertFalse(browser.webkit)
  404. t.assertTrue(os.firefoxos)
  405. t.assertTrue(os.tablet)
  406. t.assertFalse(os.phone)
  407. t.assertEqual('18.0', os.version)
  408. })
  409. },
  410. testOpera: function(t) {
  411. detect(UA.Opera_11_51, function(os, browser){
  412. t.assertFalse(browser.webkit)
  413. t.assertUndefined(browser.version)
  414. })
  415. },
  416. testChrome: function(t) {
  417. detect(UA.Chrome_Android_18_0, function(os, browser){
  418. t.assertTrue(os.android)
  419. t.assertTrue(browser.webkit)
  420. t.assertTrue(browser.chrome)
  421. t.assertTrue(os.phone)
  422. t.assertFalse(os.tablet)
  423. t.assertEqual("18.0.1025.133", browser.version)
  424. })
  425. detect(UA.Chrome_iOS_19_0, function(os, browser){
  426. t.assertTrue(os.phone)
  427. t.assertFalse(os.tablet)
  428. t.assertTrue(os.ios)
  429. t.assertTrue(browser.webkit)
  430. t.assertTrue(browser.chrome)
  431. t.assertEqual("19.0.1084.60", browser.version)
  432. })
  433. detect(UA.Chrome_OSX_24_0, function(os, browser){
  434. t.assertFalse(os.phone)
  435. t.assertFalse(os.tablet)
  436. t.assertTrue(browser.chrome)
  437. })
  438. },
  439. testIE: function(t) {
  440. detect(UA.Windows_IE_11, function(os, browser){
  441. t.assertFalse(os.phone)
  442. t.assertFalse(os.tablet)
  443. t.assertTrue(browser.ie)
  444. t.assertEqual("11", browser.version)
  445. })
  446. detect(UA.Windows_IE_10, function(os, browser){
  447. t.assertFalse(os.phone)
  448. t.assertFalse(os.tablet)
  449. t.assertTrue(browser.ie)
  450. t.assertEqual("10.0", browser.version)
  451. })
  452. detect(UA.Windows_RT_Surface, function(os, browser){
  453. t.assertFalse(os.phone)
  454. t.assertTrue(os.tablet)
  455. t.assertTrue(browser.ie)
  456. t.assertEqual("10.0", browser.version)
  457. })
  458. detect(UA.Windows_Phone_8, function(os, browser){
  459. t.assertTrue(os.wp)
  460. t.assertTrue(os.phone)
  461. t.assertFalse(os.tablet)
  462. t.assertTrue(browser.ie)
  463. t.assertEqual("10.0", browser.version)
  464. })
  465. detect(UA.Windows_IE_9, function(os, browser){
  466. t.assertFalse(os.phone)
  467. t.assertFalse(os.tablet)
  468. t.assertTrue(browser.ie)
  469. t.assertEqual("9.0", browser.version)
  470. })
  471. detect(UA.Windows_IE_9_Compat, function(os, browser){
  472. t.assertFalse(os.phone)
  473. t.assertFalse(os.tablet)
  474. t.assertTrue(browser.ie)
  475. t.assertEqual("7.0", browser.version)
  476. })
  477. }
  478. })
  479. })()
  480. </script>
  481. </body>
  482. </html>