private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
private static final String IE10_WINDOWS_8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
+ 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";
// "Version/" was added in 10.00
private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1";
public void testIE8() {
VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
bd.setIEMode(7);
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
public void testIE9() {
VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
+ assertTrident(bd);
assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 9);
VBrowserDetails bd = new VBrowserDetails(IE9_IN_IE7_MODE_WINDOWS_7);
// bd.setIE8InCompatibilityMode();
+ assertTrident(bd);
assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
* 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
*/
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
public void testIE10() {
VBrowserDetails bd = new VBrowserDetails(IE10_WINDOWS_8);
+ assertTrident(bd);
assertEngineVersion(bd, 6);
assertIE(bd);
assertBrowserMajorVersion(bd, 10);
assertWindows(bd);
}
+ public void testIE11() {
+ VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7);
+ assertTrident(bd);
+ assertEngineVersion(bd, 7);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 11);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
/*
* Helper methods below
*/
assertTrue(browserDetails.isGecko());
assertFalse(browserDetails.isWebKit());
assertFalse(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
}
private void assertPresto(VBrowserDetails browserDetails) {
assertFalse(browserDetails.isGecko());
assertFalse(browserDetails.isWebKit());
assertTrue(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
+ }
+
+ private void assertTrident(VBrowserDetails browserDetails) {
+ // Engine
+ assertFalse(browserDetails.isGecko());
+ assertFalse(browserDetails.isWebKit());
+ assertFalse(browserDetails.isPresto());
+ assertTrue(browserDetails.isTrident());
}
private void assertWebKit(VBrowserDetails browserDetails) {
assertFalse(browserDetails.isGecko());
assertTrue(browserDetails.isWebKit());
assertFalse(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
}
private void assertFirefox(VBrowserDetails browserDetails) {
private boolean isGecko = false;
private boolean isWebKit = false;
private boolean isPresto = false;
+ private boolean isTrident = false;
private boolean isChromeFrameCapable = false;
private boolean isChromeFrame = false;
// browser engine name
isGecko = userAgent.indexOf("gecko") != -1
- && userAgent.indexOf("webkit") == -1;
+ && userAgent.indexOf("webkit") == -1
+ && userAgent.indexOf("trident/") == -1;
isWebKit = userAgent.indexOf("applewebkit") != -1;
isPresto = userAgent.indexOf(" presto/") != -1;
+ isTrident = userAgent.indexOf("trident/") != -1;
// browser name
isChrome = userAgent.indexOf(" chrome/") != -1;
isOpera = userAgent.indexOf("opera") != -1;
isIE = userAgent.indexOf("msie") != -1 && !isOpera
&& (userAgent.indexOf("webtv") == -1);
+ // IE 11 no longer contains MSIE in the user agent
+ isIE = isIE || isTrident;
+
isFirefox = userAgent.indexOf(" firefox/") != -1;
// chromeframe
// Browser version
try {
if (isIE) {
- String ieVersionString = userAgent.substring(userAgent
- .indexOf("msie ") + 5);
- ieVersionString = safeSubstring(ieVersionString, 0,
- ieVersionString.indexOf(";"));
- parseVersionString(ieVersionString);
+ if (userAgent.indexOf("msie") == -1) {
+ // IE 11+
+ int rvPos = userAgent.indexOf("rv:");
+ if (rvPos >= 0) {
+ String tmp = userAgent.substring(rvPos + 3);
+ tmp = tmp.replaceFirst("(\\.[0-9]+).+", "$1");
+ parseVersionString(tmp);
+ }
+ } else {
+ String ieVersionString = userAgent.substring(userAgent
+ .indexOf("msie ") + 5);
+ ieVersionString = safeSubstring(ieVersionString, 0,
+ ieVersionString.indexOf(";"));
+ parseVersionString(ieVersionString);
+ }
} else if (isFirefox) {
int i = userAgent.indexOf(" firefox/") + 9;
parseVersionString(safeSubstring(userAgent, i, i + 5));
return isPresto;
}
+ /**
+ * Tests if the browser is using the Trident engine
+ *
+ * @since 7.1.7
+ * @return true if it is Trident, false otherwise
+ */
+ public boolean isTrident() {
+ return isTrident;
+ }
+
/**
* Tests if the browser is Safari.
*