This repository has been archived by the owner on Jun 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.html
261 lines (239 loc) · 11.7 KB
/
test.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jquery.platformselector.js tests</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/qunit/git/qunit.js" type="text/javascript"></script>
<script src="jquery.platformselector.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
</head>
<body>
<h1 id="qunit-header">jquery.platformselector.js tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
<script type="text/javascript">
//<![CDATA[
(function ($) {
QUnit.testDone = function () {
$('body')[0].className = '';
};
$(function () { $('#qunit-testrunner-toolbar').append($('body')[0].className); });
test('Body should have JavaScript class', function () {
stop();
setTimeout(function () {
ok($('body').hasClass('js'), 'Body has JavaScript class applied');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Safari 5.0.2 on Mac', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5'
});
setTimeout(function () {
ok($('body').hasClass('safari'), 'Safari identified');
ok($('body').hasClass('safari_5'), 'Safari 5 identified');
ok($('body').hasClass('safari_5_0_2'), 'Safari 5.0.2 identified');
ok($('body').hasClass('mac'), 'Mac identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Safari 4.0.5 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7'
});
setTimeout(function () {
ok($('body').hasClass('safari'), 'Safari identified');
ok($('body').hasClass('safari_4'), 'Safari 4 identified');
ok($('body').hasClass('safari_4_0_5'), 'Safari 4.0.5 identified');
ok($('body').hasClass('win'), 'Windows identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Mobile Safari 4.0.5 on iPhone', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_2 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A400 Safari/6531.22.7'
});
setTimeout(function () {
ok($('body').hasClass('safari'), 'Safari identified');
ok($('body').hasClass('safari_4'), 'Safari 4 identified');
ok($('body').hasClass('safari_4_0_5'), 'Safari 4.0.5 identified');
ok($('body').hasClass('iphone'), 'iPhone identified');
ok($('body').hasClass('ios'), 'iOS identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Mobile Safari 4.0.5 on iPod touch', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_0_2 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A400 Safari/6531.22.7'
});
setTimeout(function () {
ok($('body').hasClass('safari'), 'Safari identified');
ok($('body').hasClass('safari_4'), 'Safari 4 identified');
ok($('body').hasClass('safari_4_0_5'), 'Safari 4.0.5 identified');
ok($('body').hasClass('ipod'), 'iPod identified');
ok($('body').hasClass('ios'), 'iOS identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Mobile Safari 4.0.4 on iPad', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10'
});
setTimeout(function () {
ok($('body').hasClass('safari'), 'Safari identified');
ok($('body').hasClass('safari_4'), 'Safari 4 identified');
ok($('body').hasClass('safari_4_0_4'), 'Safari 4.0.4 identified');
ok($('body').hasClass('ipad'), 'iPad identified');
ok($('body').hasClass('ios'), 'iOS identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify IE8 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'
});
setTimeout(function () {
ok($('body').hasClass('ie'), 'IE identified');
ok($('body').hasClass('ie_8'), 'IE8 identified');
ok($('body').hasClass('win'), 'Windows identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify IE7 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
});
setTimeout(function () {
ok($('body').hasClass('ie'), 'IE identified');
ok($('body').hasClass('ie_7'), 'IE7 identified');
ok($('body').hasClass('win'), 'Windows identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify IE6 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
});
setTimeout(function () {
ok($('body').hasClass('ie'), 'IE identified');
ok($('body').hasClass('ie_6'), 'IE6 identified');
ok($('body').hasClass('win'), 'Windows identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Firefox 3.6.3 on Mac', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'
});
setTimeout(function () {
ok($('body').hasClass('firefox'), 'Firefox identified');
ok($('body').hasClass('firefox_3'), 'Firefox 3 identified');
ok($('body').hasClass('firefox_3_6_3'), 'Firefox 3.6.3 identified');
ok($('body').hasClass('mac'), 'Mac identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Firefox 3.6.3 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'
});
setTimeout(function () {
ok($('body').hasClass('firefox'), 'Firefox identified');
ok($('body').hasClass('firefox_3'), 'Firefox 3 identified');
ok($('body').hasClass('firefox_3_6_3'), 'Firefox 3.6.3 identified');
ok($('body').hasClass('win'), 'Windows identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Opera 10.53 on Mac', function () {
stop();
$.platformSelector({
userAgent: 'Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.5.24 Version/10.53'
});
setTimeout(function () {
ok($('body').hasClass('opera'), 'Opera identified');
ok($('body').hasClass('opera_10'), 'Opera 10 identified');
ok($('body').hasClass('opera_10_53'), 'Opera 10.53 identified');
ok($('body').hasClass('mac'), 'Mac identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Opera 10.53 on Windows', function () {
stop();
$.platformSelector({
userAgent: 'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.5.24 Version/10.53'
});
setTimeout(function () {
ok($('body').hasClass('opera'), 'Opera identified');
ok($('body').hasClass('opera_10'), 'Opera 10 identified');
ok($('body').hasClass('opera_10_53'), 'Opera 10.53 identified');
ok($('body').hasClass('win'), 'Mac identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Blackberry (Torch 9800 user agent)', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+'
});
setTimeout(function () {
ok($('body').hasClass('blackberry'), 'Blackberry identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Blackberry (Bold 9000 user agent)', function () {
stop();
$.platformSelector({
userAgent: 'BlackBerry9000/4.6.0.167 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102'
});
setTimeout(function () {
ok($('body').hasClass('blackberry'), 'Blackberry identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify Android (Nexus One user agent)', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
});
setTimeout(function () {
ok($('body').hasClass('android'), 'Android identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
test('Should identify WebOS (Palm Pre user agent)', function () {
stop();
$.platformSelector({
userAgent: 'Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0'
});
setTimeout(function () {
ok($('body').hasClass('webos'), 'WebOS identified');
ok($('body').hasClass('mobile'), 'Mobile identified');
start();
}, 200); // Test requires some time for the DOM to update in some browsers (e.g. Opera)
});
})(jQuery);
//]]>
</script>
</body>
</html>