Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the ability to detect Chrome for iOS as Chrome, not Safari

  • Loading branch information...
commit 0ffeeaf8fe959df352de656b778ee18efdc3b622 1 parent bcc16e4
Sean McBride authored
Showing with 34 additions and 2 deletions.
  1. +32 −0 src-test/core/useragenttest.js
  2. +2 −2 src/core/useragentparser.js
View
32 src-test/core/useragenttest.js
@@ -357,6 +357,22 @@ UserAgentTest.prototype.testBrowserIsIPadWithoutIPhone = function() {
assertTrue(userAgent.isSupportingWebFont());
};
+UserAgentTest.prototype.testBrowserIsIPadChrome = function() {
+ var userAgentParser = new webfont.UserAgentParser(
+ "Mozilla/5.0 (iPad; U; CPU OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
+ this.defaultDocument_);
+ var userAgent = userAgentParser.parse();
+
+ assertEquals("Chrome", userAgent.getName());
+ assertEquals("19.0.1084.60", userAgent.getVersion());
+ assertEquals("iPad", userAgent.getPlatform());
+ assertEquals("5_1_1", userAgent.getPlatformVersion());
+ assertEquals("AppleWebKit", userAgent.getEngine());
+ assertEquals("534.46.0", userAgent.getEngineVersion());
+ assertEquals(undefined, userAgent.getDocumentMode());
+ assertTrue(userAgent.isSupportingWebFont());
+}
+
UserAgentTest.prototype.testBrowserIsIPod = function() {
var userAgentParser = new webfont.UserAgentParser(
"Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5H11a",
@@ -389,6 +405,22 @@ UserAgentTest.prototype.testBrowserIsIPodSafari = function() {
assertTrue(userAgent.isSupportingWebFont());
};
+UserAgentTest.prototype.testBrowserIsIPodChrome = function() {
+ var userAgentParser = new webfont.UserAgentParser(
+ "Mozilla/5.0 (iPod; U; CPU iPhone OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
+ this.defaultDocument_);
+ var userAgent = userAgentParser.parse();
+
+ assertEquals("Chrome", userAgent.getName());
+ assertEquals("19.0.1084.60", userAgent.getVersion());
+ assertEquals("iPod", userAgent.getPlatform());
+ assertEquals("5_1_1", userAgent.getPlatformVersion());
+ assertEquals("AppleWebKit", userAgent.getEngine());
+ assertEquals("534.46.0", userAgent.getEngineVersion());
+ assertEquals(undefined, userAgent.getDocumentMode());
+ assertTrue(userAgent.isSupportingWebFont());
+}
+
UserAgentTest.prototype.testBrowserIsSafariWithPlusVersion = function() {
var userAgentParser = new webfont.UserAgentParser(
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; tr) AppleWebKit/528.4+ (KHTML, like Gecko) Version/4.0dp1 Safari/526.11.2",
View
4 src/core/useragentparser.js
@@ -195,7 +195,7 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
}
var name = webfont.UserAgentParser.UNKNOWN;
- if (this.userAgent_.indexOf("Chrome") != -1 || this.userAgent_.indexOf("CrMo") != -1) {
+ if (this.userAgent_.indexOf("Chrome") != -1 || this.userAgent_.indexOf("CrMo") != -1 || this.userAgent_.indexOf("CriOS") != -1) {
name = "Chrome";
} else if (this.userAgent_.indexOf("Safari") != -1) {
name = "Safari";
@@ -209,7 +209,7 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
/Version\/([\d\.\w]+)/, 1);
} else if (name == "Chrome") {
version = this.getMatchingGroup_(this.userAgent_,
- /(Chrome|CrMo)\/([\d\.]+)/, 2);
+ /(Chrome|CrMo|CriOS)\/([\d\.]+)/, 2);
} else if (name == "AdobeAIR") {
version = this.getMatchingGroup_(this.userAgent_,
/AdobeAIR\/([\d\.]+)/, 1);
Please sign in to comment.
Something went wrong with that request. Please try again.