forked from madrobby/zepto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect.html
79 lines (65 loc) · 3.29 KB
/
detect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Zepto environment detection unit tests</title>
<script src="../src/compat.js"></script>
<script src="../src/zepto.js"></script>
<script src="../src/detect.js"></script>
<script src="../vendor/evidence.js"></script>
</head>
<body>
<h1>Zepto environment detection unit tests</h1>
<p>
See the browser console for results.
</p>
<script>
var UA = {
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",
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",
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",
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",
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",
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",
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",
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",
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",
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+"
};
function detect(t, os, version, ua){
navigator.userAgent = ua;
t.assert($.__detect(ua)[os]);
t.assertEqual(version, $.__detect(ua).version);
}
Evidence.TestCase.extend('ZeptoAjaxTest', {
testWebOS: function(t){
detect(t, "webos", "1.4.0", UA.WebOS_1_4_0_Pre);
detect(t, "webos", "1.4.0", UA.WebOS_1_4_0_Pixi);
},
testAndroid: function(t){
detect(t, "android", "1.5", UA.Android_1_5);
detect(t, "android", "2.1", UA.Android_2_1);
},
testIOS: function(t){
detect(t, "ios", "3.0", UA.iOS_3_0_iPhone);
detect(t, "ios", "3.1.1", UA.iOS_3_1_1_iPod);
detect(t, "ios", "3.2", UA.iOS_3_2_iPad);
detect(t, "ios", "4.0", UA.iOS_4_0_iPhone);
detect(t, "ios", "4.2", UA.iOS_4_2_iPad);
t.assert($.__detect(UA.iOS_3_2_iPad).ipad);
t.assert($.__detect(UA.iOS_4_2_iPad).ipad);
t.assert($.__detect(UA.iOS_4_0_iPhone).iphone);
},
testBlackBerry: function(t) {
detect(t, "blackberry", "6.0.0.141", UA.BlackBerry_6_0_0_141);
},
testBrowser: function(t){
navigator.userAgent = UA.iOS_4_0_iPhone;
t.assert($.browser);
t.assert($.browser.webkit);
t.assertEqual("533.19.4", $.browser.version);
}
});
</script>
</body>
</html>