diff --git a/README.md b/README.md
index 8624280..11b8b18 100644
--- a/README.md
+++ b/README.md
@@ -27,18 +27,23 @@ Supported Browsers
- [x] ua.Android 6.x
- [x] ua.Android 7.0
- [x] ua.Android 7.1
+- [x] ua.Android 8.0
- [x] ua.iphone (IOS4)
- [x] ua.iphone (IOS5)
- [x] ua.iphone (IOS6)
- [x] ua.iphone (IOS7)
- [x] ua.iphone (IOS8)
- [x] ua.iphone (IOS9)
+- [x] ua.iphone (IOS10)
+- [x] ua.iphone (IOS11)
- [x] ua.iphone (IOS4-ipad)
- [x] ua.iphone (IOS5-ipad)
- [x] ua.iphone (IOS6-ipad)
- [x] ua.iphone (IOS7-ipad)
- [x] ua.iphone (IOS8-ipad)
- [x] ua.iphone (IOS9-ipad)
+- [x] ua.iphone (IOS10-ipad)
+- [x] ua.iphone (IOS11-ipad)
- [x] ua.iphone5 (hardware)
- [x] ua.blackberry
- [x] ua.webos
@@ -69,6 +74,23 @@ Supported Browsers
## Usage
+#### example iOS 11
+
+```
+
+
+
+```
+
+#### example detail view!
+
+
```
diff --git a/package.json b/package.json
index a70cc23..ee3d1c2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sua.js",
- "version": "2.1.0",
+ "version": "2.2.0",
"description": "Simple user agent detection library.",
"license": "MIT",
"keywords": [
diff --git a/sua.js b/sua.js
index b7f76cb..9800c98 100644
--- a/sua.js
+++ b/sua.js
@@ -75,12 +75,19 @@
*/
this.android6 = useragent.match(/(Android)\s+(6)([\d.]+)/),
/**
- * Decision: android6.x
+ * Decision: android7.x
* @name android
* @memberof ua
* @return {Array}
*/
this.android7 = useragent.match(/(Android)\s+(7)([\d.]+)/),
+ /**
+ * Decision: android8.x
+ * @name android
+ * @memberof ua
+ * @return {Array}
+ */
+ this.android8 = useragent.match(/(Android)\s+(8)([\d.]+)/),
/**
* Decision: ipad
* @name ipad
@@ -334,9 +341,9 @@
if (this.os.ios) {
var __ios_v_0 = null;
if (this.os.version) {
- __ios_v_0 = this.os.version.substring(0, 1);
+ __ios_v_0 = this.os.version.split('.')[0];
}
- for (var i = 3; i < 10; i++) { // IOS 3->9
+ for (var i = 3; i < 12; i++) { // IOS 3->9
/**
* Decision: ios 3-9
* @name ios3-9
@@ -469,7 +476,7 @@
}
}
- SUA.VERSION = '2.1.0';
+ SUA.VERSION = '2.2.0';
if (typeof module !== 'undefined' && module.exports) {
// node
diff --git a/sua.min.js b/sua.min.js
index 609be06..b238a46 100644
--- a/sua.min.js
+++ b/sua.min.js
@@ -1,6 +1,6 @@
/**
* @name sua.min.js
- * @version 2.1.0
+ * @version 2.2.0
* @overview Simple user agent detection library.
*/
-!function(i){"use strict";function s(s){if(!s&&i&&i.navigator&&i.navigator.userAgent&&(s=i.navigator.userAgent),!s)throw new Error("useragent setup error. useragent not found.");if(this.ie=!!(s.indexOf("MSIE")>=0||s.indexOf("Trident")>=0||s.indexOf("Edge")>=0),this.webkit=s.match(/(WebKit|Webkit)\/([\d.]+)/),this.android=s.match(/(Android)\s+([\d.]+)/),this.android23=s.match(/(Android)\s+(2\.3)([\d.]+)/),this.android4=s.match(/(Android)\s+(4)([\d.]+)/),this.android5=s.match(/(Android)\s+(5)([\d.]+)/),this.android6=s.match(/(Android)\s+(6)([\d.]+)/),this.android7=s.match(/(Android)\s+(7)([\d.]+)/),this.ipad=s.match(/(iPad).*OS\s([\d_]+)/),this.iphone=!this.ipad&&s.match(/(iPhone\sOS)\s([\d_]+)/),this.webos=s.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),this.touchpad=this.webos&&s.match(/TouchPad/),this.kindle=s.match(/(Kindle)/),this.silk=s.match(/(Silk)/),this.blackberry=s.match(/(BlackBerry).*/),this.bb10=s.match(/(BB10).*Version\/([\d.]+)/),this.rimtabletos=s.match(/(RIM\sTablet\sOS)\s([\d.]+)/),this.playbook=s.match(/PlayBook/),this.chrome=s.match(/Chrome\/([\d.]+)/)||s.match(/CriOS\/([\d.]+)/),this.firefox=s.match(/Firefox\/([\d.]+)/),this.wii=s.match(/Nintendo (Wii);/),this.wiiu=s.match(/Nintendo (WiiU)/),this.ds=s.match(/Nintendo (DS|3DS|DSi);/),this.nintendo_switch=s.match(/Nintendo (Switch);/),this.ps3=s.match(/PLAYSTATION 3/),this.psp=s.match(/(PlayStation Portable)/),this.psvita=s.match(/(PlayStation Vita)/),this.windowsphone=s.match(/(Windows Phone |Windows Phone OS )([\d.]+)/),this.safari=s.match(/(Version)\/([0-9\.]+).*Safari\/([0-9\.]+)/),this.trident=s.match(/Trident\/([\d\.]+)/),this.xbox=s.match(/Xbox/),this.iphone5=!("undefined"!=typeof module&&module.exports)&&this.iphone&&screen&&320===screen.width&&568===screen.height,this.vivaldi=s.match(/Vivaldi\/([\d.]+)/),this.iphone3=!(!this.iphone||1!==i.devicePixelRatio),this.browser={locale:void 0,lang:void 0,country:void 0},this.os={},this.webkit&&!this.ie&&(this.browser.webkit=!0,this.browser.version=this.webkit[1]),this.trident&&(this.browser.trident=!0,this.browser.version=this.trident[1]),this.android){this.os.android=!0,this.os.version=this.android[2];try{this.browser.locale=s.match(/(Android)\s(.+);\s([^;]+);/)[3],this.browser.lang=this.browser.locale.substring(0,2),this.browser.country=this.browser.locale.substring(3)}catch(i){}}if(this.iphone&&(this.os.ios=this.os.iphone=!0,this.os.version=this.iphone[2].replace(/_/g,".")),this.ipad&&(this.os.ios=this.os.ipad=!0,this.os.version=this.ipad[2].replace(/_/g,".")),this.os.ios){var t=null;this.os.version&&(t=this.os.version.substring(0,1));for(var h=3;h<10;h++)this["ios"+h]=t===""+h}this.webos&&(this.os.webos=!0,this.os.version=this.webos[2]),this.touchpad&&(this.os.touchpad=!0),this.blackberry&&(this.os.blackberry=!0),this.bb10&&(this.os.bb10=!0,this.os.version=this.bb10[2]),this.rimtabletos&&(this.os.rimtabletos=!0,this.os.version=this.rimtabletos[2]),this.playbook&&(this.browser.playbook=!0),this.kindle&&(this.os.kindle=!0),this.silk&&(this.browser.silk=!0),!this.silk&&this.os.android&&s.match(/Kindle Fire/)&&(this.browser.silk=!0),this.chrome&&!this.ie&&(this.browser.chrome=!0,this.browser.version=this.chrome[1]),this.firefox&&(this.browser.firefox=!0,this.browser.version=this.firefox[1],s.match(/Android/)&&(this.android=["Android","Android",""])),(this.wii||this.ds||this.wiiu||this.nintendo_switch)&&(this.os.nintendo=!0,(this.wiiu||this.nintendo_switch)&&(this.browser.nintendo=s.match(/NintendoBrowser\/([\d.]+)/),this.browser.version=this.browser.nintendo[1])),this.windowsphone&&(this.browser.windowsphone=!0,this.browser.version=this.windowsphone[2]),this.safari&&(this.browser.safari=!0,this.browser.version=this.safari[2]),this.ie&&(this.browser.ie=/(MSIE|rv:?)\s?([\d\.]+)/.exec(s),this.edge=!1,this.browser.ie?this.windowsphone||(this.browser.version=this.browser.ie?this.browser.ie[2]:""):(this.browser.ie=/(Edge\/)(\d.+)/.exec(s),this.browser.version=this.browser.ie[2],this.edge=!0,this.chrome=!1,this.webkit=!1),0=0||s.indexOf("Trident")>=0||s.indexOf("Edge")>=0),this.webkit=s.match(/(WebKit|Webkit)\/([\d.]+)/),this.android=s.match(/(Android)\s+([\d.]+)/),this.android23=s.match(/(Android)\s+(2\.3)([\d.]+)/),this.android4=s.match(/(Android)\s+(4)([\d.]+)/),this.android5=s.match(/(Android)\s+(5)([\d.]+)/),this.android6=s.match(/(Android)\s+(6)([\d.]+)/),this.android7=s.match(/(Android)\s+(7)([\d.]+)/),this.android8=s.match(/(Android)\s+(8)([\d.]+)/),this.ipad=s.match(/(iPad).*OS\s([\d_]+)/),this.iphone=!this.ipad&&s.match(/(iPhone\sOS)\s([\d_]+)/),this.webos=s.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),this.touchpad=this.webos&&s.match(/TouchPad/),this.kindle=s.match(/(Kindle)/),this.silk=s.match(/(Silk)/),this.blackberry=s.match(/(BlackBerry).*/),this.bb10=s.match(/(BB10).*Version\/([\d.]+)/),this.rimtabletos=s.match(/(RIM\sTablet\sOS)\s([\d.]+)/),this.playbook=s.match(/PlayBook/),this.chrome=s.match(/Chrome\/([\d.]+)/)||s.match(/CriOS\/([\d.]+)/),this.firefox=s.match(/Firefox\/([\d.]+)/),this.wii=s.match(/Nintendo (Wii);/),this.wiiu=s.match(/Nintendo (WiiU)/),this.ds=s.match(/Nintendo (DS|3DS|DSi);/),this.nintendo_switch=s.match(/Nintendo (Switch);/),this.ps3=s.match(/PLAYSTATION 3/),this.psp=s.match(/(PlayStation Portable)/),this.psvita=s.match(/(PlayStation Vita)/),this.windowsphone=s.match(/(Windows Phone |Windows Phone OS )([\d.]+)/),this.safari=s.match(/(Version)\/([0-9\.]+).*Safari\/([0-9\.]+)/),this.trident=s.match(/Trident\/([\d\.]+)/),this.xbox=s.match(/Xbox/),this.iphone5=!("undefined"!=typeof module&&module.exports)&&this.iphone&&screen&&320===screen.width&&568===screen.height,this.vivaldi=s.match(/Vivaldi\/([\d.]+)/),this.iphone3=!(!this.iphone||1!==i.devicePixelRatio),this.browser={locale:void 0,lang:void 0,country:void 0},this.os={},this.webkit&&!this.ie&&(this.browser.webkit=!0,this.browser.version=this.webkit[1]),this.trident&&(this.browser.trident=!0,this.browser.version=this.trident[1]),this.android){this.os.android=!0,this.os.version=this.android[2];try{this.browser.locale=s.match(/(Android)\s(.+);\s([^;]+);/)[3],this.browser.lang=this.browser.locale.substring(0,2),this.browser.country=this.browser.locale.substring(3)}catch(i){}}if(this.iphone&&(this.os.ios=this.os.iphone=!0,this.os.version=this.iphone[2].replace(/_/g,".")),this.ipad&&(this.os.ios=this.os.ipad=!0,this.os.version=this.ipad[2].replace(/_/g,".")),this.os.ios){var t=null;this.os.version&&(t=this.os.version.split(".")[0]);for(var h=3;h<12;h++)this["ios"+h]=t===""+h}this.webos&&(this.os.webos=!0,this.os.version=this.webos[2]),this.touchpad&&(this.os.touchpad=!0),this.blackberry&&(this.os.blackberry=!0),this.bb10&&(this.os.bb10=!0,this.os.version=this.bb10[2]),this.rimtabletos&&(this.os.rimtabletos=!0,this.os.version=this.rimtabletos[2]),this.playbook&&(this.browser.playbook=!0),this.kindle&&(this.os.kindle=!0),this.silk&&(this.browser.silk=!0),!this.silk&&this.os.android&&s.match(/Kindle Fire/)&&(this.browser.silk=!0),this.chrome&&!this.ie&&(this.browser.chrome=!0,this.browser.version=this.chrome[1]),this.firefox&&(this.browser.firefox=!0,this.browser.version=this.firefox[1],s.match(/Android/)&&(this.android=["Android","Android",""])),(this.wii||this.ds||this.wiiu||this.nintendo_switch)&&(this.os.nintendo=!0,(this.wiiu||this.nintendo_switch)&&(this.browser.nintendo=s.match(/NintendoBrowser\/([\d.]+)/),this.browser.version=this.browser.nintendo[1])),this.windowsphone&&(this.browser.windowsphone=!0,this.browser.version=this.windowsphone[2]),this.safari&&(this.browser.safari=!0,this.browser.version=this.safari[2]),this.ie&&(this.browser.ie=/(MSIE|rv:?)\s?([\d\.]+)/.exec(s),this.edge=!1,this.browser.ie?this.windowsphone||(this.browser.version=this.browser.ie?this.browser.ie[2]:""):(this.browser.ie=/(Edge\/)(\d.+)/.exec(s),this.browser.version=this.browser.ie[2],this.edge=!0,this.chrome=!1,this.webkit=!1),09
+ if (i == target) {
+ expect(sua['ios' + target]).be.ok;
+ } else {
+ expect(sua['ios' + i]).be.not.ok;
+ }
+ }
+ }
+
var useragents = {
"Android2.1": [
@@ -120,6 +132,10 @@
"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6P Build/N4F26J) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36",
"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 9 Build/N4F26M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Safari/537.36",
],
+ "Android8.0": [
+ 'Mozilla/5.0 (Linux; Android 8.0.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36',
+ 'Mozilla/5.0 (Linux; Android 8.0.0; Pixel Build/OPR3.170623.007) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36',
+ ],
"IOS4": [
'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7',
'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_2 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A400 Safari/6531.22.7',
@@ -155,6 +171,12 @@
"IOS9": [
'Mozilla /5.0 (iPhone; CPU iPhone OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A344 Safari/601.1',
],
+ "IOS10": [
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1'
+ ],
+ "IOS11": [
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
+ ],
"IOS4-ipad": [
'Mozilla/5.0 (iPad; U; CPU OS 4_2 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8C134',
'Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F190 Safari/6533.18.5',
@@ -187,6 +209,12 @@
"IOS9-ipad": [
'Mozilla/5.0 (iPad; CPU OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A344 Safari/601.1',
],
+ "IOS10-ipad": [
+ 'Mozilla/5.0 (iPad; CPU OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1'
+ ],
+ "IOS11-ipad": [
+ 'Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.25 (KHTML, like Gecko) Version/11.0 Mobile/15A5304j Safari/604.1',
+ ],
"BlackBerry": [
'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220',
'BlackBerry9300/5.0.0.1007 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/220',
@@ -508,6 +536,27 @@
expect(sua.os.version).be.ok;
});
});
+ it('ua.Android 8.0', function () {
+ useragents["Android8.0"].forEach(function (useragent, idx) {
+ var sua = new SUA(useragent);
+ expect(sua.android).be.ok;
+ expect(sua.android23).not.be.ok;
+ expect(sua.android4).not.be.ok;
+ expect(sua.android5).not.be.ok;
+ expect(sua.android6).not.be.ok;
+ expect(sua.android7).not.be.ok;
+ expect(sua.android8).be.ok;
+ expect(sua.webkit).be.ok;
+ expect(sua.browser.webkit).be.ok;
+ expect(sua.browser.version).be.ok;
+ if (!sua.chrome) {
+ expect(sua.browser.locale.length).equal(7).be.ok
+ }
+
+ expect(sua.os.android).be.ok;
+ expect(sua.os.version).be.ok;
+ });
+ });
it('ua.iphone (IOS4)', function () {
useragents["IOS4"].forEach(function (useragent, idx) {
var sua = new SUA(useragent);
@@ -521,13 +570,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 4) {
- expect(sua['ios4']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 4)
});
});
it('ua.iphone (IOS5)', function () {
@@ -543,13 +586,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 5) {
- expect(sua['ios5']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 5)
});
});
it('ua.iphone (IOS6)', function () {
@@ -565,13 +602,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 6) {
- expect(sua['ios6']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 6)
});
});
it('ua.iphone (IOS7)', function () {
@@ -587,13 +618,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 7) {
- expect(sua['ios7']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 7)
});
});
it('ua.iphone (IOS8)', function () {
@@ -609,13 +634,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 8) {
- expect(sua['ios8']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 8)
});
});
it('ua.iphone (IOS9)', function () {
@@ -631,13 +650,39 @@
expect(sua.os.version).be.ok;
expect(sua.os.table).not.be.ok;
expect(sua.os.phone).be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 9) {
- expect(sua['ios9']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 9)
+ });
+ });
+ it('ua.iphone (IOS10)', function () {
+ useragents["IOS10"].forEach(function (useragent, idx) {
+ var sua = new SUA(useragent);
+ expect(sua.iphone).be.ok;
+ expect(sua.webkit).be.ok;
+
+ expect(sua.browser.webkit).be.ok;
+ expect(sua.browser.version).be.ok;
+ expect(sua.os.iphone).be.ok;
+ expect(sua.os.ios).be.ok;
+ expect(sua.os.version).be.ok;
+ expect(sua.os.table).not.be.ok;
+ expect(sua.os.phone).be.ok;
+ iosVersionCheck(sua, 10)
+ });
+ });
+ it('ua.iphone (IOS11)', function () {
+ useragents["IOS11"].forEach(function (useragent, idx) {
+ var sua = new SUA(useragent);
+ expect(sua.iphone).be.ok;
+ expect(sua.webkit).be.ok;
+
+ expect(sua.browser.webkit).be.ok;
+ expect(sua.browser.version).be.ok;
+ expect(sua.os.iphone).be.ok;
+ expect(sua.os.ios).be.ok;
+ expect(sua.os.version).be.ok;
+ expect(sua.os.table).not.be.ok;
+ expect(sua.os.phone).be.ok;
+ iosVersionCheck(sua, 11)
});
});
it('ua.iphone (IOS4-ipad)', function () {
@@ -653,14 +698,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 4) {
- expect(sua['ios4']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
-
+ iosVersionCheck(sua, 4)
});
});
it('ua.iphone (IOS5-ipad)', function () {
@@ -675,13 +713,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 5) {
- expect(sua['ios5']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 5)
});
});
it('ua.iphone (IOS6-ipad)', function () {
@@ -696,13 +728,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 6) {
- expect(sua['ios6']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 6)
});
});
it('ua.iphone (IOS7-ipad)', function () {
@@ -717,13 +743,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 7) {
- expect(sua['ios7']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 7)
});
});
it('ua.iphone (IOS8-ipad)', function () {
@@ -738,13 +758,7 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 8) {
- expect(sua['ios8']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 8)
});
});
it('ua.iphone (IOS9-ipad)', function () {
@@ -759,13 +773,37 @@
expect(sua.os.version).be.ok;
expect(sua.os.tablet).be.ok;
expect(sua.os.phone).not.be.ok;
- for (var i = 3; i < 10; i++) { // IOS 3->9
- if (i == 9) {
- expect(sua['ios9']).be.ok;
- } else {
- expect(sua['ios' + i]).be.not.ok;
- }
- }
+ iosVersionCheck(sua, 9)
+ });
+ });
+ it('ua.iphone (IOS10-ipad)', function () {
+ useragents["IOS10-ipad"].forEach(function (useragent, idx) {
+ var sua = new SUA(useragent);
+ expect(sua.ipad).be.ok;
+
+ expect(sua.browser.webkit).be.ok;
+ expect(sua.browser.version).be.ok;
+ expect(sua.os.ipad).be.ok;
+ expect(sua.os.ios).be.ok;
+ expect(sua.os.version).be.ok;
+ expect(sua.os.tablet).be.ok;
+ expect(sua.os.phone).not.be.ok;
+ iosVersionCheck(sua, 10)
+ });
+ });
+ it('ua.iphone (IOS11-ipad)', function () {
+ useragents["IOS11-ipad"].forEach(function (useragent, idx) {
+ var sua = new SUA(useragent);
+ expect(sua.ipad).be.ok;
+
+ expect(sua.browser.webkit).be.ok;
+ expect(sua.browser.version).be.ok;
+ expect(sua.os.ipad).be.ok;
+ expect(sua.os.ios).be.ok;
+ expect(sua.os.version).be.ok;
+ expect(sua.os.tablet).be.ok;
+ expect(sua.os.phone).not.be.ok;
+ iosVersionCheck(sua, 11)
});
});
it('ua.iphone5 (hardware)', function () {