You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/06/24 11:26:17 UTC

svn commit: r1687218 - in /myfaces/tobago/branches/tobago-1.0.x/core/src: main/java/org/apache/myfaces/tobago/context/UserAgent.java test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java

Author: lofwyr
Date: Wed Jun 24 09:26:16 2015
New Revision: 1687218

URL: http://svn.apache.org/r1687218
Log:
TOBAGO-1474: Wrong position of menu in IE11

Added:
    myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java
Modified:
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/UserAgent.java

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/UserAgent.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/UserAgent.java?rev=1687218&r1=1687217&r2=1687218&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/UserAgent.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/context/UserAgent.java Wed Jun 24 09:26:16 2015
@@ -130,7 +130,7 @@ public class UserAgent implements Serial
       } else {
         return OPERA;
       }
-    } else if (header.indexOf("msie") > -1) {
+    } else if (header.indexOf("msie") > -1 || header.indexOf("trident") > -1) {
       if (header.indexOf("msie 5.0") > -1) {
         if (header.indexOf("mac") > -1) {
           return MSIE_5_0_MAC;
@@ -147,6 +147,8 @@ public class UserAgent implements Serial
         }
       } else if (header.indexOf("msie 7.0") > -1) {
         return MSIE_7_O;
+      } else if (header.indexOf("rv:11") > -1) {
+        return MOZILLA; // IE11 - Mozilla is here the best matching browser
       } else {
         return MSIE;
       }

Added: myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java?rev=1687218&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java (added)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/test/java/org/apache/myfaces/tobago/context/UserAgentUnitTest.java Wed Jun 24 09:26:16 2015
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.context;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.List;
+
+@RunWith(Parameterized.class)
+public class UserAgentUnitTest {
+
+  private UserAgent agent;
+  private String headerString;
+
+  public UserAgentUnitTest(final String title, final UserAgent agent, final String headerString) {
+    this.agent = agent;
+    this.headerString = headerString;
+  }
+
+  @Test
+  public void test() {
+    if (agent.equals(UserAgent.DEFAULT)) {
+      // XXX hack to prevent NPE
+      Assert.assertEquals(agent.toString(), UserAgent.getInstance(headerString).toString());
+    } else  {
+      Assert.assertEquals(agent, UserAgent.getInstance(headerString));
+    }
+  }
+
+  @Parameterized.Parameters
+  public static List<Object[]> data() {
+    return Arrays.asList(new Object[][]{
+
+        {"Internet Explorer 6 - Windows 2000",
+            UserAgent.MSIE_6_0,
+            "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0"},
+
+        {"Internet Explorer 6 - Windows XP",
+            UserAgent.MSIE_6_0,
+            "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'"},
+
+        {"Internet Explorer 7 - Windows XP",
+            UserAgent.MSIE_7_0,
+            "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"},
+
+        {"Internet Explorer 8 - Windows XP",
+            UserAgent.MSIE,
+            "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727;"
+                + " .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"},
+
+        {"Internet Explorer 8 - Compatibility Mode - Windows XP",
+            UserAgent.MSIE_7_0,
+            "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)"},
+
+        {"Internet Explorer 9 preview - Windows 7",
+            UserAgent.MSIE,
+            "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"},
+
+        {"Internet Explorer 9 - Windows 7",
+            UserAgent.MSIE,
+            "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)"},
+
+        {"Internet Explorer 9 - Compatibility Mode - Windows 7",
+            UserAgent.MSIE_7_0,
+            "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/5.0; "
+                + ".NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"},
+
+        {"Internet Explorer 10 - Windows 8 - Developer Preview",
+            UserAgent.MSIE,
+            "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"},
+
+        {"Internet Explorer 10 - Compatibility Mode - Windows 8 - Developer Preview",
+            UserAgent.MSIE_7_0,
+            "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C)"},
+
+        {"Internet Explorer 11 - Windows 7",
+            UserAgent.MOZILLA,
+            "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; "
+                + ".NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; "
+                + ".NET4.0C; .NET4.0E; rv:11.0) like Gecko"},
+
+        {"Firefox 3.6 - Ubuntu 10.4",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100308 Ubuntu/10.04 (lucid) Firefox/3.6"},
+
+        {"Firefox 3.6 - Ubuntu 9.10",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3pre) Gecko/20100328 Ubuntu/9.10 (karmic) "
+                + "Namoroka/3.6.3pre"},
+
+        {"Firefox 23.0 - Mac OS X Mountain Lion",
+            UserAgent.MOZILLA_5_0_FF_2,
+            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0"},
+
+        {"Firefox 5.0 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0"},
+
+        {"Firefox 4.0 beta 2 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b2) Gecko/20100720 Firefox/4.0b2"},
+
+        {"Firefox 3.6 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"},
+
+        {"Firefox 3.5 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9"},
+
+        {"Firefox 3.0 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.0.19) Gecko/2010031218 Firefox/3.0.19"},
+
+        {"Firefox 2.0 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0_FF_2,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20"},
+
+        {"Opera 10.61 - Windows 7",
+            UserAgent.OPERA,
+            "Opera/9.80 (Windows NT 6.1; U; de) Presto/2.6.30 Version/10.61"},
+
+        {"Opera 10.10 - Mac OS X Snow Leopard",
+            UserAgent.OPERA,
+            "Opera/9.80 (Macintosh; Intel Mac OS X; U; de) Presto/2.2.15 Version/10.10"},
+
+        {"Opera 10.51 - Ubuntu 9.10",
+            UserAgent.OPERA,
+            "Opera/9.80 (X11; Linux i686; U; en) Presto/2.5.22 Version/10.51"},
+
+        {"Chrome 4.1 - Windows 7",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko)"
+                + " Chrome/4.1.249.1042 Safari/532.5"},
+
+        {"Chrome 5 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko)"
+                + " Chrome/5.0.375.127 Safari/533.4"},
+
+        {"Chrome 5 - Ubuntu 9.10",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko)"
+                + " Chrome/5.0.360.0 Safari/533.3"},
+
+        {"Chromium 5 - Ubuntu 9.10",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko)"
+                + " Chrome/5.0.365.0 Safari/533.3"},
+
+        {"Safari 5 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; de-de) AppleWebKit/533.17.8 (KHTML, like Gecko) "
+                + "Version/5.0.1 Safari/533.17.8"},
+
+        {"Safari 4 - Mac OS X Snow Leopard",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-de) AppleWebKit/531.22.7 (KHTML, like Gecko) "
+                + "Version/4.0.5 Safari/531.22.7"},
+
+        {"Safari 4 - iPad",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; de-de) AppleWebKit/531.21.10 (KHTML, like Gecko) "
+                + "Version/4.0.4 Mobile/7B405 Safari/531.21.10"},
+
+        {"Web-Browser for S60 - Symbian - Nokia E51",
+            UserAgent.MOZILLA_5_0,
+            "Mozilla/5.0 "
+                + "(SymbianOS/9.2; U; Series60/3.1 NokiaE51-1/300.34.56; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) "
+                + "AppleWebKit/413 (KHTML, like Gecko) Safari/413"},
+    });
+  }
+}