summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-11-18 19:50:01 +0100
committerAleksander Machniak <alec@alec.pl>2013-11-18 19:50:01 +0100
commit3373e4ae1026b4ec729172074a7ec540410ebee4 (patch)
treed145541624022fce331a40fe2e6f46d61239a5a6
parent8328d0643eaadd30fb969f51cf51a96f622a459d (diff)
Fix browser version detection and failing tests
-rw-r--r--program/lib/Roundcube/rcube_browser.php2
-rw-r--r--tests/Framework/Browser.php16
2 files changed, 4 insertions, 14 deletions
diff --git a/program/lib/Roundcube/rcube_browser.php b/program/lib/Roundcube/rcube_browser.php
index abef5b5f5..e53e31200 100644
--- a/program/lib/Roundcube/rcube_browser.php
+++ b/program/lib/Roundcube/rcube_browser.php
@@ -41,7 +41,7 @@ class rcube_browser
$this->safari = !$this->chrome && (strpos($HTTP_USER_AGENT, 'safari') !== false || strpos($HTTP_USER_AGENT, 'applewebkit') !== false);
$this->mz = !$this->ie && !$this->safari && !$this->chrome && !$this->ns && strpos($HTTP_USER_AGENT, 'mozilla') !== false;
- if (preg_match('/(mozilla|chrome|msie|opera|safari|applewebkit|khtml)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
+ if (preg_match('/(chrome|msie|opera|version|khtml)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$this->ver = (float) $regs[3];
}
else if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php
index ac92e41e9..a042572a8 100644
--- a/tests/Framework/Browser.php
+++ b/tests/Framework/Browser.php
@@ -21,7 +21,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
/**
* @dataProvider browsers
*/
- function test_browser($useragent, $opera, $chrome, $ie, $ns, $ns4, $khtml, $safari, $mz)
+ function test_browser($useragent, $opera, $chrome, $ie, $ns, $safari, $mz)
{
$object = $this->getBrowser($useragent);
@@ -30,8 +30,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
$this->assertEquals($chrome, $object->chrome, 'Check for Chrome failed');
$this->assertEquals($ie, $object->ie, 'Check for IE failed');
$this->assertEquals($ns, $object->ns, 'Check for NS failed');
- $this->assertEquals($ns4, $object->ns4, 'Check for NS4 failed');
- $this->assertEquals($khtml, $object->khtml, 'Check for khtml failed');
$this->assertEquals($safari, $object->safari, 'Check for Safari failed');
$this->assertEquals($mz, $object->mz, 'Check for MZ failed');
}
@@ -132,7 +130,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
function browsers()
{
- return $this->extractDataSet(array('isOpera','isChrome','isIE','isNS','isNS4','isKHTML','isSafari','isMZ'));
+ return $this->extractDataSet(array('isOpera','isChrome','isIE','isNS','isSafari','isMZ'));
}
function useragents()
@@ -149,8 +147,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => false, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => false, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => true, //isMZ
'lang' => 'en-US', //lang
@@ -169,8 +165,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => false, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => false, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => true, //isMZ
'lang' => 'en-US', //lang
@@ -181,7 +175,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'Chrome Mac' => array(
'useragent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.461.0 Safari/534.3',
- 'version' => '5', //Version
+ 'version' => '6', //Version
'isWin' => false, //isWindows
'isLinux' => false,
'isMac' => true, //isMac
@@ -190,8 +184,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => true, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => true, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => false, //isMZ
'lang' => 'en-US', //lang
@@ -211,8 +203,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => false, //isChrome
'isIE' => true, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => false, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => false, //isMZ
'lang' => '', //lang