aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/BrowserInfo.java16
-rw-r--r--client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java25
-rw-r--r--server/src/com/vaadin/server/WebBrowser.java14
-rw-r--r--shared/src/com/vaadin/shared/VBrowserDetails.java25
4 files changed, 80 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java
index 8b274623c1..8dcefddcf5 100644
--- a/client/src/com/vaadin/client/BrowserInfo.java
+++ b/client/src/com/vaadin/client/BrowserInfo.java
@@ -30,6 +30,7 @@ public class BrowserInfo {
private static final String BROWSER_OPERA = "op";
private static final String BROWSER_IE = "ie";
+ private static final String BROWSER_EDGE = "edge";
private static final String BROWSER_FIREFOX = "ff";
private static final String BROWSER_SAFARI = "sa";
@@ -171,6 +172,13 @@ public class BrowserInfo {
minorVersionClass = majorVersionClass
+ browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_TRIDENT;
+ } else if (browserDetails.isEdge()) {
+ browserIdentifier = BROWSER_EDGE;
+ majorVersionClass = browserIdentifier
+ + getBrowserMajorVersion();
+ minorVersionClass = majorVersionClass
+ + browserDetails.getBrowserMinorVersion();
+ browserEngineClass = "";
} else if (browserDetails.isOpera()) {
browserIdentifier = BROWSER_OPERA;
majorVersionClass = browserIdentifier
@@ -225,6 +233,10 @@ public class BrowserInfo {
return browserDetails.isIE();
}
+ public boolean isEdge() {
+ return browserDetails.isEdge();
+ }
+
public boolean isFirefox() {
return browserDetails.isFirefox();
}
@@ -245,6 +257,10 @@ public class BrowserInfo {
return isIE() && getBrowserMajorVersion() == 10;
}
+ public boolean isIE11() {
+ return isIE() && getBrowserMajorVersion() == 11;
+ }
+
public boolean isChrome() {
return browserDetails.isChrome();
}
diff --git a/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
index 62b727e5f5..24bf9b6558 100644
--- a/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
+++ b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
@@ -56,6 +56,8 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
private static final String ANDROID_MOTOROLA_3_0 = "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";
private static final String ANDROID_GALAXY_NEXUS_4_0_4_CHROME = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
+ private static final String EDGE_WINDOWS_10 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240";
+
public void testSafari3() {
VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS);
assertWebKit(bd);
@@ -423,6 +425,14 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertWindows(bd, true);
}
+ public void testEdgeWindows10() {
+ VBrowserDetails bd = new VBrowserDetails(EDGE_WINDOWS_10);
+ assertEdge(bd);
+ assertBrowserMajorVersion(bd, 12);
+ assertBrowserMinorVersion(bd, 10240);
+ assertWindows(bd, false);
+ }
+
/*
* Helper methods below
*/
@@ -484,6 +494,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertFalse(browserDetails.isIE());
assertFalse(browserDetails.isOpera());
assertFalse(browserDetails.isSafari());
+ assertFalse(browserDetails.isEdge());
}
private void assertChrome(VBrowserDetails browserDetails) {
@@ -493,6 +504,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertFalse(browserDetails.isIE());
assertFalse(browserDetails.isOpera());
assertFalse(browserDetails.isSafari());
+ assertFalse(browserDetails.isEdge());
}
private void assertIE(VBrowserDetails browserDetails) {
@@ -502,6 +514,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertTrue(browserDetails.isIE());
assertFalse(browserDetails.isOpera());
assertFalse(browserDetails.isSafari());
+ assertFalse(browserDetails.isEdge());
}
private void assertOpera(VBrowserDetails browserDetails) {
@@ -511,6 +524,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertFalse(browserDetails.isIE());
assertTrue(browserDetails.isOpera());
assertFalse(browserDetails.isSafari());
+ assertFalse(browserDetails.isEdge());
}
private void assertSafari(VBrowserDetails browserDetails) {
@@ -520,6 +534,17 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase {
assertFalse(browserDetails.isIE());
assertFalse(browserDetails.isOpera());
assertTrue(browserDetails.isSafari());
+ assertFalse(browserDetails.isEdge());
+ }
+
+ private void assertEdge(VBrowserDetails browserDetails) {
+ // Browser
+ assertFalse(browserDetails.isFirefox());
+ assertFalse(browserDetails.isChrome());
+ assertFalse(browserDetails.isIE());
+ assertFalse(browserDetails.isOpera());
+ assertFalse(browserDetails.isSafari());
+ assertTrue(browserDetails.isEdge());
}
private void assertMacOSX(VBrowserDetails browserDetails) {
diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java
index 66018b02f2..9bf30cb3db 100644
--- a/server/src/com/vaadin/server/WebBrowser.java
+++ b/server/src/com/vaadin/server/WebBrowser.java
@@ -126,6 +126,20 @@ public class WebBrowser implements Serializable {
}
/**
+ * Tests whether the user is using Edge.
+ *
+ * @return true if the user is using Edge, false if the user is not using
+ * Edge or if no information on the browser is present
+ */
+ public boolean isEdge() {
+ if (browserDetails == null) {
+ return false;
+ }
+
+ return browserDetails.isEdge();
+ }
+
+ /**
* Tests whether the user is using Safari.
*
* @return true if the user is using Safari, false if the user is not using
diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java
index 561b6c76d0..d0de8ffb9f 100644
--- a/shared/src/com/vaadin/shared/VBrowserDetails.java
+++ b/shared/src/com/vaadin/shared/VBrowserDetails.java
@@ -41,6 +41,7 @@ public class VBrowserDetails implements Serializable {
private boolean isFirefox = false;
private boolean isOpera = false;
private boolean isIE = false;
+ private boolean isEdge = false;
private boolean isPhantomJS = false;
private boolean isWindowsPhone;
@@ -88,6 +89,16 @@ public class VBrowserDetails implements Serializable {
isSafari = !isChrome && !isIE && userAgent.indexOf("safari") != -1;
isFirefox = userAgent.indexOf(" firefox/") != -1;
isPhantomJS = userAgent.indexOf("phantomjs/") != -1;
+ if (userAgent.indexOf(" edge/") != -1) {
+ isEdge = true;
+ isChrome = false;
+ isOpera = false;
+ isIE = false;
+ isSafari = false;
+ isFirefox = false;
+ isWebKit = false;
+ isGecko = false;
+ }
// chromeframe
isChromeFrameCapable = userAgent.indexOf("chromeframe") != -1;
@@ -115,6 +126,8 @@ public class VBrowserDetails implements Serializable {
tmp = tmp.replaceFirst("([0-9]+\\.[0-9]+).*", "$1");
browserEngineVersion = Float.parseFloat(tmp);
}
+ } else if (isEdge) {
+ browserEngineVersion = 0;
}
} catch (Exception e) {
// Browser engine version parsing failed
@@ -158,6 +171,9 @@ public class VBrowserDetails implements Serializable {
i = userAgent.indexOf("opera/") + 6;
}
parseVersionString(safeSubstring(userAgent, i, i + 5));
+ } else if (isEdge) {
+ int i = userAgent.indexOf(" edge/") + 6;
+ parseVersionString(safeSubstring(userAgent, i, i + 8));
}
} catch (Exception e) {
// Browser version parsing failed
@@ -373,6 +389,15 @@ public class VBrowserDetails implements Serializable {
}
/**
+ * Tests if the browser is Edge.
+ *
+ * @return true if it is Edge, false otherwise
+ */
+ public boolean isEdge() {
+ return isEdge;
+ }
+
+ /**
* Tests if the browser is PhantomJS.
*
* @return true if it is PhantomJS, false otherwise