Skip to content

Commit

Permalink
Detect IE 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn authored and mislav committed Feb 16, 2014
1 parent e557acb commit db27729
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
playbook = ua.match(/PlayBook/),
chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/),
firefox = ua.match(/Firefox\/([\d.]+)/),
ie = ua.match(/MSIE\s([\d.]+)/),
ie = ua.match(/MSIE\s([\d.]+)/) || ua.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),
webview = !chrome && ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),
safari = webview || ua.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/)

Expand Down
29 changes: 27 additions & 2 deletions test/detect.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ <h1>Zepto Detect unit tests</h1>
Firefox_6_0_2: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2",
Firefox_Mobile_Simulator: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:2.1.1) Gecko/ Firefox/4.0.2pre Fennec/4.0.1",

Windows_IE: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
Windows_IE_9: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Windows_IE_9_Compat: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)",
Windows_IE_10: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
Windows_IE_11: "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko",
Windows_RT_Surface: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)",
Windows_Phone_8: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; Windows Phone 8X by HTC)"
}
Expand Down Expand Up @@ -432,7 +435,14 @@ <h1>Zepto Detect unit tests</h1>
},

testIE: function(t) {
detect(UA.Windows_IE, function(os, browser){
detect(UA.Windows_IE_11, function(os, browser){
t.assertFalse(os.phone)
t.assertFalse(os.tablet)
t.assertTrue(browser.ie)
t.assertEqual("11", browser.version)
})

detect(UA.Windows_IE_10, function(os, browser){
t.assertFalse(os.phone)
t.assertFalse(os.tablet)
t.assertTrue(browser.ie)
Expand All @@ -452,6 +462,21 @@ <h1>Zepto Detect unit tests</h1>
t.assertTrue(browser.ie)
t.assertEqual("10.0", browser.version)
})

detect(UA.Windows_IE_9, function(os, browser){
t.assertFalse(os.phone)
t.assertFalse(os.tablet)
t.assertTrue(browser.ie)
t.assertEqual("9.0", browser.version)
})

detect(UA.Windows_IE_9_Compat, function(os, browser){
t.assertFalse(os.phone)
t.assertFalse(os.tablet)
t.assertTrue(browser.ie)
t.assertEqual("7.0", browser.version)
})

}
})
})()
Expand Down

0 comments on commit db27729

Please sign in to comment.