webfontloader 1.0.28 → 1.0.29
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/lib/webfontloader.rb +1 -1
- data/src-test/core/useragenttest.js +89 -0
- data/src-test/google/fontapiurlbuildertest.js +11 -0
- data/src-test/google/lastresortwebkitfontwatchrunnertest.js +3 -3
- data/src/core/useragentparser.js +17 -2
- data/src/google/fontapiurlbuilder.js +6 -2
- data/src/google/lastresortwebkitfontwatchrunner.js +1 -4
- data/webfontloader.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
v1.0.29 (July 26, 2012)
|
2
|
+
* Added test to ensure Firefox for Android is properly detected as "Firefox" by UserAgentParser.
|
3
|
+
* Added test to ensure Opera Mobile for Android is properly detected as "Opera" by UserAgentParser.
|
4
|
+
* Changed detection so that Chrome for iOS is detected as "Chrome" instead of "Safari".
|
5
|
+
* Changed detection so that Opera Mini is correctly detected as "OperaMini" (without font support) instead of "Opera" (with font support).
|
6
|
+
* Fixed a bug in Google Web Fonts module when requesting a font family with character sets and no variations.
|
7
|
+
* Scaled back the number of fall back fonts used in the Google Web Fonts font watching code.
|
8
|
+
|
1
9
|
v1.0.28 (June 4, 2012)
|
2
10
|
* Added support for detecting the Chrome OS platform ("CrOS") in the UserAgentParser.
|
3
11
|
|
data/lib/webfontloader.rb
CHANGED
@@ -197,6 +197,24 @@ UserAgentTest.prototype.testBrowserIsAndroidChromeMobile = function() {
|
|
197
197
|
assertTrue(userAgent.isSupportingWebFont());
|
198
198
|
};
|
199
199
|
|
200
|
+
UserAgentTest.prototype.testBrowserIsAndroidFirefox = function() {
|
201
|
+
// This useragent has been slightly doctored with versions to ensure the right
|
202
|
+
// info is coming from the right places.
|
203
|
+
var userAgentParser = new webfont.UserAgentParser(
|
204
|
+
"Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/15.0 Firefox/14.0",
|
205
|
+
this.defaultDocument_);
|
206
|
+
var userAgent = userAgentParser.parse();
|
207
|
+
|
208
|
+
assertEquals("Firefox", userAgent.getName());
|
209
|
+
assertEquals("14.0", userAgent.getVersion());
|
210
|
+
assertEquals("Android", userAgent.getPlatform());
|
211
|
+
assertEquals("Unknown", userAgent.getPlatformVersion());
|
212
|
+
assertEquals("Gecko", userAgent.getEngine());
|
213
|
+
assertEquals("13.0", userAgent.getEngineVersion());
|
214
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
215
|
+
assertTrue(userAgent.isSupportingWebFont());
|
216
|
+
}
|
217
|
+
|
200
218
|
UserAgentTest.prototype.testBrowserIsFirefoxLettersVersion = function() {
|
201
219
|
var userAgentParser = new webfont.UserAgentParser(
|
202
220
|
"Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.9.2a1pre) Gecko/20090405 Ubuntu/9.04 (jaunty) Firefox/3.6a1pre",
|
@@ -293,6 +311,45 @@ UserAgentTest.prototype.testBrowserIsOperaBeforeVersion10 = function() {
|
|
293
311
|
assertFalse(userAgent.isSupportingWebFont());
|
294
312
|
};
|
295
313
|
|
314
|
+
UserAgentTest.prototype.testBrowserIsOperaMobileAndroid = function() {
|
315
|
+
// For the purposes of web font support, we consider Opera Mobile to be a
|
316
|
+
// version of full Opera on mobile devices, since the support for web fonts
|
317
|
+
// follows the same version numbers as the desktop versions.
|
318
|
+
var userAgentParser = new webfont.UserAgentParser(
|
319
|
+
"Opera/9.80 (Android 4.1.1; Linux; Opera Mobi/ADR-1207201819; U; en) Presto/2.10.254 Version/12.00",
|
320
|
+
this.defaultDocument_);
|
321
|
+
var userAgent = userAgentParser.parse();
|
322
|
+
|
323
|
+
assertEquals("Opera", userAgent.getName());
|
324
|
+
assertEquals("12.00", userAgent.getVersion());
|
325
|
+
assertEquals("Android", userAgent.getPlatform());
|
326
|
+
assertEquals("4.1.1", userAgent.getPlatformVersion());
|
327
|
+
assertEquals("Presto", userAgent.getEngine());
|
328
|
+
assertEquals("2.10.254", userAgent.getEngineVersion());
|
329
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
330
|
+
assertTrue(userAgent.isSupportingWebFont());
|
331
|
+
};
|
332
|
+
|
333
|
+
UserAgentTest.prototype.testBrowserIsOperaMiniAndroid = function() {
|
334
|
+
// For the purposes of web font support, we consider Opera Mini to be a
|
335
|
+
// different browser from the full Opera, since it doesn't support web fonts
|
336
|
+
// and follows two separate versioning systems. We use the Opera Mini version
|
337
|
+
// instead of the more generic Opera version.
|
338
|
+
var userAgentParser = new webfont.UserAgentParser(
|
339
|
+
"Opera/9.80 (Android; Opera Mini/7.0.29952/28.2144; U; en) Presto/2.8.119 Version/11.10",
|
340
|
+
this.defaultDocument_);
|
341
|
+
var userAgent = userAgentParser.parse();
|
342
|
+
|
343
|
+
assertEquals("OperaMini", userAgent.getName());
|
344
|
+
assertEquals("7.0.29952", userAgent.getVersion());
|
345
|
+
assertEquals("Android", userAgent.getPlatform());
|
346
|
+
assertEquals("Unknown", userAgent.getPlatformVersion());
|
347
|
+
assertEquals("Presto", userAgent.getEngine());
|
348
|
+
assertEquals("2.8.119", userAgent.getEngineVersion());
|
349
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
350
|
+
assertFalse(userAgent.isSupportingWebFont());
|
351
|
+
}
|
352
|
+
|
296
353
|
UserAgentTest.prototype.testBrowserIsIEOnMac = function() {
|
297
354
|
var userAgentParser = new webfont.UserAgentParser(
|
298
355
|
"Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC)",
|
@@ -357,6 +414,22 @@ UserAgentTest.prototype.testBrowserIsIPadWithoutIPhone = function() {
|
|
357
414
|
assertTrue(userAgent.isSupportingWebFont());
|
358
415
|
};
|
359
416
|
|
417
|
+
UserAgentTest.prototype.testBrowserIsIPadChrome = function() {
|
418
|
+
var userAgentParser = new webfont.UserAgentParser(
|
419
|
+
"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",
|
420
|
+
this.defaultDocument_);
|
421
|
+
var userAgent = userAgentParser.parse();
|
422
|
+
|
423
|
+
assertEquals("Chrome", userAgent.getName());
|
424
|
+
assertEquals("19.0.1084.60", userAgent.getVersion());
|
425
|
+
assertEquals("iPad", userAgent.getPlatform());
|
426
|
+
assertEquals("5_1_1", userAgent.getPlatformVersion());
|
427
|
+
assertEquals("AppleWebKit", userAgent.getEngine());
|
428
|
+
assertEquals("534.46.0", userAgent.getEngineVersion());
|
429
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
430
|
+
assertTrue(userAgent.isSupportingWebFont());
|
431
|
+
}
|
432
|
+
|
360
433
|
UserAgentTest.prototype.testBrowserIsIPod = function() {
|
361
434
|
var userAgentParser = new webfont.UserAgentParser(
|
362
435
|
"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 +462,22 @@ UserAgentTest.prototype.testBrowserIsIPodSafari = function() {
|
|
389
462
|
assertTrue(userAgent.isSupportingWebFont());
|
390
463
|
};
|
391
464
|
|
465
|
+
UserAgentTest.prototype.testBrowserIsIPodChrome = function() {
|
466
|
+
var userAgentParser = new webfont.UserAgentParser(
|
467
|
+
"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",
|
468
|
+
this.defaultDocument_);
|
469
|
+
var userAgent = userAgentParser.parse();
|
470
|
+
|
471
|
+
assertEquals("Chrome", userAgent.getName());
|
472
|
+
assertEquals("19.0.1084.60", userAgent.getVersion());
|
473
|
+
assertEquals("iPod", userAgent.getPlatform());
|
474
|
+
assertEquals("5_1_1", userAgent.getPlatformVersion());
|
475
|
+
assertEquals("AppleWebKit", userAgent.getEngine());
|
476
|
+
assertEquals("534.46.0", userAgent.getEngineVersion());
|
477
|
+
assertEquals(undefined, userAgent.getDocumentMode());
|
478
|
+
assertTrue(userAgent.isSupportingWebFont());
|
479
|
+
}
|
480
|
+
|
392
481
|
UserAgentTest.prototype.testBrowserIsSafariWithPlusVersion = function() {
|
393
482
|
var userAgentParser = new webfont.UserAgentParser(
|
394
483
|
"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",
|
@@ -37,3 +37,14 @@ FontApiUrlBuilderTest.prototype.testBuildProperUrlWithSubsets = function() {
|
|
37
37
|
'?family=Font1:bold%7CFont2:italic%7CFont3' +
|
38
38
|
'&subset=greek,cyrillic', fontApiUrlBuilder.build());
|
39
39
|
};
|
40
|
+
|
41
|
+
FontApiUrlBuilderTest.prototype.testBuildProperUrlWithSubsetsNoVariations =
|
42
|
+
function() {
|
43
|
+
var fontApiUrlBuilder = new webfont.FontApiUrlBuilder();
|
44
|
+
|
45
|
+
fontApiUrlBuilder.setFontFamilies([ 'Font1:bold,italic:greek,cyrillic',
|
46
|
+
'Font2:italic', 'Font3::latin' ]);
|
47
|
+
assertEquals("http:" + webfont.FontApiUrlBuilder.DEFAULT_API_URL +
|
48
|
+
'?family=Font1:bold,italic%7CFont2:italic%7CFont3' +
|
49
|
+
'&subset=greek,cyrillic,latin', fontApiUrlBuilder.build());
|
50
|
+
};
|
@@ -73,7 +73,7 @@ LastResortWebKitFontWatchRunnerTest.prototype.setUp = function() {
|
|
73
73
|
LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontIgnored =
|
74
74
|
function() {
|
75
75
|
var originalSizeCount = 2;
|
76
|
-
var lastResortFontsCount =
|
76
|
+
var lastResortFontsCount = 5;
|
77
77
|
var firstSize = 2;
|
78
78
|
var secondSize = 2;
|
79
79
|
var thirdSize = 2;
|
@@ -119,7 +119,7 @@ LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontActiveWhenSizeMa
|
|
119
119
|
= function() {
|
120
120
|
this.timesToGetTimeBeforeTimeout_ = 3;
|
121
121
|
var originalSizeCount = 2;
|
122
|
-
var lastResortFontsCount =
|
122
|
+
var lastResortFontsCount = 5;
|
123
123
|
var firstSize = 2;
|
124
124
|
|
125
125
|
this.fontFamily_ = "Arimo";
|
@@ -157,7 +157,7 @@ LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontInactiveWhenSize
|
|
157
157
|
= function() {
|
158
158
|
this.timesToGetTimeBeforeTimeout_ = 3;
|
159
159
|
var originalSizeCount = 2;
|
160
|
-
var lastResortFontsCount =
|
160
|
+
var lastResortFontsCount = 5;
|
161
161
|
var firstSize = 2;
|
162
162
|
var secondSize = 2;
|
163
163
|
var thirdSize = 2;
|
data/src/core/useragentparser.js
CHANGED
@@ -153,6 +153,21 @@ webfont.UserAgentParser.prototype.parseOperaUserAgentString_ = function() {
|
|
153
153
|
engineVersion = geckoVersion;
|
154
154
|
}
|
155
155
|
}
|
156
|
+
|
157
|
+
// Check for Opera Mini first, since it looks like normal Opera
|
158
|
+
if (this.userAgent_.indexOf("Opera Mini/") != -1) {
|
159
|
+
var version = this.getMatchingGroup_(this.userAgent_, /Opera Mini\/([\d\.]+)/, 1);
|
160
|
+
|
161
|
+
if (version == "") {
|
162
|
+
version = webfont.UserAgentParser.UNKNOWN;
|
163
|
+
}
|
164
|
+
|
165
|
+
return new webfont.UserAgent("OperaMini", version, engineName,
|
166
|
+
engineVersion, this.getPlatform_(), this.getPlatformVersion_(),
|
167
|
+
this.getDocumentMode_(this.doc_), false);
|
168
|
+
}
|
169
|
+
|
170
|
+
// Otherwise, find version information for normal Opera or Opera Mobile
|
156
171
|
if (this.userAgent_.indexOf("Version/") != -1) {
|
157
172
|
var version = this.getMatchingGroup_(this.userAgent_, /Version\/([\d\.]+)/, 1);
|
158
173
|
|
@@ -195,7 +210,7 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
|
|
195
210
|
}
|
196
211
|
var name = webfont.UserAgentParser.UNKNOWN;
|
197
212
|
|
198
|
-
if (this.userAgent_.indexOf("Chrome") != -1 || this.userAgent_.indexOf("CrMo") != -1) {
|
213
|
+
if (this.userAgent_.indexOf("Chrome") != -1 || this.userAgent_.indexOf("CrMo") != -1 || this.userAgent_.indexOf("CriOS") != -1) {
|
199
214
|
name = "Chrome";
|
200
215
|
} else if (this.userAgent_.indexOf("Safari") != -1) {
|
201
216
|
name = "Safari";
|
@@ -209,7 +224,7 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
|
|
209
224
|
/Version\/([\d\.\w]+)/, 1);
|
210
225
|
} else if (name == "Chrome") {
|
211
226
|
version = this.getMatchingGroup_(this.userAgent_,
|
212
|
-
/(Chrome|CrMo)\/([\d\.]+)/, 2);
|
227
|
+
/(Chrome|CrMo|CriOS)\/([\d\.]+)/, 2);
|
213
228
|
} else if (name == "AdobeAIR") {
|
214
229
|
version = this.getMatchingGroup_(this.userAgent_,
|
215
230
|
/AdobeAIR\/([\d\.]+)/, 1);
|
@@ -8,7 +8,7 @@ webfont.FontApiUrlBuilder = function(apiUrl) {
|
|
8
8
|
var protocol = 'https:' == window.location.protocol ? 'https:' : 'http:';
|
9
9
|
|
10
10
|
this.apiUrl_ = protocol + webfont.FontApiUrlBuilder.DEFAULT_API_URL;
|
11
|
-
}
|
11
|
+
}
|
12
12
|
this.fontFamilies_ = [];
|
13
13
|
this.subsets_ = [];
|
14
14
|
};
|
@@ -32,7 +32,11 @@ webfont.FontApiUrlBuilder.prototype.parseFontFamilies_ =
|
|
32
32
|
if (elements.length == 3) {
|
33
33
|
this.subsets_.push(elements.pop());
|
34
34
|
}
|
35
|
-
|
35
|
+
var joinCharacter = '';
|
36
|
+
if (elements.length == 2 && elements[1] != ''){
|
37
|
+
joinCharacter = ':';
|
38
|
+
}
|
39
|
+
this.fontFamilies_.push(elements.join(joinCharacter));
|
36
40
|
}
|
37
41
|
};
|
38
42
|
|
@@ -38,10 +38,7 @@ webfont.LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS = {
|
|
38
38
|
*/
|
39
39
|
webfont.LastResortWebKitFontWatchRunner.prototype
|
40
40
|
.setUpWebKitLastResortFontSizes_ = function() {
|
41
|
-
var lastResortFonts = [
|
42
|
-
"Lucida Sans Unicode", "Courier New", "Tahoma", "Arial",
|
43
|
-
"Microsoft Sans Serif", "Times", "Lucida Console", "Sans", "Serif",
|
44
|
-
"Monospace"];
|
41
|
+
var lastResortFonts = ['Times New Roman', 'Arial', 'Times', 'Sans', 'Serif'];
|
45
42
|
var lastResortFontSizes = lastResortFonts.length;
|
46
43
|
var webKitLastResortFontSizes = {};
|
47
44
|
var element = this.createHiddenElementWithFont_(lastResortFonts[0], true);
|
data/webfontloader.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'webfontloader'
|
16
|
-
s.version = '1.0.
|
17
|
-
s.date = '2012-
|
16
|
+
s.version = '1.0.29'
|
17
|
+
s.date = '2012-07-26'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webfontloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 45
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 29
|
10
|
+
version: 1.0.29
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Carver
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-07-26 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
prerelease: false
|