aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDos Moonen <darsstar@gmail.com>2017-03-22 07:46:00 +0100
committerPekka Hyvönen <pekka@vaadin.com>2017-03-22 08:46:00 +0200
commitbaa0baf8d6f06dc234c610a0ed558cd66c6c67b4 (patch)
tree4109300dccb76c8d6023fef53ad1b1ddfb2ea528
parentec0b52a1b6c506a184121c303adb5e4e4711b8f3 (diff)
downloadvaadin-framework-baa0baf8d6f06dc234c610a0ed558cd66c6c67b4.tar.gz
vaadin-framework-baa0baf8d6f06dc234c610a0ed558cd66c6c67b4.zip
Check Trident version to detect compatibility mode (#8884)
IE11 in compatibility mode is actually not too old. It's just not recognized as IE11 if you leave the Trident version out of the equation. Checking the Trident version and using it to determine the actual IE version instead of trusting the possibly emulated MSIE version string.
-rw-r--r--client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java36
-rw-r--r--shared/src/main/java/com/vaadin/shared/VBrowserDetails.java18
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;
}