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:
Chuck Feltner 2021-12-09 18:38:54 -06:00 коммит произвёл GitHub
Родитель 7f88c46fc3
Коммит 8ad6d2ed65
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -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) {