webfontloader 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/webfontloader.rb +1 -1
- data/spec/core/domhelper_spec.js +246 -1
- data/spec/core/external_script.js +1 -0
- data/spec/core/fontwatcher_spec.js +11 -11
- data/spec/deps.js +9 -9
- data/spec/index.html +15 -15
- data/spec/{ascender/ascenderscript_spec.js → modules/ascender_spec.js} +17 -17
- data/spec/{custom/customcss_spec.js → modules/custom_spec.js} +3 -3
- data/spec/{fontdeck/fontdeckscript_spec.js → modules/fontdeck_spec.js} +6 -6
- data/spec/{google → modules/google}/fontapiparser_spec.js +2 -2
- data/spec/{google → modules/google}/fontapiurlbuilder_spec.js +2 -2
- data/spec/{google → modules/google}/googlefontapi_spec.js +2 -2
- data/spec/{google → modules/google}/lastresortwebkitfontwatchrunner_spec.js +2 -2
- data/spec/{monotype/monotypescript_spec.js → modules/monotype_spec.js} +5 -4
- data/spec/{typekit/typekitscript_spec.js → modules/typekit_spec.js} +6 -6
- data/src/core/domhelper.js +62 -1
- data/src/core/fontwatcher.js +1 -1
- data/src/core/webfont.js +2 -2
- data/src/modules.yml +9 -9
- data/src/{ascender/ascender_script.js → modules/ascender.js} +13 -13
- data/src/{custom/customcss.js → modules/custom.js} +8 -8
- data/src/{fontdeck/fontdeck_script.js → modules/fontdeck.js} +16 -17
- data/src/{google → modules/google}/fontapiparser.js +7 -7
- data/src/{google → modules/google}/fontapiurlbuilder.js +5 -5
- data/src/{google → modules/google}/googlefontapi.js +12 -12
- data/src/{google → modules/google}/lastresortwebkitfontwatchrunner.js +5 -5
- data/src/{monotype/monotype_script.js → modules/monotype.js} +16 -16
- data/src/{typekit/typekit_script.js → modules/typekit.js} +13 -13
- data/webfontloader.gemspec +21 -20
- metadata +23 -22
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
v1.4.5 (May 23, 2013)
|
2
|
+
* Move modules into their own namespace
|
3
|
+
* Add new methods into DomHelper and add specs for all DomHelper methods
|
4
|
+
* Rename watch method so as not to conflict with Firefox Object.prototype.watch
|
5
|
+
|
1
6
|
v1.4.4 (May 22, 2013)
|
2
7
|
* Change the UserAgent API so that it is backwards compatible with older Typekit kits.
|
3
8
|
|
data/lib/webfontloader.rb
CHANGED
data/spec/core/domhelper_spec.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
describe('DomHelper', function () {
|
2
|
-
var
|
2
|
+
var DomHelper = webfont.DomHelper,
|
3
|
+
domHelper = new DomHelper(window);
|
3
4
|
|
4
5
|
describe('#createElement', function () {
|
5
6
|
it('should create an element', function () {
|
@@ -155,4 +156,248 @@ describe('DomHelper', function () {
|
|
155
156
|
expect(div.style.top).toEqual('1px');
|
156
157
|
});
|
157
158
|
});
|
159
|
+
|
160
|
+
describe('#createStyle', function () {
|
161
|
+
var style = null;
|
162
|
+
|
163
|
+
beforeEach(function () {
|
164
|
+
style = domHelper.createStyle('font-size:300px;');
|
165
|
+
});
|
166
|
+
|
167
|
+
it('should create a style element', function () {
|
168
|
+
expect(style).not.toBeNull();
|
169
|
+
expect(style.nodeName).toEqual('STYLE');
|
170
|
+
});
|
171
|
+
|
172
|
+
it('should set the css content correctly', function () {
|
173
|
+
if (style.styleSheet) {
|
174
|
+
expect(style.styleSheet.cssText).toEqual('font-size:300px;');
|
175
|
+
} else {
|
176
|
+
expect(style.textContent).toEqual('font-size:300px;');
|
177
|
+
}
|
178
|
+
});
|
179
|
+
});
|
180
|
+
|
181
|
+
describe('#loadScript', function () {
|
182
|
+
it('should load the script', function () {
|
183
|
+
runs(function () {
|
184
|
+
domHelper.loadScript('core/external_script.js');
|
185
|
+
});
|
186
|
+
|
187
|
+
waitsFor(function () {
|
188
|
+
return window.EXTERNAL_SCRIPT_LOADED;
|
189
|
+
}, 'script was never inserted', 1000);
|
190
|
+
|
191
|
+
runs(function () {
|
192
|
+
expect(window.EXTERNAL_SCRIPT_LOADED).toBe(true);
|
193
|
+
});
|
194
|
+
});
|
195
|
+
|
196
|
+
it('should call the callback', function () {
|
197
|
+
var called = false;
|
198
|
+
|
199
|
+
runs(function () {
|
200
|
+
domHelper.loadScript('core/external_script.js', function () {
|
201
|
+
called = true;
|
202
|
+
});
|
203
|
+
});
|
204
|
+
|
205
|
+
waitsFor(function () {
|
206
|
+
return called;
|
207
|
+
}, 'callback was never called', 1000);
|
208
|
+
|
209
|
+
runs(function () {
|
210
|
+
expect(called).toBe(true);
|
211
|
+
});
|
212
|
+
});
|
213
|
+
});
|
214
|
+
|
215
|
+
describe('#getProtocol', function () {
|
216
|
+
it('should return http', function () {
|
217
|
+
var domHelper = new DomHelper({
|
218
|
+
location: {
|
219
|
+
protocol: 'http:'
|
220
|
+
}
|
221
|
+
});
|
222
|
+
|
223
|
+
expect(domHelper.getProtocol()).toEqual('http:');
|
224
|
+
});
|
225
|
+
|
226
|
+
it('should return https', function () {
|
227
|
+
var domHelper = new DomHelper({
|
228
|
+
location: {
|
229
|
+
protocol: 'https:'
|
230
|
+
}
|
231
|
+
});
|
232
|
+
|
233
|
+
expect(domHelper.getProtocol()).toEqual('https:');
|
234
|
+
});
|
235
|
+
|
236
|
+
it('should return the protocol from an iframe', function () {
|
237
|
+
var domHelper = new DomHelper({
|
238
|
+
location: {
|
239
|
+
protocol: 'https:'
|
240
|
+
}
|
241
|
+
}, {
|
242
|
+
location: {
|
243
|
+
protocol: 'http:'
|
244
|
+
}
|
245
|
+
});
|
246
|
+
|
247
|
+
expect(domHelper.getProtocol()).toEqual('http:');
|
248
|
+
});
|
249
|
+
|
250
|
+
it('should return the protocol from the main window if the iframe has no protocol', function () {
|
251
|
+
var domHelper = new DomHelper({
|
252
|
+
location: {
|
253
|
+
protocol: 'http:'
|
254
|
+
}
|
255
|
+
}, {
|
256
|
+
location: {
|
257
|
+
protocol: 'about:'
|
258
|
+
}
|
259
|
+
});
|
260
|
+
|
261
|
+
expect(domHelper.getProtocol()).toEqual('http:');
|
262
|
+
});
|
263
|
+
});
|
264
|
+
|
265
|
+
describe('#isHttps', function () {
|
266
|
+
it('should return true if the protocol is https', function () {
|
267
|
+
var domHelper = new DomHelper({
|
268
|
+
location: {
|
269
|
+
protocol: 'https:'
|
270
|
+
}
|
271
|
+
});
|
272
|
+
|
273
|
+
expect(domHelper.isHttps()).toBe(true);
|
274
|
+
});
|
275
|
+
|
276
|
+
it('should return false if the protocol is not https', function () {
|
277
|
+
var domHelper = new DomHelper({
|
278
|
+
location: {
|
279
|
+
protocol: 'http:'
|
280
|
+
}
|
281
|
+
});
|
282
|
+
|
283
|
+
expect(domHelper.isHttps()).toBe(false);
|
284
|
+
});
|
285
|
+
});
|
286
|
+
|
287
|
+
describe('#getHostname', function () {
|
288
|
+
it('should return the hostname', function () {
|
289
|
+
var domHelper = new DomHelper({
|
290
|
+
location: {
|
291
|
+
hostname: 'example.com'
|
292
|
+
}
|
293
|
+
});
|
294
|
+
|
295
|
+
expect(domHelper.getHostName()).toEqual('example.com');
|
296
|
+
});
|
297
|
+
|
298
|
+
it('should return the hostname from the iframe if present', function () {
|
299
|
+
var domHelper = new DomHelper({
|
300
|
+
location: {
|
301
|
+
hostname: 'example.com'
|
302
|
+
}
|
303
|
+
}, {
|
304
|
+
location: {
|
305
|
+
hostname: 'example.org'
|
306
|
+
}
|
307
|
+
});
|
308
|
+
|
309
|
+
expect(domHelper.getHostName()).toEqual('example.org');
|
310
|
+
});
|
311
|
+
});
|
312
|
+
|
313
|
+
describe('#insertInto', function () {
|
314
|
+
it('should insert an element', function () {
|
315
|
+
var a = domHelper.createElement('div');
|
316
|
+
|
317
|
+
var result = domHelper.insertInto('body', a);
|
318
|
+
|
319
|
+
expect(result).toBe(true);
|
320
|
+
expect(a.parentNode.nodeName).toEqual('BODY');
|
321
|
+
});
|
322
|
+
});
|
323
|
+
|
324
|
+
describe('#whenBodyExists', function () {
|
325
|
+
var domHelper = null,
|
326
|
+
callback = null;
|
327
|
+
|
328
|
+
beforeEach(function () {
|
329
|
+
domHelper = new DomHelper({
|
330
|
+
document: {}
|
331
|
+
});
|
332
|
+
|
333
|
+
callback = jasmine.createSpy('callback');
|
334
|
+
});
|
335
|
+
|
336
|
+
it('should wait until the body exists before calling the callback', function () {
|
337
|
+
runs(function () {
|
338
|
+
domHelper.whenBodyExists(callback);
|
339
|
+
});
|
340
|
+
|
341
|
+
waits(200);
|
342
|
+
|
343
|
+
runs(function () {
|
344
|
+
domHelper.document_.body = true;
|
345
|
+
});
|
346
|
+
|
347
|
+
waitsFor(function () {
|
348
|
+
return callback.wasCalled;
|
349
|
+
}, 'callback was never called', 100);
|
350
|
+
|
351
|
+
runs(function () {
|
352
|
+
expect(callback).toHaveBeenCalled();
|
353
|
+
});
|
354
|
+
});
|
355
|
+
|
356
|
+
it('should not call the callback if the body is not available', function () {
|
357
|
+
runs(function () {
|
358
|
+
domHelper.whenBodyExists(callback);
|
359
|
+
});
|
360
|
+
|
361
|
+
waits(100);
|
362
|
+
|
363
|
+
runs(function () {
|
364
|
+
expect(callback).not.toHaveBeenCalled();
|
365
|
+
});
|
366
|
+
});
|
367
|
+
});
|
368
|
+
|
369
|
+
describe('#removeElement', function () {
|
370
|
+
it('should remove an element', function () {
|
371
|
+
var a = domHelper.createElement('div'),
|
372
|
+
b = domHelper.createElement('div');
|
373
|
+
|
374
|
+
a.appendChild(b);
|
375
|
+
|
376
|
+
var result = domHelper.removeElement(b);
|
377
|
+
expect(result).toBe(true);
|
378
|
+
expect(b.parentNode).toEqual(null);
|
379
|
+
});
|
380
|
+
|
381
|
+
it('should return false when failing to remove an element', function () {
|
382
|
+
var a = domHelper.createElement('div');
|
383
|
+
|
384
|
+
var result = domHelper.removeElement(a);
|
385
|
+
|
386
|
+
expect(result).toBe(false);
|
387
|
+
});
|
388
|
+
});
|
389
|
+
|
390
|
+
describe('#getMainWindow', function () {
|
391
|
+
it('should return the main window', function () {
|
392
|
+
var domHelper = new DomHelper(1, 2);
|
393
|
+
expect(domHelper.getMainWindow()).toEqual(1);
|
394
|
+
});
|
395
|
+
});
|
396
|
+
|
397
|
+
describe('#getLoadWindow', function () {
|
398
|
+
it('should return the load window', function () {
|
399
|
+
var domHelper = new DomHelper(1, 2);
|
400
|
+
expect(domHelper.getLoadWindow()).toEqual(2);
|
401
|
+
});
|
402
|
+
});
|
158
403
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
window.EXTERNAL_SCRIPT_LOADED = true;
|
@@ -65,7 +65,7 @@ describe('FontWatcher', function () {
|
|
65
65
|
activeFonts = [];
|
66
66
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
67
67
|
|
68
|
-
fontWatcher.
|
68
|
+
fontWatcher.watchFonts([], {}, FakeFontWatchRunner, true);
|
69
69
|
expect(eventDispatcher.dispatchInactive).toHaveBeenCalled();
|
70
70
|
});
|
71
71
|
|
@@ -73,7 +73,7 @@ describe('FontWatcher', function () {
|
|
73
73
|
activeFonts = [];
|
74
74
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
75
75
|
|
76
|
-
fontWatcher.
|
76
|
+
fontWatcher.watchFonts([], {}, FakeFontWatchRunner, false);
|
77
77
|
expect(eventDispatcher.dispatchInactive).not.toHaveBeenCalled();
|
78
78
|
});
|
79
79
|
});
|
@@ -83,7 +83,7 @@ describe('FontWatcher', function () {
|
|
83
83
|
activeFonts = [font1];
|
84
84
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
85
85
|
|
86
|
-
fontWatcher.
|
86
|
+
fontWatcher.watchFonts([font1], {}, FakeFontWatchRunner, false);
|
87
87
|
expect(eventDispatcher.dispatchFontInactive).not.toHaveBeenCalled();
|
88
88
|
expect(eventDispatcher.dispatchActive).not.toHaveBeenCalled();
|
89
89
|
expect(eventDispatcher.dispatchInactive).not.toHaveBeenCalled();
|
@@ -95,7 +95,7 @@ describe('FontWatcher', function () {
|
|
95
95
|
activeFonts = [font1];
|
96
96
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
97
97
|
|
98
|
-
fontWatcher.
|
98
|
+
fontWatcher.watchFonts([font1], {}, FakeFontWatchRunner, true);
|
99
99
|
expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
|
100
100
|
expect(eventDispatcher.dispatchFontActive).toHaveBeenCalledWith(font1);
|
101
101
|
expect(eventDispatcher.dispatchFontInactive).not.toHaveBeenCalled();
|
@@ -109,7 +109,7 @@ describe('FontWatcher', function () {
|
|
109
109
|
activeFonts = [];
|
110
110
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
111
111
|
|
112
|
-
fontWatcher.
|
112
|
+
fontWatcher.watchFonts([font1], {}, FakeFontWatchRunner, true);
|
113
113
|
expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
|
114
114
|
expect(eventDispatcher.dispatchFontActive).not.toHaveBeenCalled();
|
115
115
|
expect(eventDispatcher.dispatchFontInactive).toHaveBeenCalledWith(font1);
|
@@ -123,7 +123,7 @@ describe('FontWatcher', function () {
|
|
123
123
|
activeFonts = [font1, font2, font3];
|
124
124
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
125
125
|
|
126
|
-
fontWatcher.
|
126
|
+
fontWatcher.watchFonts([font1, font2, font3], {}, FakeFontWatchRunner, true);
|
127
127
|
expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
|
128
128
|
expect(eventDispatcher.dispatchFontActive).toHaveBeenCalledWith(font1);
|
129
129
|
expect(eventDispatcher.dispatchFontInactive).not.toHaveBeenCalled();
|
@@ -137,7 +137,7 @@ describe('FontWatcher', function () {
|
|
137
137
|
activeFonts = [];
|
138
138
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
139
139
|
|
140
|
-
fontWatcher.
|
140
|
+
fontWatcher.watchFonts([font1, font2, font3], {}, FakeFontWatchRunner, true);
|
141
141
|
expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font1);
|
142
142
|
expect(eventDispatcher.dispatchFontActive).not.toHaveBeenCalled();
|
143
143
|
expect(eventDispatcher.dispatchFontInactive).toHaveBeenCalledWith(font1);
|
@@ -151,7 +151,7 @@ describe('FontWatcher', function () {
|
|
151
151
|
activeFonts = [font1, font3];
|
152
152
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
153
153
|
|
154
|
-
fontWatcher.
|
154
|
+
fontWatcher.watchFonts([font1, font2, font3], {}, FakeFontWatchRunner, true);
|
155
155
|
expect(eventDispatcher.dispatchFontLoading.callCount).toEqual(3);
|
156
156
|
expect(eventDispatcher.dispatchFontLoading.calls[0].args[0]).toEqual(font1);
|
157
157
|
expect(eventDispatcher.dispatchFontLoading.calls[1].args[0]).toEqual(font2);
|
@@ -180,7 +180,7 @@ describe('FontWatcher', function () {
|
|
180
180
|
activeFonts = [font5, font6];
|
181
181
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
182
182
|
|
183
|
-
fontWatcher.
|
183
|
+
fontWatcher.watchFonts([font5, font6, font7, font8, font9], {}, FakeFontWatchRunner, true);
|
184
184
|
|
185
185
|
expect(eventDispatcher.dispatchFontLoading.callCount).toEqual(5);
|
186
186
|
expect(eventDispatcher.dispatchFontLoading).toHaveBeenCalledWith(font5);
|
@@ -209,7 +209,7 @@ describe('FontWatcher', function () {
|
|
209
209
|
|
210
210
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher);
|
211
211
|
|
212
|
-
fontWatcher.
|
212
|
+
fontWatcher.watchFonts([font1, font2, font3, font4], {
|
213
213
|
'font1': 'testString1',
|
214
214
|
'font2': null,
|
215
215
|
'font3': 'testString2',
|
@@ -225,7 +225,7 @@ describe('FontWatcher', function () {
|
|
225
225
|
it('should pass on the timeout to FontWatchRunner', function () {
|
226
226
|
var fontWatcher = new FontWatcher(userAgent, domHelper, eventDispatcher, 4000);
|
227
227
|
|
228
|
-
fontWatcher.
|
228
|
+
fontWatcher.watchFonts([font1], {}, FakeFontWatchRunner, true);
|
229
229
|
|
230
230
|
expect(timeout).toHaveBeenCalledWith(4000);
|
231
231
|
});
|
data/spec/deps.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
// This file was autogenerated by calcdeps.js
|
2
|
-
goog.addDependency("../../src/ascender/ascender_script.js", ["webfont.AscenderScript"], ["webfont.Font"]);
|
3
2
|
goog.addDependency("../../src/async_load.js", [], []);
|
4
3
|
goog.addDependency("../../src/closure.js", [], []);
|
5
4
|
goog.addDependency("../../src/core/browserinfo.js", ["webfont.BrowserInfo"], []);
|
@@ -17,11 +16,12 @@ goog.addDependency("../../src/core/useragent.js", ["webfont.UserAgent"], []);
|
|
17
16
|
goog.addDependency("../../src/core/useragentparser.js", ["webfont.UserAgentParser"], ["webfont.BrowserInfo","webfont.UserAgent","webfont.Version"]);
|
18
17
|
goog.addDependency("../../src/core/version.js", ["webfont.Version"], []);
|
19
18
|
goog.addDependency("../../src/core/webfont.js", ["webfont.WebFont"], ["webfont.DomHelper","webfont.EventDispatcher","webfont.FontWatcher"]);
|
20
|
-
goog.addDependency("../../src/
|
21
|
-
goog.addDependency("../../src/
|
22
|
-
goog.addDependency("../../src/
|
23
|
-
goog.addDependency("../../src/google/
|
24
|
-
goog.addDependency("../../src/google/
|
25
|
-
goog.addDependency("../../src/google/
|
26
|
-
goog.addDependency("../../src/
|
27
|
-
goog.addDependency("../../src/
|
19
|
+
goog.addDependency("../../src/modules/ascender.js", ["webfont.modules.Ascender"], ["webfont.Font"]);
|
20
|
+
goog.addDependency("../../src/modules/custom.js", ["webfont.modules.Custom"], ["webfont.Font"]);
|
21
|
+
goog.addDependency("../../src/modules/fontdeck.js", ["webfont.modules.Fontdeck"], ["webfont.Font"]);
|
22
|
+
goog.addDependency("../../src/modules/google/fontapiparser.js", ["webfont.modules.FontApiParser"], ["webfont.Font"]);
|
23
|
+
goog.addDependency("../../src/modules/google/fontapiurlbuilder.js", ["webfont.modules.FontApiUrlBuilder"], []);
|
24
|
+
goog.addDependency("../../src/modules/google/googlefontapi.js", ["webfont.modules.GoogleFontApi"], ["webfont.modules.FontApiUrlBuilder","webfont.modules.FontApiParser","webfont.FontWatchRunner","webfont.modules.LastResortWebKitFontWatchRunner"]);
|
25
|
+
goog.addDependency("../../src/modules/google/lastresortwebkitfontwatchrunner.js", ["webfont.modules.LastResortWebKitFontWatchRunner"], ["webfont.Font","webfont.FontRuler"]);
|
26
|
+
goog.addDependency("../../src/modules/monotype.js", ["webfont.modules.Monotype"], ["webfont.Font"]);
|
27
|
+
goog.addDependency("../../src/modules/typekit.js", ["webfont.modules.Typekit"], ["webfont.Font"]);
|
data/spec/index.html
CHANGED
@@ -25,12 +25,12 @@
|
|
25
25
|
|
26
26
|
// Require the modules because they don't have an explicit
|
27
27
|
// dependency on core.
|
28
|
-
goog.require('webfont.
|
29
|
-
goog.require('webfont.
|
30
|
-
goog.require('webfont.
|
31
|
-
goog.require('webfont.
|
32
|
-
goog.require('webfont.
|
33
|
-
goog.require('webfont.GoogleFontApi');
|
28
|
+
goog.require('webfont.modules.Typekit');
|
29
|
+
goog.require('webfont.modules.Ascender');
|
30
|
+
goog.require('webfont.modules.Fontdeck');
|
31
|
+
goog.require('webfont.modules.Monotype');
|
32
|
+
goog.require('webfont.modules.Custom');
|
33
|
+
goog.require('webfont.modules.GoogleFontApi');
|
34
34
|
</script>
|
35
35
|
|
36
36
|
<script src="../spec/core/domhelper_spec.js"></script>
|
@@ -44,15 +44,15 @@
|
|
44
44
|
<script src="../spec/core/fontwatcher_spec.js"></script>
|
45
45
|
<script src="../spec/core/webfont_spec.js"></script>
|
46
46
|
<script src="../spec/core/version_spec.js"></script>
|
47
|
-
<script src="../spec/google/fontapiparser_spec.js"></script>
|
48
|
-
<script src="../spec/google/fontapiurlbuilder_spec.js"></script>
|
49
|
-
<script src="../spec/google/googlefontapi_spec.js"></script>
|
50
|
-
<script src="../spec/google/lastresortwebkitfontwatchrunner_spec.js"></script>
|
51
|
-
<script src="../spec/
|
52
|
-
<script src="../spec/
|
53
|
-
<script src="../spec/
|
54
|
-
<script src="../spec/
|
55
|
-
<script src="../spec/
|
47
|
+
<script src="../spec/modules/google/fontapiparser_spec.js"></script>
|
48
|
+
<script src="../spec/modules/google/fontapiurlbuilder_spec.js"></script>
|
49
|
+
<script src="../spec/modules/google/googlefontapi_spec.js"></script>
|
50
|
+
<script src="../spec/modules/google/lastresortwebkitfontwatchrunner_spec.js"></script>
|
51
|
+
<script src="../spec/modules/custom_spec.js"></script>
|
52
|
+
<script src="../spec/modules/ascender_spec.js"></script>
|
53
|
+
<script src="../spec/modules/fontdeck_spec.js"></script>
|
54
|
+
<script src="../spec/modules/monotype_spec.js"></script>
|
55
|
+
<script src="../spec/modules/typekit_spec.js"></script>
|
56
56
|
|
57
57
|
<script>
|
58
58
|
(function () {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
var
|
1
|
+
describe('modules.Ascender', function () {
|
2
|
+
var Ascender = webfont.modules.Ascender,
|
3
3
|
Font = webfont.Font;
|
4
4
|
|
5
5
|
var configuration = {
|
@@ -10,7 +10,7 @@ describe('AscenderScript', function () {
|
|
10
10
|
describe('load family and variations', function () {
|
11
11
|
var fakeDomHelper = null,
|
12
12
|
fakeOnReady = null,
|
13
|
-
|
13
|
+
ascender = null;
|
14
14
|
|
15
15
|
beforeEach(function () {
|
16
16
|
fakeDomHelper = {
|
@@ -21,8 +21,8 @@ describe('AscenderScript', function () {
|
|
21
21
|
|
22
22
|
fakeOnReady = jasmine.createSpy('onReady');
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
ascender = new Ascender(fakeDomHelper, configuration);
|
25
|
+
ascender.load(fakeOnReady);
|
26
26
|
});
|
27
27
|
|
28
28
|
it('should create the link correctly', function () {
|
@@ -39,24 +39,24 @@ describe('AscenderScript', function () {
|
|
39
39
|
});
|
40
40
|
|
41
41
|
it('should parse variations correctly', function () {
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
45
|
-
expect(
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
49
|
-
expect(
|
42
|
+
expect(ascender.parseVariations('regular')).toEqual(['n4']);
|
43
|
+
expect(ascender.parseVariations('bold')).toEqual(['n7']);
|
44
|
+
expect(ascender.parseVariations('italic')).toEqual(['i4']);
|
45
|
+
expect(ascender.parseVariations('bolditalic')).toEqual(['i7']);
|
46
|
+
expect(ascender.parseVariations('regular,')).toEqual(['n4']);
|
47
|
+
expect(ascender.parseVariations('regular,bold')).toEqual(['n4', 'n7']);
|
48
|
+
expect(ascender.parseVariations('regular,,bold')).toEqual(['n4', 'n7']);
|
49
|
+
expect(ascender.parseVariations('n4,n7')).toEqual(['n4', 'n7']);
|
50
50
|
});
|
51
51
|
|
52
52
|
it('should parse font families correctly', function () {
|
53
|
-
expect(
|
54
|
-
expect(
|
55
|
-
expect(
|
53
|
+
expect(ascender.parseFamilyAndVariations('Arial')).toEqual([new Font('Arial')]);
|
54
|
+
expect(ascender.parseFamilyAndVariations('Arial:bold,regular')).toEqual([new Font('Arial', 'n7'), new Font('Arial', 'n4')]);
|
55
|
+
expect(ascender.parseFamilyAndVariations('Arial:n4,n7')).toEqual([new Font('Arial', 'n4'), new Font('Arial', 'n7')]);
|
56
56
|
});
|
57
57
|
|
58
58
|
it('should parse multiple font families correctly', function () {
|
59
|
-
expect(
|
59
|
+
expect(ascender.parseFamiliesAndVariations(['Arial', 'Sans:n4,n7'])).toEqual([
|
60
60
|
new Font('Arial', 'n4'),
|
61
61
|
new Font('Sans', 'n4'),
|
62
62
|
new Font('Sans', 'n7')
|