Permalink
Browse files

MDL-43082 Themes IE 9 Compatibility View doesn't support SVG.

  • Loading branch information...
1 parent 3e6e38b commit eadcc99eeae70b4bab67cb45487127c18cb3ff22 @scara scara committed with Matteo Scaramuccia Nov 27, 2013
Showing with 78 additions and 2 deletions.
  1. +3 −0 lib/classes/useragent.php
  2. +12 −2 lib/tests/theme_config_test.php
  3. +63 −0 lib/tests/useragent_test.php
@@ -863,6 +863,9 @@ public static function supports_svg() {
} else if (self::is_ie() and !self::check_ie_version('9')) {
// IE < 9 doesn't support SVG. Say no.
$instance->supportssvg = false;
+ } else if (self::is_ie() and !self::check_ie_version('10') and self::check_ie_compatibility_view()) {
+ // IE 9 Compatibility View doesn't support SVG. Say no.
+ $instance->supportssvg = false;
} else if (preg_match('#Android +[0-2]\.#', $instance->useragent)) {
// Android < 3 doesn't support SVG. Say no.
$instance->supportssvg = false;
@@ -82,7 +82,15 @@ public function test_svg_image_use() {
// IE9 on Windows 7.
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => true,
// IE9 on Windows 7 in intranet mode.
- 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)' => true,
+ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)' => false,
+ // IE10 on Windows 8.
+ 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)' => true,
+ // IE10 on Windows 8 in compatibility mode.
+ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)' => true,
+ // IE11 on Windows 8.
+ 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0)' => true,
+ // IE11 on Windows 8 in compatibility mode.
+ 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)' => true,
// Chrome 11 on Windows.
'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Chrome/11.0.652.0 Safari/534.17' => true,
// Chrome 22 on Windows.
@@ -102,7 +110,9 @@ public function test_svg_image_use() {
// Android browser 2.3 (HTC).
'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => false,
// Android browser 3.0 (Motorola).
- 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13' => true
+ 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13' => true,
+ // Android browser 4.3 (Samsung GT-9505).
+ 'Mozilla/5.0 (Linux; Android 4.3; it-it; SAMSUNG GT-I9505/I9505XXUEMJ7 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36' => true
);
foreach ($useragents as $agent => $expected) {
core_useragent::instance(true, $agent);
@@ -138,6 +138,9 @@ class core_useragent_testcase extends basic_testcase {
'530' => array(
'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'
),
+ '537' => array(
+ 'Samsung GT-9505' => 'Mozilla/5.0 (Linux; Android 4.3; it-it; SAMSUNG GT-I9505/I9505XXUEMJ7 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36'
+ )
),
'Chrome' => array(
'8' => array(
@@ -414,6 +417,66 @@ public function test_check_browser_version() {
}
/**
+ * Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if supports_svg
+ * works as expected.
+ */
+ public function test_supports_svg() {
+ $this->assertTrue(core_useragent::supports_svg());
+
+ // MSIE 5.0 is not considered a browser at all: known false positive.
+ core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['5.5']['Windows 2000']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['7.0']['Windows XP SP2']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['8.0']['Windows Vista']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['MSIE']['11.0i']['Windows 8.1']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['WebKit Android']['525']['G1 Phone']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Samsung GT-9505']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']);
+ $this->assertFalse(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
+ $this->assertTrue(core_useragent::supports_svg());
+
+ core_useragent::instance(true, $this->user_agents['Firefox']['18.0']['Mac OS X']);
+ $this->assertTrue(core_useragent::supports_svg());
+ }
+
+ /**
* Test browser version classes functionality.
*/
public function test_get_browser_version_classes() {

0 comments on commit eadcc99

Please sign in to comment.