diff options
-rw-r--r-- | client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java | 36 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/VBrowserDetails.java | 18 |
2 files changed, 46 insertions, 8 deletions
diff --git a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java index cef4f6a5d6..ee9d9d996c 100644 --- a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java +++ b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java @@ -24,6 +24,9 @@ public class VBrowserDetailsUserAgentParserTest { private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)"; private static final String IE11_WINDOWS_7 = "Mozilla/5.0 (Windows NT 6.1; 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; rv:11.0) like Gecko"; + private static final String IE11_WINDOWS_7_COMPATIBILITY_VIEW_IE7 = "Mozilla/4.0 (compatible; MSIE 7.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)"; + private static final String IE11_WINDOWS_10_COMPATIBILITY_VIEW_IE7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E)"; + private static final String IE11_INITIAL_WINDOWS_10_COMPATIBILITY_VIEW_IE7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/8.0; .NET4.0C; .NET4.0E)"; private static final String IE11_WINDOWS_PHONE_8_1_UPDATE = "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 920) Like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537"; // "Version/" was added in 10.00 @@ -345,6 +348,39 @@ public class VBrowserDetailsUserAgentParserTest { } @Test + public void testIE11Windows7CompatibilityViewIE7() { + VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7_COMPATIBILITY_VIEW_IE7); + assertTrident(bd); + assertEngineVersion(bd, 7); + assertIE(bd); + assertBrowserMajorVersion(bd, 11); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + @Test + public void testIE11Windows10CompatibilityViewIE7() { + VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_10_COMPATIBILITY_VIEW_IE7); + assertTrident(bd); + assertEngineVersion(bd, 7); + assertIE(bd); + assertBrowserMajorVersion(bd, 11); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + @Test + public void testIE11InitialWindows10CompatibilityViewIE7() { + VBrowserDetails bd = new VBrowserDetails(IE11_INITIAL_WINDOWS_10_COMPATIBILITY_VIEW_IE7); + assertTrident(bd); + assertEngineVersion(bd, 7); + assertIE(bd); + assertBrowserMajorVersion(bd, 11); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + @Test public void testIE11WindowsPhone81Update() { VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_PHONE_8_1_UPDATE); assertTrident(bd); diff --git a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java index 2b6018f314..99dac478bc 100644 --- a/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java +++ b/shared/src/main/java/com/vaadin/shared/VBrowserDetails.java @@ -120,13 +120,13 @@ public class VBrowserDetails implements Serializable { .substring(userAgent.indexOf("webkit/") + 7); tmp = tmp.replaceFirst("([0-9]+)[^0-9].+", "$1"); browserEngineVersion = Float.parseFloat(tmp); - } else if (isIE) { - int tridentPos = userAgent.indexOf("trident/"); - if (tridentPos >= 0) { - String tmp = userAgent - .substring(tridentPos + "Trident/".length()); - tmp = tmp.replaceFirst("([0-9]+\\.[0-9]+).*", "$1"); - browserEngineVersion = Float.parseFloat(tmp); + } else if (isTrident) { + String tmp = userAgent + .substring(userAgent.indexOf("trident/") + 8); + tmp = tmp.replaceFirst("([0-9]+\\.[0-9]+).*", "$1"); + browserEngineVersion = Float.parseFloat(tmp); + if (browserEngineVersion > 7) { + browserEngineVersion = 7; } } else if (isEdge) { browserEngineVersion = 0; @@ -148,6 +148,9 @@ public class VBrowserDetails implements Serializable { tmp = tmp.replaceFirst("(\\.[0-9]+).+", "$1"); parseVersionString(tmp); } + } else if (isTrident) { + // See https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#TriToken + setIEMode((int) browserEngineVersion + 4); } else { String ieVersionString = userAgent .substring(userAgent.indexOf("msie ") + 5); @@ -565,7 +568,6 @@ public class VBrowserDetails implements Serializable { * supported or might work */ public boolean isTooOldToFunctionProperly() { - // Check Trident version to detect compatibility mode if (isIE() && getBrowserMajorVersion() < 11) { return true; } |