mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge branch 'origin/stable' into make-testable-and-add-tests
This commit is contained in:
commit
981354333e
@ -66,7 +66,10 @@ else {
|
|||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Simply `$ npm install` and `$ make` inside the bowser folder.
|
If you'd like to contribute a change to bowser, modify the files in src/, then run the following (you'll need node + npm installed):
|
||||||
|
|
||||||
|
$ npm install
|
||||||
|
$ make
|
||||||
|
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
@ -76,4 +79,4 @@ We started a list `src/useragents.js` with example user agents and their expecte
|
|||||||
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
|
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
|
||||||
check if all tests are still passing.
|
check if all tests are still passing.
|
||||||
|
|
||||||
To run the test call `$ make test` and hope for green light ;)
|
To run the test call `$ make test`
|
||||||
|
42
bowser.js
42
bowser.js
@ -5,8 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
!function (name, definition) {
|
!function (name, definition) {
|
||||||
if (typeof define == 'function') define(definition)
|
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
||||||
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
else if (typeof define == 'function') define(definition)
|
||||||
else this[name] = definition()
|
else this[name] = definition()
|
||||||
}('bowser', function () {
|
}('bowser', function () {
|
||||||
/**
|
/**
|
||||||
@ -19,9 +19,11 @@
|
|||||||
* Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
|
* Firefox: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0"
|
||||||
* iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
|
* iPhone: "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
|
||||||
* iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
|
* iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
|
||||||
|
* iPod: "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5"
|
||||||
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
||||||
* Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
|
* Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
|
||||||
* PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34"
|
* PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34"
|
||||||
|
* Amazon Silk: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.153_10033210) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ua = navigator.userAgent
|
var ua = navigator.userAgent
|
||||||
@ -29,10 +31,12 @@
|
|||||||
, ie = /(msie|trident)/i.test(ua)
|
, ie = /(msie|trident)/i.test(ua)
|
||||||
, chrome = /chrome|crios/i.test(ua)
|
, chrome = /chrome|crios/i.test(ua)
|
||||||
, phantom = /phantom/i.test(ua)
|
, phantom = /phantom/i.test(ua)
|
||||||
, safari = /safari/i.test(ua) && !chrome && !phantom
|
|
||||||
, iphone = /iphone/i.test(ua)
|
, iphone = /iphone/i.test(ua)
|
||||||
, ipad = /ipad/i.test(ua)
|
, ipad = /ipad/i.test(ua)
|
||||||
|
, ipod = /ipod/i.test(ua)
|
||||||
, touchpad = /touchpad/i.test(ua)
|
, touchpad = /touchpad/i.test(ua)
|
||||||
|
, silk = /silk/i.test(ua)
|
||||||
|
, safari = /safari/i.test(ua) && !chrome && !phantom && !silk
|
||||||
, android = /android/i.test(ua)
|
, android = /android/i.test(ua)
|
||||||
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
||||||
, firefox = /firefox/i.test(ua)
|
, firefox = /firefox/i.test(ua)
|
||||||
@ -40,6 +44,7 @@
|
|||||||
, seamonkey = /seamonkey\//i.test(ua)
|
, seamonkey = /seamonkey\//i.test(ua)
|
||||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||||
, firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
|
, firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
|
||||||
|
, mobile = /mobile/i.test(ua)
|
||||||
, o
|
, o
|
||||||
|
|
||||||
function detect() {
|
function detect() {
|
||||||
@ -59,6 +64,10 @@
|
|||||||
, webkit: t
|
, webkit: t
|
||||||
, chrome: t
|
, chrome: t
|
||||||
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
|
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
|
||||||
|
, ipad: ipad
|
||||||
|
, iphone: iphone
|
||||||
|
, ios: !!ua.match(/crios/i)
|
||||||
|
, mobile: mobile
|
||||||
}
|
}
|
||||||
if (phantom) return {
|
if (phantom) return {
|
||||||
name: 'PhantomJS'
|
name: 'PhantomJS'
|
||||||
@ -72,14 +81,23 @@
|
|||||||
, touchpad: t
|
, touchpad: t
|
||||||
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
|
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
|
||||||
}
|
}
|
||||||
if (iphone || ipad) {
|
|
||||||
o = {
|
if (silk) return {
|
||||||
name : iphone ? 'iPhone' : 'iPad'
|
name: 'Amazon Silk'
|
||||||
, webkit: t
|
, webkit: t
|
||||||
|
, android: t
|
||||||
, mobile: t
|
, mobile: t
|
||||||
|
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
|
||||||
|
}
|
||||||
|
if (iphone || ipad || ipod) {
|
||||||
|
o = {
|
||||||
|
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
|
||||||
|
, webkit: t
|
||||||
|
, mobile: iphone
|
||||||
, ios: t
|
, ios: t
|
||||||
, iphone: iphone
|
, iphone: iphone
|
||||||
, ipad: ipad
|
, ipad: ipad
|
||||||
|
, ipod: ipod
|
||||||
}
|
}
|
||||||
// WTF: version is not part of user agent in web apps
|
// WTF: version is not part of user agent in web apps
|
||||||
if (webkitVersion.test(ua)) {
|
if (webkitVersion.test(ua)) {
|
||||||
@ -125,17 +143,17 @@
|
|||||||
|
|
||||||
// Graded Browser Support
|
// Graded Browser Support
|
||||||
// http://developer.yahoo.com/yui/articles/gbs
|
// http://developer.yahoo.com/yui/articles/gbs
|
||||||
if ((bowser.msie && bowser.version >= 8) ||
|
if ((bowser.msie && bowser.version >= 9) ||
|
||||||
(bowser.chrome && bowser.version >= 10) ||
|
(bowser.chrome && bowser.version >= 20) ||
|
||||||
(bowser.firefox && bowser.version >= 4.0) ||
|
(bowser.firefox && bowser.version >= 10.0) ||
|
||||||
(bowser.safari && bowser.version >= 5) ||
|
(bowser.safari && bowser.version >= 5) ||
|
||||||
(bowser.opera && bowser.version >= 10.0)) {
|
(bowser.opera && bowser.version >= 10.0)) {
|
||||||
bowser.a = t;
|
bowser.a = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((bowser.msie && bowser.version < 8) ||
|
else if ((bowser.msie && bowser.version < 9) ||
|
||||||
(bowser.chrome && bowser.version < 10) ||
|
(bowser.chrome && bowser.version < 20) ||
|
||||||
(bowser.firefox && bowser.version < 4.0) ||
|
(bowser.firefox && bowser.version < 10.0) ||
|
||||||
(bowser.safari && bowser.version < 5) ||
|
(bowser.safari && bowser.version < 5) ||
|
||||||
(bowser.opera && bowser.version < 10.0)) {
|
(bowser.opera && bowser.version < 10.0)) {
|
||||||
bowser.c = t
|
bowser.c = t
|
||||||
|
2
bowser.min.js
vendored
2
bowser.min.js
vendored
@ -3,4 +3,4 @@
|
|||||||
* https://github.com/ded/bowser
|
* https://github.com/ded/bowser
|
||||||
* MIT License | (c) Dustin Diaz 2013
|
* MIT License | (c) Dustin Diaz 2013
|
||||||
*/
|
*/
|
||||||
!function(e,t){typeof define=="function"?define(t):typeof module!="undefined"&&module.exports?module.exports.browser=t():this[e]=t()}("bowser",function(){function g(){return n?{name:"Internet Explorer",msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:l?{name:"Opera",opera:t,version:e.match(d)?e.match(d)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{name:"Chrome",webkit:t,chrome:t,version:e.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]}:i?{name:"PhantomJS",webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{name:"TouchPad",webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:o||u?(m={name:o?"iPhone":"iPad",webkit:t,mobile:t,ios:t,iphone:o,ipad:u},d.test(e)&&(m.version=e.match(d)[1]),m):f?{name:"Android",webkit:t,android:t,mobile:t,version:(e.match(d)||e.match(v))[1]}:s?{name:"Safari",webkit:t,safari:t,version:e.match(d)[1]}:h?(m={name:"Gecko",gecko:t,mozilla:t,version:e.match(v)[1]},c&&(m.name="Firefox",m.firefox=t),m):p?{name:"SeaMonkey",seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome|crios/i.test(e),i=/phantom/i.test(e),s=/safari/i.test(e)&&!r&&!i,o=/iphone/i.test(e),u=/ipad/i.test(e),a=/touchpad/i.test(e),f=/android/i.test(e),l=/opera/i.test(e)||/opr/i.test(e),c=/firefox/i.test(e),h=/gecko\//i.test(e),p=/seamonkey\//i.test(e),d=/version\/(\d+(\.\d+)?)/i,v=/firefox\/(\d+(\.\d+)?)/i,m,y=g();return y.msie&&y.version>=8||y.chrome&&y.version>=10||y.firefox&&y.version>=4||y.safari&&y.version>=5||y.opera&&y.version>=10?y.a=t:y.msie&&y.version<8||y.chrome&&y.version<10||y.firefox&&y.version<4||y.safari&&y.version<5||y.opera&&y.version<10?y.c=t:y.x=t,y})
|
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function w(){return n?{name:"Internet Explorer",msie:t,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:h?{name:"Opera",opera:t,version:e.match(m)?e.match(m)[1]:e.match(/opr\/(\d+(\.\d+)?)/i)[1]}:r?{name:"Chrome",webkit:t,chrome:t,version:e.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1],ipad:o,iphone:s,ios:!!e.match(/crios/i),mobile:y}:i?{name:"PhantomJS",webkit:t,phantom:t,version:e.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]}:a?{name:"TouchPad",webkit:t,touchpad:t,version:e.match(/touchpad\/(\d+(\.\d+)?)/i)[1]}:f?{name:"Amazon Silk",webkit:t,android:t,mobile:t,version:e.match(/silk\/(\d+(\.\d+)?)/i)[1]}:s||o||u?(b={name:s?"iPhone":o?"iPad":"iPod",webkit:t,mobile:s,ios:t,iphone:s,ipad:o,ipod:u},m.test(e)&&(b.version=e.match(m)[1]),b):c?{name:"Android",webkit:t,android:t,mobile:t,version:(e.match(m)||e.match(g))[1]}:l?{name:"Safari",webkit:t,safari:t,version:e.match(m)[1]}:d?(b={name:"Gecko",gecko:t,mozilla:t,version:e.match(g)[1]},p&&(b.name="Firefox",b.firefox=t),b):v?{name:"SeaMonkey",seamonkey:t,version:e.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}:{}}var e=navigator.userAgent,t=!0,n=/(msie|trident)/i.test(e),r=/chrome|crios/i.test(e),i=/phantom/i.test(e),s=/iphone/i.test(e),o=/ipad/i.test(e),u=/ipod/i.test(e),a=/touchpad/i.test(e),f=/silk/i.test(e),l=/safari/i.test(e)&&!r&&!i&&!f,c=/android/i.test(e),h=/opera/i.test(e)||/opr/i.test(e),p=/firefox/i.test(e),d=/gecko\//i.test(e),v=/seamonkey\//i.test(e),m=/version\/(\d+(\.\d+)?)/i,g=/firefox\/(\d+(\.\d+)?)/i,y=/mobile/i.test(e),b,E=w();return E.msie&&E.version>=9||E.chrome&&E.version>=20||E.firefox&&E.version>=10||E.safari&&E.version>=5||E.opera&&E.version>=10?E.a=t:E.msie&&E.version<9||E.chrome&&E.version<20||E.firefox&&E.version<10||E.safari&&E.version<5||E.opera&&E.version<10?E.c=t:E.x=t,E})
|
29
package.json
29
package.json
@ -1,16 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "bowser"
|
"name": "bowser",
|
||||||
, "description": "a browser detector"
|
"description": "a browser detector",
|
||||||
, "keywords": ["ender", "browser", "sniff", "detection"]
|
"keywords": [
|
||||||
, "version": "0.3.4"
|
"ender",
|
||||||
, "homepage": "https://github.com/ded/bowser"
|
"browser",
|
||||||
, "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)"
|
"sniff",
|
||||||
, "main": "./bowser.js"
|
"detection"
|
||||||
, "repository": {
|
],
|
||||||
"type": "git"
|
"version": "0.3.9",
|
||||||
, "url": "https://github.com/ded/bowser.git"
|
"homepage": "https://github.com/ded/bowser",
|
||||||
}
|
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
||||||
, "devDependencies": {
|
"main": "./bowser.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/ded/bowser.git"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
"smoosh": "*"
|
"smoosh": "*"
|
||||||
, "mocha": "*"
|
, "mocha": "*"
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
!function (name, definition) {
|
!function (name, definition) {
|
||||||
if (typeof define == 'function') define(definition)
|
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
||||||
else if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
else if (typeof define == 'function') define(definition)
|
||||||
else this[name] = definition()
|
else this[name] = definition()
|
||||||
}('bowser', function () {
|
}('bowser', function () {
|
||||||
/**
|
/**
|
||||||
@ -15,17 +15,21 @@
|
|||||||
var ie = /(msie|trident)/i.test(ua)
|
var ie = /(msie|trident)/i.test(ua)
|
||||||
, chrome = /chrome|crios/i.test(ua)
|
, chrome = /chrome|crios/i.test(ua)
|
||||||
, phantom = /phantom/i.test(ua)
|
, phantom = /phantom/i.test(ua)
|
||||||
, safari = /safari/i.test(ua) && !chrome && !phantom
|
|
||||||
, iphone = /iphone/i.test(ua)
|
, iphone = /iphone/i.test(ua)
|
||||||
, ipad = /ipad/i.test(ua)
|
, ipad = /ipad/i.test(ua)
|
||||||
|
, ipod = /ipod/i.test(ua)
|
||||||
, touchpad = /touchpad/i.test(ua)
|
, touchpad = /touchpad/i.test(ua)
|
||||||
|
, silk = /silk/i.test(ua)
|
||||||
|
, safari = /safari/i.test(ua) && !chrome && !phantom && !silk
|
||||||
, android = /android/i.test(ua)
|
, android = /android/i.test(ua)
|
||||||
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
||||||
, firefox = /firefox/i.test(ua)
|
, firefox = /firefox/i.test(ua)
|
||||||
, gecko = /gecko\//i.test(ua)
|
, gecko = /gecko\//i.test(ua)
|
||||||
, seamonkey = /seamonkey\//i.test(ua)
|
, seamonkey = /seamonkey\//i.test(ua)
|
||||||
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
||||||
|
// , firefoxVersion = /firefox\/(\d+(\.\d+)?)/i
|
||||||
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
|
, firefoxVersion = /firefox[ \/](\d+(\.\d+)?)/i
|
||||||
|
, mobile = /mobile/i.test(ua)
|
||||||
, o = {}
|
, o = {}
|
||||||
|
|
||||||
if (opera) {
|
if (opera) {
|
||||||
@ -48,6 +52,10 @@
|
|||||||
, webkit: t
|
, webkit: t
|
||||||
, chrome: t
|
, chrome: t
|
||||||
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
|
, version: ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]
|
||||||
|
, ipad: ipad
|
||||||
|
, iphone: iphone
|
||||||
|
, ios: !!ua.match(/crios/i)
|
||||||
|
, mobile: mobile
|
||||||
}
|
}
|
||||||
else if (phantom) o = {
|
else if (phantom) o = {
|
||||||
name: 'PhantomJS'
|
name: 'PhantomJS'
|
||||||
@ -61,14 +69,22 @@
|
|||||||
, touchpad: t
|
, touchpad: t
|
||||||
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
|
, version : ua.match(/touchpad\/(\d+(\.\d+)?)/i)[1]
|
||||||
}
|
}
|
||||||
else if (iphone || ipad) {
|
else if (silk) o = {
|
||||||
o = {
|
name: 'Amazon Silk'
|
||||||
name : iphone ? 'iPhone' : 'iPad'
|
|
||||||
, webkit: t
|
, webkit: t
|
||||||
|
, android: t
|
||||||
, mobile: t
|
, mobile: t
|
||||||
|
, version : ua.match(/silk\/(\d+(\.\d+)?)/i)[1]
|
||||||
|
}
|
||||||
|
else if (iphone || ipad || ipod) {
|
||||||
|
o = {
|
||||||
|
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
|
||||||
|
, webkit: t
|
||||||
|
, mobile: iphone
|
||||||
, ios: t
|
, ios: t
|
||||||
, iphone: iphone
|
, iphone: iphone
|
||||||
, ipad: ipad
|
, ipad: ipad
|
||||||
|
, ipod: ipod
|
||||||
}
|
}
|
||||||
// WTF: version is not part of user agent in web apps
|
// WTF: version is not part of user agent in web apps
|
||||||
if (webkitVersion.test(ua)) {
|
if (webkitVersion.test(ua)) {
|
||||||
@ -108,17 +124,17 @@
|
|||||||
|
|
||||||
// Graded Browser Support
|
// Graded Browser Support
|
||||||
// http://developer.yahoo.com/yui/articles/gbs
|
// http://developer.yahoo.com/yui/articles/gbs
|
||||||
if ((o.msie && o.version >= 8) ||
|
if ((o.msie && o.version >= 9) ||
|
||||||
(o.chrome && o.version >= 10) ||
|
(o.chrome && o.version >= 20) ||
|
||||||
(o.firefox && o.version >= 4.0) ||
|
(o.firefox && o.version >= 10.0) ||
|
||||||
(o.safari && o.version >= 5) ||
|
(o.safari && o.version >= 5) ||
|
||||||
(o.opera && o.version >= 10.0)) {
|
(o.opera && o.version >= 10.0)) {
|
||||||
o.a = t;
|
o.a = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((o.msie && o.version < 8) ||
|
else if ((o.msie && o.version < 9) ||
|
||||||
(o.chrome && o.version < 10) ||
|
(o.chrome && o.version < 20) ||
|
||||||
(o.firefox && o.version < 4.0) ||
|
(o.firefox && o.version < 10.0) ||
|
||||||
(o.safari && o.version < 5) ||
|
(o.safari && o.version < 5) ||
|
||||||
(o.opera && o.version < 10.0)) {
|
(o.opera && o.version < 10.0)) {
|
||||||
o.c = t
|
o.c = t
|
||||||
|
@ -9,47 +9,85 @@ module.exports.useragents = {
|
|||||||
Chrome: {
|
Chrome: {
|
||||||
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36': {
|
'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '30.0'
|
, version: '30.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, a: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36': {
|
, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '29.0'
|
, version: '29.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, a: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36': {
|
, 'Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '29.0'
|
, version: '29.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, a: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36': {
|
, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '29.0'
|
, version: '29.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, a: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36': {
|
, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '28.0'
|
, version: '28.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, a: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24': {
|
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '11.0'
|
, version: '11.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, a: true
|
, c: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.462.0 Safari/534.3': {
|
, 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.462.0 Safari/534.3': {
|
||||||
chrome: true
|
chrome: true
|
||||||
|
, ipad: false
|
||||||
|
, iphone: false
|
||||||
|
, ios: false
|
||||||
|
, mobile: false
|
||||||
, version: '6.0'
|
, version: '6.0'
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, c: true
|
, c: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
, 'Amazon Silk': {
|
||||||
|
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.153_10033210) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true': {
|
||||||
|
name: 'Amazon Silk'
|
||||||
|
, webkit: true
|
||||||
|
, android: true
|
||||||
|
, mobile: true
|
||||||
|
, version : '1.0'
|
||||||
|
, x: true
|
||||||
|
}
|
||||||
|
}
|
||||||
, Opera: {
|
, Opera: {
|
||||||
'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14': {
|
'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14': {
|
||||||
opera: true
|
opera: true
|
||||||
@ -175,7 +213,7 @@ module.exports.useragents = {
|
|||||||
, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': {
|
, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': {
|
||||||
msie: true
|
msie: true
|
||||||
, version: '8.0'
|
, version: '8.0'
|
||||||
, a: true
|
, c: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)': {
|
, 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)': {
|
||||||
msie: true
|
msie: true
|
||||||
@ -239,21 +277,21 @@ module.exports.useragents = {
|
|||||||
, gecko: true
|
, gecko: true
|
||||||
, firefox: true
|
, firefox: true
|
||||||
, version: '6.0'
|
, version: '6.0'
|
||||||
, a: true
|
, c: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (X11; Linux x86_64; rv:2.2a1pre) Gecko/20100101 Firefox/4.2a1pre': {
|
, 'Mozilla/5.0 (X11; Linux x86_64; rv:2.2a1pre) Gecko/20100101 Firefox/4.2a1pre': {
|
||||||
mozilla: true
|
mozilla: true
|
||||||
, gecko: true
|
, gecko: true
|
||||||
, firefox: true
|
, firefox: true
|
||||||
, version: '4.2'
|
, version: '4.2'
|
||||||
, a: true
|
, c: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0': {
|
, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0': {
|
||||||
mozilla: true
|
mozilla: true
|
||||||
, gecko: true
|
, gecko: true
|
||||||
, firefox: true
|
, firefox: true
|
||||||
, version: '4.0'
|
, version: '4.0'
|
||||||
, a: true
|
, c: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2b1) Gecko/20091014 Firefox/3.6b1 GTB5': {
|
, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2b1) Gecko/20091014 Firefox/3.6b1 GTB5': {
|
||||||
mozilla: true
|
mozilla: true
|
||||||
@ -283,6 +321,7 @@ module.exports.useragents = {
|
|||||||
, version: '5.0'
|
, version: '5.0'
|
||||||
, iphone: true
|
, iphone: true
|
||||||
, ipad: false
|
, ipad: false
|
||||||
|
, ipod: false
|
||||||
, mobile: true
|
, mobile: true
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
@ -292,6 +331,7 @@ module.exports.useragents = {
|
|||||||
, version: '3.0'
|
, version: '3.0'
|
||||||
, iphone: true
|
, iphone: true
|
||||||
, ipad: false
|
, ipad: false
|
||||||
|
, ipod: false
|
||||||
, mobile: true
|
, mobile: true
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
@ -301,6 +341,7 @@ module.exports.useragents = {
|
|||||||
, version: '4.0'
|
, version: '4.0'
|
||||||
, iphone: true
|
, iphone: true
|
||||||
, ipad: false
|
, ipad: false
|
||||||
|
, ipod: false
|
||||||
, mobile: true
|
, mobile: true
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
@ -310,6 +351,7 @@ module.exports.useragents = {
|
|||||||
, version: '3.1'
|
, version: '3.1'
|
||||||
, iphone: true
|
, iphone: true
|
||||||
, ipad: false
|
, ipad: false
|
||||||
|
, ipod: false
|
||||||
, mobile: true
|
, mobile: true
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
@ -318,37 +360,45 @@ module.exports.useragents = {
|
|||||||
, iPad: {
|
, iPad: {
|
||||||
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25': {
|
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25': {
|
||||||
ios: true
|
ios: true
|
||||||
|
, name: 'iPad'
|
||||||
, version: '6.0'
|
, version: '6.0'
|
||||||
, iphone: false
|
, iphone: false
|
||||||
, ipad: true
|
, ipad: true
|
||||||
, mobile: true
|
, ipod: false
|
||||||
|
, mobile: false
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
|
, 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3': {
|
||||||
ios: true
|
ios: true
|
||||||
|
, name: 'iPad'
|
||||||
, version: '5.1'
|
, version: '5.1'
|
||||||
, iphone: false
|
, iphone: false
|
||||||
, ipad: true
|
, ipad: true
|
||||||
, mobile: true
|
, ipod: false
|
||||||
|
, mobile: false
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
|
, 'Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5': {
|
||||||
ios: true
|
ios: true
|
||||||
|
, name: 'iPad'
|
||||||
, version: '5.0'
|
, version: '5.0'
|
||||||
, iphone: false
|
, iphone: false
|
||||||
, ipad: true
|
, ipad: true
|
||||||
, mobile: true
|
, ipod: false
|
||||||
|
, mobile: false
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
, 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B360 Safari/531.21.10': {
|
, 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B360 Safari/531.21.10': {
|
||||||
ios: true
|
ios: true
|
||||||
|
, name: 'iPad'
|
||||||
, version: '4.0'
|
, version: '4.0'
|
||||||
, iphone: false
|
, iphone: false
|
||||||
, ipad: true
|
, ipad: true
|
||||||
, mobile: true
|
, ipod: false
|
||||||
|
, mobile: false
|
||||||
, webkit: true
|
, webkit: true
|
||||||
, x: true
|
, x: true
|
||||||
}
|
}
|
||||||
|
19
test/test.js
19
test/test.js
@ -28,23 +28,34 @@ function objLength(obj) {
|
|||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objKeys(obj) {
|
||||||
|
var keys = []
|
||||||
|
, key
|
||||||
|
for (key in obj) {
|
||||||
|
if (obj.hasOwnProperty(key)) {
|
||||||
|
keys.push(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
keys.sort();
|
||||||
|
return keys.join(', ')
|
||||||
|
}
|
||||||
|
|
||||||
/* Groups */
|
/* Groups */
|
||||||
for (g in allUserAgents) { (function(group, userAgents) {
|
for (g in allUserAgents) { (function(group, userAgents) {
|
||||||
describe(group, function() {
|
describe(group, function() {
|
||||||
|
|
||||||
/* User Agents */
|
/* User Agents */
|
||||||
for (ua in userAgents) { (function(userAgent, expections) {
|
for (ua in userAgents) { (function(userAgent, expections) {
|
||||||
describe('#' + userAgent, function() {
|
describe('user agent "' + userAgent + '"', function() {
|
||||||
|
|
||||||
expections.name = group
|
expections.name = group
|
||||||
|
|
||||||
/* Get the result from bowser. */
|
/* Get the result from bowser. */
|
||||||
var result = browser._detect(userAgent)
|
var result = browser._detect(userAgent)
|
||||||
, expectionLength = objLength(expections)
|
|
||||||
|
|
||||||
/* At first, check if the result has the correct length. */
|
/* At first, check if the result has the correct length. */
|
||||||
it('Should have ' + expectionLength + ' properties', function() {
|
it('should have ' + objLength(expections) + ' properties', function() {
|
||||||
assert.equal(objLength(result), expectionLength)
|
assert.equal(objKeys(result), objKeys(expections))
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Properties */
|
/* Properties */
|
||||||
|
Loading…
Reference in New Issue
Block a user