21e0ef7b04a841d61ff1ef10e409183753aeb53c
[moodle.git] / lib / tests / useragent_test.php
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 /**
18  * Tests the user agent class.
19  *
20  * @package    core
21  * @copyright  2013 Sam Hemelryk
22  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23  */
25 /**
26  * User agent test suite.
27  *
28  * @package    core
29  * @copyright  2013 Sam Hemelryk
30  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31  */
32 class core_useragent_testcase extends basic_testcase {
34     /**
35      * User agents we'll be using to test.
36      * @var array
37      */
38     protected $user_agents = array(
39         'MSIE' => array(
40             '5.0' => array(
41                 'Windows 98' => 'Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)'
42             ),
43             '5.5' => array(
44                 'Windows 2000' => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)'
45             ),
46             '6.0' => array(
47                 'Windows XP SP2' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
48             ),
49             '7.0' => array(
50                 'Windows XP SP2' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)'
51             ),
52             '8.0' => array(
53                 'Windows Vista' => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)'
54             ),
55             '9.0' => array(
56                 'Windows 7' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'
57             ),
58             '9.0i' => array(
59                 'Windows 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'
60             ),
61             '10.0' => array(
62                 'Windows 8' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)'
63             ),
64             '10.0i' => array(
65                 'Windows 8' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)'
66             ),
67         ),
68         'Firefox' => array(
69             '1.0.6' => array(
70                 'Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6'
71             ),
72             '1.5' => array(
73                 'Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8) Gecko/20051107 Firefox/1.5'
74             ),
75             '1.5.0.1' => array(
76                 'Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'
77             ),
78             '2.0' => array(
79                 'Windows XP' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1',
80                 'Ubuntu Linux AMD64' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)'
81             ),
82             '3.0.6' => array(
83                 'SUSE' => 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-1.4 Firefox/3.0.6'
84             ),
85             '3.6' => array(
86                 'Linux' => 'Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/3.6'
87             ),
88             '11.0' => array(
89                 'Windows' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko Firefox/11.0'
90             ),
91             '15.0a2' => array(
92                 'Windows' => 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2'
93             ),
94             '18.0' => array(
95                 'Mac OS X' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/18.0 Firefox/18.0'
96             ),
97         ),
98         'SeaMonkey' => array(
99             '2.0' => array(
100                 'Windows' => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1b3pre) Gecko/20081208 SeaMonkey/2.0'
101             ),
102             '2.1' => array(
103                 'Linux' => 'Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20110609 Firefox/4.0.1 SeaMonkey/2.1'
104             ),
105             '2.3' => array(
106                 'FreeBSD' => 'Mozilla/5.0 (X11; FreeBSD amd64; rv:6.0) Gecko/20110818 Firefox/6.0 SeaMonkey/2.3'
107             ),
108         ),
109         'Safari' => array(
110             '312' => array(
111                 'Mac OS X' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312'
112             ),
113             '412' => array(
114                 'Mac OS X' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412'
115             ),
116             '2.0' => array(
117                 'Mac OS X' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412'
118             )
119         ),
120         'Safari iOS' => array(
121             '528' => array(
122                 'iPhone' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; cs-cz) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'
123             ),
124             '533' => array(
125                 'iPad' => 'Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5'
126             ),
127         ),
128         'WebKit Android' => array(
129             '525' => array(
130                 'G1 Phone' => 'Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2 – G1 Phone'
131             ),
132             '530' => array(
133                 'Nexus' => 'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 –Nexus'
134             ),
135         ),
136         'Chrome' => array(
137             '8' => array(
138                 'Mac OS X' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10'
139             ),
140         ),
141         'Opera' => array(
142             '8.51' => array(
143                 'Windows XP' => 'Opera/8.51 (Windows NT 5.1; U; en)'
144             ),
145             '9.0'  => array(
146                 'Windows XP' => 'Opera/9.0 (Windows NT 5.1; U; en)',
147                 'Debian Linux' => 'Opera/9.01 (X11; Linux i686; U; en)'
148             )
149         )
150     );
152     /**
153      * Test instance generation.
154      */
155     public function test_instance() {
156         $this->assertInstanceOf('core_useragent', core_useragent::instance());
157         $this->assertInstanceOf('core_useragent', core_useragent::instance(true));
158     }
160     /**
161      * Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version
162      * works as expected.
163      */
164     public function test_check_browser_version() {
165         core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']);
166         $this->assertTrue(core_useragent::check_safari_version());
167         $this->assertTrue(core_useragent::check_webkit_version());
168         $this->assertTrue(core_useragent::check_safari_version('312'));
169         $this->assertFalse(core_useragent::check_safari_version('500'));
170         $this->assertFalse(core_useragent::check_chrome_version());
171         $this->assertFalse(core_useragent::check_safari_ios_version());
173         core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']);
174         $this->assertTrue(core_useragent::check_safari_ios_version());
175         $this->assertTrue(core_useragent::check_webkit_version());
176         $this->assertTrue(core_useragent::check_safari_ios_version('527'));
177         $this->assertFalse(core_useragent::check_safari_ios_version(590));
178         $this->assertFalse(core_useragent::check_safari_version('312'));
179         $this->assertFalse(core_useragent::check_safari_version('500'));
180         $this->assertFalse(core_useragent::check_chrome_version());
182         core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']);
183         $this->assertTrue(core_useragent::check_webkit_version());
184         $this->assertTrue(core_useragent::check_webkit_android_version('527'));
185         $this->assertFalse(core_useragent::check_webkit_android_version(590));
186         $this->assertFalse(core_useragent::check_safari_version());
187         $this->assertFalse(core_useragent::check_chrome_version());
189         core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
190         $this->assertTrue(core_useragent::check_chrome_version());
191         $this->assertTrue(core_useragent::check_webkit_version());
192         $this->assertTrue(core_useragent::check_chrome_version(8));
193         $this->assertFalse(core_useragent::check_chrome_version(10));
194         $this->assertFalse(core_useragent::check_safari_version('1'));
196         core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']);
197         $this->assertTrue(core_useragent::check_opera_version());
198         $this->assertTrue(core_useragent::check_opera_version('8.0'));
199         $this->assertFalse(core_useragent::check_opera_version('10.0'));
201         core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']);
202         $this->assertTrue(core_useragent::check_ie_version());
203         $this->assertTrue(core_useragent::check_ie_version('5.0'));
204         $this->assertFalse(core_useragent::check_ie_version('7.0'));
206         core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']);
207         $this->assertFalse(core_useragent::check_ie_version());
208         $this->assertTrue(core_useragent::check_ie_version(0));
209         $this->assertTrue(core_useragent::check_ie_version('5.0'));
210         $this->assertFalse(core_useragent::check_ie_version('7.0'));
212         core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']);
213         $this->assertTrue(core_useragent::check_ie_version());
214         $this->assertTrue(core_useragent::check_ie_version(0));
215         $this->assertTrue(core_useragent::check_ie_version('5.0'));
216         $this->assertTrue(core_useragent::check_ie_version('9.0'));
217         $this->assertFalse(core_useragent::check_ie_version('10'));
219         core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']);
220         $this->assertTrue(core_useragent::check_ie_version());
221         $this->assertTrue(core_useragent::check_ie_version(0));
222         $this->assertTrue(core_useragent::check_ie_version('5.0'));
223         $this->assertTrue(core_useragent::check_ie_version('9.0'));
224         $this->assertFalse(core_useragent::check_ie_version('10'));
226         core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']);
227         $this->assertTrue(core_useragent::check_ie_version());
228         $this->assertTrue(core_useragent::check_ie_version(0));
229         $this->assertTrue(core_useragent::check_ie_version('5.0'));
230         $this->assertTrue(core_useragent::check_ie_version('9.0'));
231         $this->assertTrue(core_useragent::check_ie_version('10'));
232         $this->assertFalse(core_useragent::check_ie_version('11'));
234         core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']);
235         $this->assertTrue(core_useragent::check_ie_version());
236         $this->assertTrue(core_useragent::check_ie_version(0));
237         $this->assertTrue(core_useragent::check_ie_version('5.0'));
238         $this->assertTrue(core_useragent::check_ie_version('9.0'));
239         $this->assertTrue(core_useragent::check_ie_version('10'));
240         $this->assertFalse(core_useragent::check_ie_version('11'));
242         core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
243         $this->assertTrue(core_useragent::check_firefox_version());
244         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
245         $this->assertFalse(core_useragent::check_firefox_version('3.0'));
246         $this->assertTrue(core_useragent::check_gecko_version('2'));
247         $this->assertTrue(core_useragent::check_gecko_version(20030516));
248         $this->assertTrue(core_useragent::check_gecko_version(20051106));
249         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
251         core_useragent::instance(true, $this->user_agents['Firefox']['1.0.6']['Windows XP']);
252         $this->assertTrue(core_useragent::check_firefox_version());
253         $this->assertTrue(core_useragent::check_gecko_version('1'));
254         $this->assertFalse(core_useragent::check_gecko_version(20030516));
255         $this->assertFalse(core_useragent::check_gecko_version(20051106));
256         $this->assertFalse(core_useragent::check_gecko_version(2006010100));
257         $this->assertFalse(core_useragent::check_firefox_version('1.5'));
258         $this->assertFalse(core_useragent::check_firefox_version('3.0'));
259         $this->assertFalse(core_useragent::check_gecko_version('2'));
261         core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
262         $this->assertTrue(core_useragent::check_firefox_version());
263         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
264         $this->assertTrue(core_useragent::check_gecko_version('1'));
265         $this->assertTrue(core_useragent::check_gecko_version('2'));
266         $this->assertTrue(core_useragent::check_gecko_version(20030516));
267         $this->assertTrue(core_useragent::check_gecko_version(20051106));
268         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
269         $this->assertFalse(core_useragent::check_firefox_version('3.0'));
271         core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']);
272         $this->assertTrue(core_useragent::check_firefox_version());
273         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
274         $this->assertTrue(core_useragent::check_firefox_version('3.0'));
275         $this->assertTrue(core_useragent::check_gecko_version('2'));
276         $this->assertTrue(core_useragent::check_gecko_version('3.6'));
277         $this->assertTrue(core_useragent::check_gecko_version(20030516));
278         $this->assertTrue(core_useragent::check_gecko_version(20051106));
279         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
280         $this->assertFalse(core_useragent::check_firefox_version('4'));
281         $this->assertFalse(core_useragent::check_firefox_version('10'));
283         core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']);
284         $this->assertTrue(core_useragent::check_firefox_version());
285         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
286         $this->assertTrue(core_useragent::check_firefox_version('3.0'));
287         $this->assertTrue(core_useragent::check_gecko_version('2'));
288         $this->assertTrue(core_useragent::check_gecko_version('3.6'));
289         $this->assertTrue(core_useragent::check_gecko_version(20030516));
290         $this->assertTrue(core_useragent::check_gecko_version(20051106));
291         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
292         $this->assertFalse(core_useragent::check_firefox_version('4'));
293         $this->assertFalse(core_useragent::check_firefox_version('10'));
294         $this->assertFalse(core_useragent::check_firefox_version('18'));
295         $this->assertFalse(core_useragent::check_gecko_version('4'));
297         core_useragent::instance(true, $this->user_agents['Firefox']['15.0a2']['Windows']);
298         $this->assertTrue(core_useragent::check_firefox_version());
299         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
300         $this->assertTrue(core_useragent::check_firefox_version('3.0'));
301         $this->assertTrue(core_useragent::check_gecko_version('2'));
302         $this->assertTrue(core_useragent::check_gecko_version('3.6'));
303         $this->assertTrue(core_useragent::check_gecko_version('15.0'));
304         $this->assertTrue(core_useragent::check_gecko_version(20030516));
305         $this->assertTrue(core_useragent::check_gecko_version(20051106));
306         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
307         $this->assertTrue(core_useragent::check_firefox_version('4'));
308         $this->assertTrue(core_useragent::check_firefox_version('10'));
309         $this->assertTrue(core_useragent::check_firefox_version('15'));
310         $this->assertFalse(core_useragent::check_firefox_version('18'));
311         $this->assertFalse(core_useragent::check_gecko_version('18'));
313         core_useragent::instance(true, $this->user_agents['Firefox']['18.0']['Mac OS X']);
314         $this->assertTrue(core_useragent::check_firefox_version());
315         $this->assertTrue(core_useragent::check_firefox_version('1.5'));
316         $this->assertTrue(core_useragent::check_firefox_version('3.0'));
317         $this->assertTrue(core_useragent::check_gecko_version('2'));
318         $this->assertTrue(core_useragent::check_gecko_version('3.6'));
319         $this->assertTrue(core_useragent::check_gecko_version('15.0'));
320         $this->assertTrue(core_useragent::check_gecko_version('18.0'));
321         $this->assertTrue(core_useragent::check_gecko_version(20030516));
322         $this->assertTrue(core_useragent::check_gecko_version(20051106));
323         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
324         $this->assertTrue(core_useragent::check_firefox_version('4'));
325         $this->assertTrue(core_useragent::check_firefox_version('10'));
326         $this->assertTrue(core_useragent::check_firefox_version('15'));
327         $this->assertTrue(core_useragent::check_firefox_version('18'));
328         $this->assertFalse(core_useragent::check_firefox_version('19'));
329         $this->assertFalse(core_useragent::check_gecko_version('19'));
331         core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.0']['Windows']);
332         $this->assertTrue(core_useragent::check_gecko_version('2'));
333         $this->assertTrue(core_useragent::check_gecko_version(20030516));
334         $this->assertTrue(core_useragent::check_gecko_version(20051106));
335         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
336         $this->assertFalse(core_useragent::check_gecko_version('3.6'));
337         $this->assertFalse(core_useragent::check_gecko_version('4.0'));
338         $this->assertFalse(core_useragent::check_firefox_version());
340         core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.1']['Linux']);
341         $this->assertTrue(core_useragent::check_gecko_version('2'));
342         $this->assertTrue(core_useragent::check_gecko_version('3.6'));
343         $this->assertTrue(core_useragent::check_gecko_version('4.0'));
344         $this->assertTrue(core_useragent::check_gecko_version(20030516));
345         $this->assertTrue(core_useragent::check_gecko_version(20051106));
346         $this->assertTrue(core_useragent::check_gecko_version(2006010100));
347         $this->assertTrue(core_useragent::check_firefox_version());
348         $this->assertTrue(core_useragent::check_firefox_version(4.0));
349         $this->assertFalse(core_useragent::check_firefox_version(5));
350         $this->assertFalse(core_useragent::check_gecko_version('18.0'));
352     }
354     /**
355      * Test browser version classes functionality.
356      */
357     public function test_get_browser_version_classes() {
358         core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']);
359         $this->assertEquals(array('safari'), core_useragent::get_browser_version_classes());
361         core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
362         $this->assertEquals(array('safari'), core_useragent::get_browser_version_classes());
364         core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']);
365         $this->assertEquals(array('safari', 'ios'), core_useragent::get_browser_version_classes());
367         core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']);
368         $this->assertEquals(array('safari', 'android'), core_useragent::get_browser_version_classes());
370         core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
371         $this->assertEquals(array('safari'), core_useragent::get_browser_version_classes());
373         core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']);
374         $this->assertEquals(array('opera'), core_useragent::get_browser_version_classes());
376         core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']);
377         $this->assertEquals(array('ie', 'ie6'), core_useragent::get_browser_version_classes());
379         core_useragent::instance(true, $this->user_agents['MSIE']['7.0']['Windows XP SP2']);
380         $this->assertEquals(array('ie', 'ie7'), core_useragent::get_browser_version_classes());
382         core_useragent::instance(true, $this->user_agents['MSIE']['8.0']['Windows Vista']);
383         $this->assertEquals(array('ie', 'ie8'), core_useragent::get_browser_version_classes());
385         core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']);
386         $this->assertEquals(array('ie', 'ie9'), core_useragent::get_browser_version_classes());
388         core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']);
389         $this->assertEquals(array('ie', 'ie9'), core_useragent::get_browser_version_classes());
391         core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']);
392         $this->assertEquals(array('ie', 'ie10'), core_useragent::get_browser_version_classes());
394         core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']);
395         $this->assertEquals(array('ie', 'ie10'), core_useragent::get_browser_version_classes());
397         core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
398         $this->assertEquals(array('gecko', 'gecko18'), core_useragent::get_browser_version_classes());
400         core_useragent::instance(true, $this->user_agents['Firefox']['3.0.6']['SUSE']);
401         $this->assertEquals(array('gecko', 'gecko19'), core_useragent::get_browser_version_classes());
402     }
404     /**
405      * Test device type detection.
406      */
407     public function test_get_device_type() {
408         // IE8 (common pattern ~1.5% of IE7/8 users have embedded IE6 agent).
409         $ie8 = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BT Openworld BB; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Hotbar 10.2.197.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)';
410         core_useragent::instance(true, $ie8);
411         $this->assertEquals('default', core_useragent::get_device_type());
412         // Genuine IE6.
413         $ie6 = 'Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.0.3705; Media Center PC 2.8)';
414         core_useragent::instance(true, $ie6);
415         $this->assertEquals('legacy', core_useragent::get_device_type());
417         core_useragent::instance(true);
418     }