summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-10-11 12:06:38 +0000
committerVaadin Code Review <review@vaadin.com>2012-10-11 12:06:38 +0000
commita11134fc980892ace23b1a83358fb03419d427f7 (patch)
treee8a9e1a4e7df956218fd329905ba58d23a015baf
parent6f485e39df17aba6271956294ed6cc3e27337e92 (diff)
parent235c4cb98a16d2f60aeb8c49cd0c25b81371dd22 (diff)
downloadvaadin-framework-a11134fc980892ace23b1a83358fb03419d427f7.tar.gz
vaadin-framework-a11134fc980892ace23b1a83358fb03419d427f7.zip
Merge "Parse Trident versions to support IE in compatibility mode (#9887)"
-rw-r--r--client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java22
-rw-r--r--server/src/com/vaadin/server/BootstrapHandler.java9
-rw-r--r--shared/src/com/vaadin/shared/VBrowserDetails.java12
3 files changed, 30 insertions, 13 deletions
diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
index 70c1b130fd..b1d60f50b5 100644
--- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
+++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
@@ -22,7 +22,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
private static final String IE8_WINDOWS = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
private static final String IE8_IN_IE7_MODE_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
- private static final String IE9_BETA_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
+ private static final String IE9_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
@@ -279,7 +279,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE6() {
VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS);
- // assertTrident(bd);
+ assertEngineVersion(bd, -1);
assertIE(bd);
assertBrowserMajorVersion(bd, 6);
assertBrowserMinorVersion(bd, 0);
@@ -288,7 +288,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE7() {
VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS);
- // assertTrident(bd);
+ assertEngineVersion(bd, -1);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
assertBrowserMinorVersion(bd, 0);
@@ -297,7 +297,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE8() {
VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
- // assertTrident(bd);
+ assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
assertBrowserMinorVersion(bd, 0);
@@ -308,7 +308,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
bd.setIEMode(7);
- // assertTrident(bd);
+ assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
assertBrowserMinorVersion(bd, 0);
@@ -318,7 +318,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE9() {
VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
- // assertTrident(bd);
+ assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 9);
assertBrowserMinorVersion(bd, 0);
@@ -326,10 +326,10 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
}
public void testIE9InIE7CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE7_MODE_WINDOWS_7);
+ VBrowserDetails bd = new VBrowserDetails(IE9_IN_IE7_MODE_WINDOWS_7);
// bd.setIE8InCompatibilityMode();
- // assertTrident(bd);
+ assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
assertBrowserMinorVersion(bd, 0);
@@ -341,7 +341,11 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7);
// bd.setIE8InCompatibilityMode();
- // assertTrident(bd);
+ /*
+ * Trident/4.0 in example user agent string based on beta even though it
+ * should be Trident/5.0 in real (non-beta) user agent strings
+ */
+ assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
assertBrowserMinorVersion(bd, 0);
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index 9a0e4c2071..f4da147667 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -239,10 +239,13 @@ public abstract class BootstrapHandler implements RequestHandler {
head.appendElement("meta").attr("http-equiv", "Content-Type")
.attr("content", "text/html; charset=utf-8");
- // Chrome frame in all versions of IE (only if Chrome frame is
- // installed)
+ /*
+ * Enable Chrome Frame in all versions of IE if installed.
+ *
+ * Claim IE10 support to avoid using compatibility mode.
+ */
head.appendElement("meta").attr("http-equiv", "X-UA-Compatible")
- .attr("content", "chrome=1");
+ .attr("content", "IE=10;chrome=1");
String title = response.getUIProvider().getPageTitle(
new UICreateEvent(context.getRequest(), context.getUIClass()));
diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java
index 2143e884c0..46d29ac75c 100644
--- a/shared/src/com/vaadin/shared/VBrowserDetails.java
+++ b/shared/src/com/vaadin/shared/VBrowserDetails.java
@@ -95,6 +95,14 @@ 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);
+ }
}
} catch (Exception e) {
// Browser engine version parsing failed
@@ -456,7 +464,9 @@ public class VBrowserDetails implements Serializable {
* supported or might work
*/
public boolean isTooOldToFunctionProperly() {
- if (isIE() && getBrowserMajorVersion() < 8) {
+ // Check Trident version to detect compatibility mode
+ if (isIE() && getBrowserMajorVersion() < 8
+ && getBrowserEngineVersion() < 4) {
return true;
}
// Webkit 533 in Safari 4.1+, Android 2.2+, iOS 4+