webfontloader 1.5.21 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38658e34f875143f4c7da55b806b3734211ec243
4
- data.tar.gz: 18161fe41190393aabe0b5a1c66b1da7e2b327c2
3
+ metadata.gz: 45a47daf28ee4cd29e8e044c4ff0c296d03f7f4d
4
+ data.tar.gz: 632bcb1c5d914ddf66aeb679b3d705e34e144945
5
5
  SHA512:
6
- metadata.gz: 51d3ec5bdc64984eb0bdfc0601dbe01e49a3a2081877109e2facaf304146e00ca63670ea942b872cb88293a2a937056c16563a3ee0049e18f6b63af272ec20db
7
- data.tar.gz: 8f028fafa7ccf2bec73e6ec81718b2c1a496905635777043a19b3e6bc6dce49fab8eeaaf611e2214d555098054f8a92254292a326563d96d7575616de1e2761c
6
+ metadata.gz: f105249ee823a73c6c57573a81938bdcac178e22be04960259cbfc5bae535c186d9160ea76681487971bf8796e397eb293e52ae40baabc62aa19f15e324d49b7
7
+ data.tar.gz: e4f343569f5fcb6e98c0f6e72896264c6a29cf8ec28701b3c402897f71b647f33ce2ca4007ad1c8bffa2a9d3c07ec93d9420f1b52f2f2b52ae06bcb4cda9bbfe
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v1.6.0 (May 28, 2015)
2
+ * Remove user agent string sniffing. From now on the Web Font Loader will always try to load fonts.
3
+
1
4
  v1.5.21 (May 26, 2015)
2
5
  * No changes.
3
6
 
data/lib/webfontloader.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.5.21'
6
+ VERSION = '1.6.0'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
@@ -2,8 +2,6 @@ describe('FontWatcher', function () {
2
2
  var FontWatcher = webfont.FontWatcher,
3
3
  FontWatchRunner = webfont.FontWatchRunner,
4
4
  Font = webfont.Font,
5
- UserAgent = webfont.UserAgent,
6
- BrowserInfo = webfont.BrowserInfo,
7
5
  DomHelper = webfont.DomHelper,
8
6
  Version = webfont.Version,
9
7
  domHelper = new DomHelper(window),
@@ -14,20 +12,9 @@ describe('FontWatcher', function () {
14
12
  font2 = null,
15
13
  font3 = null,
16
14
  font4 = null,
17
- userAgent = null,
18
15
  activeFonts = [];
19
16
 
20
17
  beforeEach(function () {
21
- userAgent = new UserAgent(
22
- 'Firefox',
23
- new Version(3, 6),
24
- 'Gecko',
25
- new Version(1, 9, 3),
26
- 'Macintosh',
27
- new Version(10, 6),
28
- undefined,
29
- new BrowserInfo(true, false, false, false)
30
- );
31
18
  font1 = new Font('font1');
32
19
  font2 = new Font('font2');
33
20
  font3 = new Font('font3');
@@ -66,7 +53,7 @@ describe('FontWatcher', function () {
66
53
  describe('watch zero fonts', function () {
67
54
  it('should call inactive when there are no fonts to load', function () {
68
55
  activeFonts = [];
69
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
56
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
70
57
 
71
58
  fontWatcher.watchFonts([], {}, null, true);
72
59
  expect(eventDispatcher.dispatchInactive).toHaveBeenCalled();
@@ -74,7 +61,7 @@ describe('FontWatcher', function () {
74
61
 
75
62
  it('should not call inactive when there are no fonts to load, but this is not the last set', function () {
76
63
  activeFonts = [];
77
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
64
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
78
65
 
79
66
  fontWatcher.watchFonts([], {}, null, false);
80
67
  expect(eventDispatcher.dispatchInactive).not.toHaveBeenCalled();
@@ -84,7 +71,7 @@ describe('FontWatcher', function () {
84
71
  describe('watch one font not last', function () {
85
72
  it('should not call font inactive, inactive or active', function () {
86
73
  activeFonts = [font1];
87
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
74
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
88
75
 
89
76
  fontWatcher.watchFonts([font1], {}, null, false);
90
77
  expect(eventDispatcher.dispatchFontInactive).not.toHaveBeenCalled();
@@ -96,7 +83,7 @@ describe('FontWatcher', function () {
96
83
  describe('watch one font active', function () {
97
84
  it('should call font active and active', function () {
98
85
  activeFonts = [font1];
99
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
86
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
100
87
 
101
88
  fontWatcher.watchFonts([font1], {}, null, true);
102
89
  expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
@@ -110,7 +97,7 @@ describe('FontWatcher', function () {
110
97
  describe('watch one font inactive', function () {
111
98
  it('should call inactive', function () {
112
99
  activeFonts = [];
113
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
100
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
114
101
 
115
102
  fontWatcher.watchFonts([font1], {}, null, true);
116
103
  expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
@@ -124,7 +111,7 @@ describe('FontWatcher', function () {
124
111
  describe('watch multiple fonts active', function () {
125
112
  it('should call font active and active', function () {
126
113
  activeFonts = [font1, font2, font3];
127
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
114
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
128
115
 
129
116
  fontWatcher.watchFonts([font1, font2, font3], {}, null, true);
130
117
  expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
@@ -138,7 +125,7 @@ describe('FontWatcher', function () {
138
125
  describe('watch multiple fonts inactive', function () {
139
126
  it('should call inactive', function () {
140
127
  activeFonts = [];
141
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
128
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
142
129
 
143
130
  fontWatcher.watchFonts([font1, font2, font3], {}, null, true);
144
131
  expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
@@ -152,7 +139,7 @@ describe('FontWatcher', function () {
152
139
  describe('watch multiple fonts mixed', function () {
153
140
  it('should call the correct callbacks', function () {
154
141
  activeFonts = [font1, font3];
155
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
142
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
156
143
 
157
144
  fontWatcher.watchFonts([font1, font2, font3], {}, null, true);
158
145
  expect(eventDispatcher.dispatchFontLoading.callCount).toEqual(3);
@@ -181,7 +168,7 @@ describe('FontWatcher', function () {
181
168
  font9 = new Font('font8', 'n7');
182
169
 
183
170
  activeFonts = [font5, font6];
184
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
171
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
185
172
 
186
173
  fontWatcher.watchFonts([font5, font6, font7, font8, font9], {}, null, true);
187
174
  expect(eventDispatcher.dispatchFontLoading.callCount).toEqual(5);
@@ -209,7 +196,7 @@ describe('FontWatcher', function () {
209
196
  it('should use the correct tests strings', function () {
210
197
  activeFonts = [font1, font2];
211
198
 
212
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
199
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher);
213
200
 
214
201
  fontWatcher.watchFonts([font1, font2, font3, font4], {
215
202
  'font1': 'testString1',
@@ -227,7 +214,7 @@ describe('FontWatcher', function () {
227
214
  });
228
215
 
229
216
  it('should pass on the timeout to FontWatchRunner', function () {
230
- var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher, 4000);
217
+ var fontWatcher = new FontWatcher(domHelper, eventDispatcher, 4000);
231
218
 
232
219
  fontWatcher.watchFonts([font1], {}, null, true);
233
220
 
@@ -2,29 +2,23 @@ describe('FontWatchRunner', function () {
2
2
  var FontWatchRunner = webfont.FontWatchRunner,
3
3
  Font = webfont.Font,
4
4
  BrowserInfo = webfont.BrowserInfo,
5
- UserAgentParser = webfont.UserAgentParser,
6
5
  DomHelper = webfont.DomHelper,
7
6
  FontRuler = webfont.FontRuler;
8
7
 
9
8
  var domHelper = null,
10
9
  activeCallback = null,
11
10
  inactiveCallback = null,
12
- userAgent = null,
13
11
  nullFont = null,
14
12
  sourceSansA = null,
15
13
  sourceSansB = null,
16
14
  elena = null;
17
15
 
18
16
  beforeEach(function () {
19
- var userAgentParser = new UserAgentParser(window.navigator.userAgent, window.document);
20
-
21
17
  domHelper = new DomHelper(window);
22
18
 
23
19
  activeCallback = jasmine.createSpy('activeCallback');
24
20
  inactiveCallback = jasmine.createSpy('inactiveCallback');
25
21
 
26
- userAgent = userAgentParser.parse();
27
-
28
22
  nullFont = new Font('__webfontloader_test__');
29
23
  sourceSansA = new Font('SourceSansA');
30
24
  sourceSansB = new Font('SourceSansB');
@@ -33,7 +27,7 @@ describe('FontWatchRunner', function () {
33
27
 
34
28
  it('should fail to load a null font', function () {
35
29
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
36
- domHelper, nullFont, userAgent.getBrowserInfo(), 500, {});
30
+ domHelper, nullFont, 500, {});
37
31
 
38
32
  runs(function () {
39
33
  fontWatchRunner.start();
@@ -50,7 +44,7 @@ describe('FontWatchRunner', function () {
50
44
 
51
45
  it('should load font succesfully', function () {
52
46
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
53
- domHelper, sourceSansA, userAgent.getBrowserInfo(), 5000),
47
+ domHelper, sourceSansA, 5000),
54
48
  ruler = new FontRuler(domHelper, 'abcdef'),
55
49
  monospace = new Font('monospace'),
56
50
  sourceSansAFallback = new Font("'SourceSansA', monospace"),
@@ -92,7 +86,7 @@ describe('FontWatchRunner', function () {
92
86
 
93
87
  it('should attempt to load a non-existing font', function () {
94
88
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
95
- domHelper, elena, userAgent.getBrowserInfo(), 500, {});
89
+ domHelper, elena, 500, {});
96
90
 
97
91
  runs(function () {
98
92
  fontWatchRunner.start();
@@ -109,7 +103,7 @@ describe('FontWatchRunner', function () {
109
103
 
110
104
  it('should load even if @font-face is inserted after watching has started', function () {
111
105
  var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
112
- domHelper, sourceSansB, userAgent.getBrowserInfo(), 5000),
106
+ domHelper, sourceSansB, 5000),
113
107
  ruler = new FontRuler(domHelper, 'abcdef'),
114
108
  monospace = new Font('monospace'),
115
109
  sourceSansBFallback = new Font("'SourceSansB', monospace"),
@@ -1,14 +1,12 @@
1
1
  describe('NativeFontWatchRunner', function () {
2
2
  var NativeFontWatchRunner = webfont.NativeFontWatchRunner,
3
3
  Font = webfont.Font,
4
- UserAgentParser = webfont.UserAgentParser,
5
4
  DomHelper = webfont.DomHelper,
6
5
  FontRuler = webfont.FontRuler;
7
6
 
8
7
  var domHelper = null,
9
8
  activeCallback = null,
10
9
  inactiveCallback = null,
11
- userAgent = null,
12
10
  nullFont = null,
13
11
  sourceSansC = null,
14
12
  elena = null;
@@ -19,13 +17,9 @@ describe('NativeFontWatchRunner', function () {
19
17
  activeCallback = jasmine.createSpy('activeCallback');
20
18
  inactiveCallback = jasmine.createSpy('inactiveCallback');
21
19
 
22
- var userAgentParser = new UserAgentParser(window.navigator.userAgent, window.document);
23
-
24
20
  nullFont = new Font('__webfontloader_test_3__');
25
21
  sourceSansC = new Font('SourceSansC');
26
22
  elena = new Font('Elena');
27
-
28
- userAgent = userAgentParser.parse();
29
23
  });
30
24
 
31
25
  if (window['FontFace']) {
@@ -1,103 +1,21 @@
1
1
  describe('WebFont', function () {
2
2
  var WebFont = webfont.WebFont,
3
3
  Font = webfont.Font;
4
- UserAgent = webfont.UserAgent,
5
4
  FontWatchRunner = webfont.FontWatchRunner,
6
5
  NativeFontWatchRunner = webfont.NativeFontWatchRunner,
7
- BrowserInfo = webfont.BrowserInfo,
8
6
  Version = webfont.Version,
9
7
  Font = webfont.Font,
10
8
  FontModuleLoader = webfont.FontModuleLoader,
11
- fontModuleLoader = null,
12
- userAgent = null;
9
+ fontModuleLoader = null;
13
10
 
14
11
  beforeEach(function () {
15
- userAgent = new UserAgent(
16
- 'Firefox',
17
- new Version(3, 6),
18
- '3.6',
19
- 'Gecko',
20
- new Version(1, 9, 2),
21
- '1.9.2',
22
- 'Macintosh',
23
- new Version(10, 6),
24
- '10.6',
25
- undefined,
26
- new BrowserInfo(true, false, false, false)
27
- );
28
12
  fontModuleLoader = new FontModuleLoader();
29
13
  });
30
14
 
31
- describe('font load', function () {
32
- var font = null,
33
- testModule = null;
34
-
35
- beforeEach(function () {
36
- font = new WebFont(window);
37
- font.addModule('test', function (conf, domHelper) {
38
- testModule = new function () {
39
- this.conf = conf;
40
- this.domHelper = domHelper;
41
- this.loadCalled = true;
42
- this.supportUserAgentCalled = false;
43
- };
44
-
45
- testModule.load = function (onReady) {
46
- this.loadCalled = true;
47
- onReady([]);
48
- };
49
-
50
- testModule.supportUserAgent = function (ua, support) {
51
- this.supportUserAgentCalled = true;
52
- support(true);
53
- };
54
-
55
- return testModule;
56
- });
57
- });
58
-
59
- it('should not start loading', function () {
60
- expect(font.moduleFailedLoading_).toEqual(0);
61
- expect(font.moduleLoading_).toEqual(0);
62
- });
63
-
64
- it('should fail to load a module', function () {
65
- var loading = jasmine.createSpy('loading');
66
-
67
- font.load({
68
- test: {
69
- somedata: 'in french a cow says meuh'
70
- },
71
- loading: loading
72
- });
73
-
74
- expect(font.moduleFailedLoading_).toEqual(1);
75
- expect(font.moduleLoading_).toEqual(0);
76
- expect(testModule).not.toBeNull();
77
-
78
- expect(testModule.conf).not.toBeUndefined();
79
- expect(testModule.conf).not.toBeNull();
80
-
81
- expect(testModule.domHelper).not.toBeNull();
82
- expect(testModule.domHelper).not.toBeUndefined();
83
-
84
- expect(testModule.domHelper.getMainWindow()).toEqual(window);
85
- expect(testModule.domHelper.getLoadWindow()).toEqual(window);
86
-
87
- expect(testModule.conf.somedata).toEqual('in french a cow says meuh');
88
- expect(testModule.loadCalled).toBe(true);
89
- expect(testModule.supportUserAgentCalled).toBe(true);
90
- expect(loading).toHaveBeenCalled();
91
- });
92
- });
93
-
94
15
  describe('font load with context', function () {
95
16
  var font = null,
96
17
  testModule = null,
97
18
  fakeMainWindow = {
98
- navigator: {
99
- userAgent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2'
100
- },
101
19
  document: {}
102
20
  };
103
21
 
@@ -107,9 +25,8 @@ describe('WebFont', function () {
107
25
  testModule = new function () {
108
26
  this.domHelper = domHelper;
109
27
  };
110
- testModule.load = function () {};
111
- testModule.supportUserAgent = function (ua, support) {
112
- support(true);
28
+ testModule.load = function (onReady) {
29
+ onReady([]);
113
30
  };
114
31
 
115
32
  return testModule;
@@ -146,7 +63,6 @@ describe('WebFont', function () {
146
63
  webfont.addModule('test', function (conf, domHelper) {
147
64
  testModule = new function () {
148
65
  this.conf = conf;
149
- this.fonts = [];
150
66
  };
151
67
 
152
68
  spyOn(FontWatchRunner.prototype, 'start').andCallFake(function () {
@@ -165,16 +81,12 @@ describe('WebFont', function () {
165
81
  }
166
82
  });
167
83
 
168
- testModule.supportUserAgent = function (userAgent, support) {
84
+ testModule.load = function (onReady) {
169
85
  if (conf.id) {
170
- // The monotype module only initializes font
171
- // and description if there is a kit id.
172
- this.fonts = [font];
86
+ onReady([font]);
87
+ } else {
88
+ onReady([]);
173
89
  }
174
- support(true);
175
- };
176
- testModule.load = function (onReady) {
177
- onReady(this.fonts);
178
90
  };
179
91
 
180
92
  return testModule;
@@ -221,7 +133,6 @@ describe('WebFont', function () {
221
133
 
222
134
  font.addModule('test', function (conf, domHelper) {
223
135
  testModule = new function () {};
224
- testModule.supportUserAgent = function (ua, support) { support(true); };
225
136
  testModule.load = function (onReady) {
226
137
  onReady([new Font('Elena')], { 'Elena': '1234567' });
227
138
  };
@@ -243,40 +154,6 @@ describe('WebFont', function () {
243
154
  });
244
155
  });
245
156
 
246
- describe('font inactive', function () {
247
- var font = null,
248
- testModule = null;
249
-
250
- beforeEach(function () {
251
- font = new WebFont(window);
252
- font.addModule('test', function (conf, domHelper) {
253
- testModule = new function () {
254
- this.conf = conf;
255
- this.loadCalled = false;
256
- };
257
- testModule.supportUserAgent = function (ua, support) {
258
- support(false);
259
- };
260
- testModule.load = function () {};
261
- return testModule;
262
- });
263
- });
264
-
265
- it('should load with the correct context', function () {
266
- var inactive = jasmine.createSpy('inactive');
267
-
268
- font.load({
269
- test: {
270
- somedata: 'in french a cow says meuh'
271
- },
272
- inactive: inactive
273
- });
274
-
275
- expect(inactive).toHaveBeenCalled();
276
- expect(inactive.calls.length).toEqual(1);
277
- });
278
- });
279
-
280
157
  describe('module fails to load', function () {
281
158
  var font = null,
282
159
  testModule = null,
@@ -287,17 +164,12 @@ describe('WebFont', function () {
287
164
  inactive = jasmine.createSpy('inactive'),
288
165
  active = jasmine.createSpy('active');
289
166
 
290
- font = new WebFont(window, fontModuleLoader, userAgent);
167
+ font = new WebFont(window, fontModuleLoader);
291
168
 
292
169
  font.addModule('test', function (conf, domHelper) {
293
170
  testModule = new function () {};
294
- testModule.supportUserAgent = function (ua, support) {
295
- window.setTimeout(function () {
296
- support(false);
297
- }, 100);
298
- };
299
171
  testModule.load = function (onReady) {
300
- onReady();
172
+ onReady([]);
301
173
  };
302
174
 
303
175
  return testModule;
@@ -336,17 +208,12 @@ describe('WebFont', function () {
336
208
  active = jasmine.createSpy('active');
337
209
  loading = jasmine.createSpy('loading');
338
210
 
339
- font = new WebFont(window, fontModuleLoader, userAgent);
211
+ font = new WebFont(window, fontModuleLoader);
340
212
 
341
213
  font.addModule('test', function (conf, domHelper) {
342
214
  testModule = new function () {};
343
- testModule.supportUserAgent = function (ua, support) {
344
- window.setTimeout(function () {
345
- support(true);
346
- }, 100);
347
- };
348
215
  testModule.load = function (onReady) {
349
- onReady([]);
216
+ onReady([new Font('Elena')]);
350
217
  };
351
218
 
352
219
  return testModule;