In getting IE version, prefer Trident version over MSIE version. (#1726)
* In getting IE version, prefer Trident version over MSIE version. * In getting IE version, revert preferring Trident version and check on documentMode instead. * Added getieversion unit test.
This commit is contained in:
Родитель
7f88c46fc3
Коммит
8ad6d2ed65
|
@ -531,8 +531,8 @@ export class UtilTests extends AITestClass {
|
|||
}
|
||||
|
||||
Assert.equal(7, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"));
|
||||
Assert.equal(7, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0;)"));
|
||||
Assert.equal(7, Util.getIEVersion("Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; en-US)"));
|
||||
Assert.equal(7, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0;)"));
|
||||
Assert.equal(8, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)"));
|
||||
Assert.equal(8, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"));
|
||||
Assert.equal(8, Util.getIEVersion("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"));
|
||||
|
@ -546,7 +546,16 @@ export class UtilTests extends AITestClass {
|
|||
Assert.equal(11, Util.getIEVersion("Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"));
|
||||
Assert.equal(11, Util.getIEVersion("Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko"));
|
||||
Assert.equal(11, Util.getIEVersion("Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"));
|
||||
|
||||
const origDocMode = document['documentMode'];
|
||||
document['documentMode'] = 11;
|
||||
|
||||
Assert.equal(11, Util.getIEVersion("Mozilla/4.0 (Compatible; MSIE 8.0; Windows NT 5.2; Trident/6.0)"));
|
||||
Assert.equal(11, Util.getIEVersion("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E)"));
|
||||
|
||||
// restore documentMode
|
||||
document['documentMode'] = origDocMode;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ declare var XDomainRequest: any;
|
|||
|
||||
const strWindow = "window";
|
||||
const strDocument = "document";
|
||||
const strDocumentMode = "documentMode";
|
||||
const strNavigator = "navigator";
|
||||
const strHistory = "history";
|
||||
const strLocation = "location";
|
||||
|
@ -311,8 +312,10 @@ export function getIEVersion(userAgentStr: string = null): number {
|
|||
}
|
||||
|
||||
var ua = (userAgentStr || "").toLowerCase();
|
||||
// Also check for documentMode in case X-UA-Compatible meta tag was included in HTML.
|
||||
if (strContains(ua, strMsie)) {
|
||||
return parseInt(ua.split(strMsie)[1]);
|
||||
let doc = getDocument() || {} as Document;
|
||||
return Math.max(parseInt(ua.split(strMsie)[1]), (doc[strDocumentMode] || 0));
|
||||
} else if (strContains(ua, strTrident)) {
|
||||
let tridentVer = parseInt(ua.split(strTrident)[1]);
|
||||
if (tridentVer) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче