Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Add support for IE Mobile 11
Browse files Browse the repository at this point in the history
Closes #71
  • Loading branch information
bnjmnt4n committed Nov 21, 2014
1 parent fefd04f commit 296dd00
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 17 deletions.
49 changes: 34 additions & 15 deletions platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,12 @@

/* Detectable layout engines (order is important) */
var layout = getLayout([
'Trident',
{ 'label': 'WebKit', 'pattern': 'AppleWebKit' },
'iCab',
'Presto',
'NetFront',
'Tasman',
'Trident',
'KHTML',
'Gecko'
]);
Expand Down Expand Up @@ -384,6 +384,7 @@
'Chrome',
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
{ 'label': 'IE', 'pattern': 'IEMobile' },
{ 'label': 'IE', 'pattern': 'MSIE' },
'Safari'
]);
Expand All @@ -397,6 +398,7 @@
{ 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
{ 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
'Google TV',
'Lumia',
'iPad',
'iPod',
'iPhone',
Expand Down Expand Up @@ -430,13 +432,14 @@
'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
'Motorola': { 'Xoom': 1 },
'Nintendo': { 'Wii U': 1, 'Wii': 1 },
'Nokia': {},
'Nokia': { 'Lumia': 1 },
'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
'Sony': { 'PlayStation 4': 1, 'PlayStation 3': 1, 'PlayStation Vita': 1 }
});

/* Detectable OSes (order is important) */
var os = getOS([
'Windows Phone ',
'Android',
'CentOS',
'Debian',
Expand Down Expand Up @@ -644,11 +647,15 @@
if (!product) {
product = data[1];
}
}
// detect IE Mobile 11 which identifies as different browsers
else if (layout == 'Trident' && !/\bWindows\b/.test(os)) {

}
// detect non-Opera versions (order is important)
if (!version) {
version = getVersion([
'(?:Cloud9|CriOS|CrMo|Iron|Opera ?Mini|OPiOS|OPR|Raven|Silk(?!/[\\d.]+$))',
'(?:Cloud9|CriOS|CrMo|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|Silk(?!/[\\d.]+$))',
'Version',
qualify(name),
'(?:Firefox|Minefield|NetFront)'
Expand All @@ -657,23 +664,41 @@
// detect stubborn layout engines
if (layout == 'iCab' && parseFloat(version) > 3) {
layout = ['WebKit'];
} else if ((data =
} else if (
layout != 'Trident' &&
(data =
/\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
/\b(?:Midori|Nook|Safari)\b/i.test(ua) && 'WebKit' ||
!layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident')
)) {
)
) {
layout = [data];
}
// detect NetFront on PlayStation
else if (/\bPlayStation\b(?! Vita\b)/i.test(name) && layout == 'WebKit') {
layout = ['NetFront'];
}
// detect Windows Phone 7 desktop mode
if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
name += ' Mobile';
os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
description.unshift('desktop mode');
}
// detect Windows Phone 8+ desktop mode
else if (/\bWPDesktop\b/i.test(ua)) {
name = 'IE Mobile';
os = 'Windows Phone 8+';
description.unshift('desktop mode');
version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
}
// detect IE 11 and above
if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
if (name) {
description.push('identifying as ' + name + (version ? ' ' + version : ''));
else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
if (!/\bWPDesktop\b/i.test(ua)) {
if (name) {
description.push('identifying as ' + name + (version ? ' ' + version : ''));
}
name = 'IE';
}
name = 'IE';
version = data[1];
}
// leverage environment features
Expand Down Expand Up @@ -760,12 +785,6 @@
description.unshift('accelerated');
}
}
// detect Windows Phone desktop mode
else if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
name += ' Mobile';
os = 'Windows Phone ' + data + '.x';
description.unshift('desktop mode');
}
// detect Xbox 360 and Xbox One
else if (/\bXbox\b/i.test(product)) {
os = null;
Expand Down
62 changes: 60 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,18 +1195,76 @@
'version': '9.0'
},

'IE Mobile 10.0 on Nokia (Windows Phone 8.0)': {
'IE Mobile 10.0 on Nokia Lumia 920 (Windows Phone 8.0)': {
'ua': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)',
'external': null,
'layout': 'Trident',
'manufacturer': 'Nokia',
'mode': 10,
'name': 'IE Mobile',
'os': 'Windows Phone 8.0',
'product': 'Nokia',
'product': 'Lumia 920',
'version': '10.0'
},

'IE Mobile 10.0 (desktop mode) on Windows Phone 8+': {
'ua': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; ARM; Touch; WPDesktop)',
'external': null,
'layout': 'Trident',
'mode': 10,
'name': 'IE Mobile',
'os': 'Windows Phone 8+',
'version': '10.0'
},

'IE Mobile 11.0 on Nokia Lumia 920 (Windows Phone 8.1)': {
'ua': 'Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 920) like Gecko',
'external': null,
'layout': 'Trident',
'manufacturer': 'Nokia',
'mode': 11,
'name': 'IE Mobile',
'os': 'Windows Phone 8.1',
'product': 'Lumia 920',
'version': '11.0'
},

'IE Mobile 11.0 (desktop mode) on Nokia Lumia 920 (Windows Phone 8+)': {
'ua': 'Mozilla/5.0 (Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop; NOKIA; Lumia 920) like Gecko',
'external': null,
'layout': 'Trident',
'manufacturer': 'Nokia',
'mode': 11,
'name': 'IE Mobile',
'os': 'Windows Phone 8+',
'product': 'Lumia 920',
'version': '11.0'
},

'IE Mobile 11.0#{ }on Nokia Lumia 920 (Windows Phone 8.1)': {
'ua': 'Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 920) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537',
'external': null,
'layout': 'Trident',
'manufacturer': 'Nokia',
'mode': 11,
'name': 'IE Mobile',
'os': 'Windows Phone 8.1',
'product': 'Lumia 920',
'version': '11.0'
},

'IE Mobile 11.0#{ }(desktop mode) on Nokia Lumia 920 (Windows Phone 8+)': {
'ua': 'Mozilla/5.0 (Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop; Lumia 920) like Gecko',
'external': null,
'layout': 'Trident',
'manufacturer': 'Nokia',
'mode': 11,
'name': 'IE Mobile',
'os': 'Windows Phone 8+',
'product': 'Lumia 920',
'version': '11.0'
},

'SRWare Iron 0.2.152.0 on Windows Server 2008 / Vista': {
'ua': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Iron/0.2.152.0 Safari/41562480.525',
'layout': 'WebKit',
Expand Down

0 comments on commit 296dd00

Please sign in to comment.