webfontloader 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/Gemfile +2 -8
- data/README.md +31 -32
- data/Rakefile +2 -33
- data/docs/EVENTS.md +10 -1
- data/docs/MODULES.md +4 -3
- data/lib/webfontloader.rb +1 -1
- data/spec/ascender/ascenderscript_spec.js +43 -0
- data/spec/core/cssclassname_spec.js +42 -0
- data/spec/core/cssfontfamilyname_spec.js +38 -0
- data/spec/core/domhelper_spec.js +158 -0
- data/spec/core/eventdispatcher_spec.js +209 -0
- data/spec/core/font_spec.js +218 -0
- data/spec/core/fontmoduleloader_spec.js +55 -0
- data/spec/core/fontruler_spec.js +33 -0
- data/spec/core/fontvariationdescription_spec.js +67 -0
- data/spec/core/fontwatcher_spec.js +204 -0
- data/spec/core/fontwatchrunner_spec.js +398 -0
- data/spec/core/size_spec.js +17 -0
- data/spec/core/useragentparser_spec.js +921 -0
- data/spec/custom/customcss_spec.js +36 -0
- data/spec/fontdeck/fontdeckscript_spec.js +111 -0
- data/spec/fonts/LICENSE.txt +93 -0
- data/spec/fonts/nullfont.css +1 -0
- data/spec/fonts/nullfont1.css +1 -0
- data/spec/fonts/nullfont2.css +1 -0
- data/spec/fonts/nullfont3.css +1 -0
- data/spec/fonts/sourcesans.eot +0 -0
- data/spec/fonts/sourcesans.otf +0 -0
- data/spec/fonts/sourcesans.svg +2523 -0
- data/spec/fonts/sourcesans.ttf +0 -0
- data/spec/fonts/sourcesans.woff +0 -0
- data/spec/fonts/sourcesansa.css +1 -0
- data/spec/fonts/sourcesansb.css +1 -0
- data/spec/google/fontapiparser_spec.js +348 -0
- data/spec/google/fontapiurlbuilder_spec.js +40 -0
- data/spec/google/googlefontapi_spec.js +123 -0
- data/spec/google/lastresortwebkitfontwatchrunner_spec.js +145 -0
- data/spec/index.html +95 -0
- data/spec/monotype/monotypescript_spec.js +49 -0
- data/spec/typekit/typekitscript_spec.js +93 -0
- data/src/core/domhelper.js +6 -3
- data/src/core/fontruler.js +1 -1
- data/src/core/fontwatcher.js +5 -0
- data/src/core/fontwatchrunner.js +7 -4
- data/src/monotype/monotype_script.js +4 -3
- data/tools/jasmine-phantomjs/jasmine-phantomjs.js +26 -0
- data/tools/jasmine-phantomjs/terminal-reporter.js +177 -0
- data/tools/jasmine/MIT.LICENSE +20 -0
- data/tools/jasmine/jasmine-html.js +681 -0
- data/tools/jasmine/jasmine.css +82 -0
- data/tools/jasmine/jasmine.js +2600 -0
- data/webfontloader.gemspec +46 -25
- metadata +77 -42
- data/src-test/ascender/ascender_script_test.js +0 -51
- data/src-test/core/cssclassnametest.js +0 -42
- data/src-test/core/cssfontfamilynametest.js +0 -54
- data/src-test/core/domhelpertest.js +0 -151
- data/src-test/core/eventdispatchertest.js +0 -275
- data/src-test/core/fontmoduleloadertest.js +0 -30
- data/src-test/core/fonttest.js +0 -121
- data/src-test/core/fontvariationdescriptiontest.js +0 -76
- data/src-test/core/fontwatchertest.js +0 -287
- data/src-test/core/fontwatchrunnertest.js +0 -454
- data/src-test/core/useragenttest.js +0 -755
- data/src-test/custom/customcsstest.js +0 -35
- data/src-test/fontdeck/fontdeck_script_test.js +0 -116
- data/src-test/google/fontapiparsertest.js +0 -252
- data/src-test/google/fontapiurlbuildertest.js +0 -71
- data/src-test/google/googlefontapitest.js +0 -185
- data/src-test/google/lastresortwebkitfontwatchrunnertest.js +0 -204
- data/src-test/monotype/monotype_script_test.js +0 -304
- data/src-test/typekit/typekit_script_test.js +0 -195
- data/tools/jstestdriver/JsTestDriver-1.2.1.jar +0 -0
@@ -1,275 +0,0 @@
|
|
1
|
-
var EventDispatcherTest = TestCase('EventDispatcherTest');
|
2
|
-
|
3
|
-
EventDispatcherTest.prototype.setUp = function() {
|
4
|
-
this.fakeHtmlElement_ = { className: '' };
|
5
|
-
this.loadingEventCalled_ = false;
|
6
|
-
this.fontLoadingEventCalled_ = false;
|
7
|
-
this.fontLoading_ = '';
|
8
|
-
this.fontActiveEventCalled_ = false;
|
9
|
-
this.fontActive_ = '';
|
10
|
-
this.fontInactiveEventCalled_ = false;
|
11
|
-
this.fontInactive_ = '';
|
12
|
-
this.activeEventCalled_ = false;
|
13
|
-
this.inactiveEventCalled_ = false;
|
14
|
-
var namespace = 'ns';
|
15
|
-
var self = this;
|
16
|
-
|
17
|
-
this.eventDispatcher_ = new webfont.EventDispatcher(new webfont.DomHelper(
|
18
|
-
window), this.fakeHtmlElement_, {
|
19
|
-
loading: function() {
|
20
|
-
self.loadingEventCalled_ = true;
|
21
|
-
},
|
22
|
-
active: function() {
|
23
|
-
self.activeEventCalled_ = true;
|
24
|
-
},
|
25
|
-
inactive: function() {
|
26
|
-
self.inactiveEventCalled_ = true;
|
27
|
-
},
|
28
|
-
fontloading: function(fontFamily, fontDescription) {
|
29
|
-
self.fontLoadingEventCalled_ = true;
|
30
|
-
self.fontLoading_ = fontFamily + ' ' + fontDescription;
|
31
|
-
},
|
32
|
-
fontactive: function(fontFamily, fontDescription) {
|
33
|
-
self.fontActiveEventCalled_ = true;
|
34
|
-
self.fontActive_ = fontFamily + ' ' + fontDescription;
|
35
|
-
},
|
36
|
-
fontinactive: function(fontFamily, fontDescription) {
|
37
|
-
self.fontInactiveEventCalled_ = true;
|
38
|
-
self.fontInactive_ = fontFamily + ' ' + fontDescription;
|
39
|
-
}
|
40
|
-
}, namespace);
|
41
|
-
};
|
42
|
-
|
43
|
-
EventDispatcherTest.prototype.testClassNamesOnActiveLoad = function() {
|
44
|
-
this.eventDispatcher_.dispatchLoading();
|
45
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
46
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
47
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
48
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
49
|
-
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
50
|
-
this.eventDispatcher_.dispatchActive();
|
51
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
52
|
-
};
|
53
|
-
|
54
|
-
EventDispatcherTest.prototype.testEventsOnActiveLoad = function() {
|
55
|
-
this.eventDispatcher_.dispatchLoading();
|
56
|
-
assertTrue(this.loadingEventCalled_);
|
57
|
-
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
|
58
|
-
assertTrue(this.fontLoadingEventCalled_);
|
59
|
-
assertEquals('fontFamilyLoading n4', this.fontLoading_);
|
60
|
-
this.eventDispatcher_.dispatchFontActive('fontFamilyActive', 'n4');
|
61
|
-
assertTrue(this.fontActiveEventCalled_);
|
62
|
-
assertEquals('fontFamilyActive n4', this.fontActive_);
|
63
|
-
this.eventDispatcher_.dispatchActive();
|
64
|
-
assertTrue(this.activeEventCalled_);
|
65
|
-
};
|
66
|
-
|
67
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveFontButActive = function() {
|
68
|
-
this.eventDispatcher_.dispatchLoading();
|
69
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
70
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
71
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
72
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
73
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
74
|
-
this.eventDispatcher_.dispatchActive();
|
75
|
-
assertEquals('ns-myfamily-n4-inactive ns-active', this.fakeHtmlElement_.className);
|
76
|
-
};
|
77
|
-
|
78
|
-
EventDispatcherTest.prototype.testEventsOnInactiveFontButActive = function() {
|
79
|
-
this.eventDispatcher_.dispatchLoading();
|
80
|
-
assertTrue(this.loadingEventCalled_);
|
81
|
-
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
|
82
|
-
assertTrue(this.fontLoadingEventCalled_);
|
83
|
-
assertEquals('fontFamilyLoading n4', this.fontLoading_);
|
84
|
-
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
|
85
|
-
assertTrue(this.fontInactiveEventCalled_);
|
86
|
-
assertEquals('fontFamilyInactive n4', this.fontInactive_);
|
87
|
-
this.eventDispatcher_.dispatchActive();
|
88
|
-
assertTrue(this.activeEventCalled_);
|
89
|
-
};
|
90
|
-
|
91
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveLoad = function() {
|
92
|
-
this.eventDispatcher_.dispatchLoading();
|
93
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
94
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
95
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
96
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
97
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
98
|
-
this.eventDispatcher_.dispatchInactive();
|
99
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
100
|
-
};
|
101
|
-
|
102
|
-
EventDispatcherTest.prototype.testEventsOnInactiveLoad = function() {
|
103
|
-
this.eventDispatcher_.dispatchLoading();
|
104
|
-
assertTrue(this.loadingEventCalled_);
|
105
|
-
this.eventDispatcher_.dispatchFontLoading('fontFamilyLoading', 'n4');
|
106
|
-
assertTrue(this.fontLoadingEventCalled_);
|
107
|
-
assertEquals('fontFamilyLoading n4', this.fontLoading_);
|
108
|
-
this.eventDispatcher_.dispatchFontInactive('fontFamilyInactive', 'n4');
|
109
|
-
assertTrue(this.fontInactiveEventCalled_);
|
110
|
-
assertEquals('fontFamilyInactive n4', this.fontInactive_);
|
111
|
-
this.eventDispatcher_.dispatchInactive();
|
112
|
-
assertTrue(this.inactiveEventCalled_);
|
113
|
-
};
|
114
|
-
|
115
|
-
EventDispatcherTest.prototype.testClassNamesOnInactive = function() {
|
116
|
-
this.eventDispatcher_.dispatchInactive();
|
117
|
-
assertEquals('ns-inactive', this.fakeHtmlElement_.className);
|
118
|
-
};
|
119
|
-
|
120
|
-
EventDispatcherTest.prototype.testEventsOnInactive = function() {
|
121
|
-
this.eventDispatcher_.dispatchInactive();
|
122
|
-
assertTrue(this.inactiveEventCalled_);
|
123
|
-
};
|
124
|
-
|
125
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveThenActiveLoad = function() {
|
126
|
-
this.eventDispatcher_.dispatchLoading();
|
127
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
128
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
129
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
130
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
131
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
132
|
-
this.eventDispatcher_.dispatchInactive();
|
133
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
134
|
-
this.eventDispatcher_.dispatchLoading();
|
135
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
|
136
|
-
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
|
137
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
|
138
|
-
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
|
139
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
|
140
|
-
this.eventDispatcher_.dispatchActive();
|
141
|
-
assertEquals('ns-myfamily-n4-inactive ns-myfamily2-n4-active ns-active', this.fakeHtmlElement_.className);
|
142
|
-
};
|
143
|
-
|
144
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveThenActiveLoadSameFont = function() {
|
145
|
-
this.eventDispatcher_.dispatchLoading();
|
146
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
147
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
148
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
149
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
150
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
151
|
-
this.eventDispatcher_.dispatchInactive();
|
152
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
153
|
-
this.eventDispatcher_.dispatchLoading();
|
154
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
|
155
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
156
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
157
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
158
|
-
assertEquals('ns-inactive ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
159
|
-
this.eventDispatcher_.dispatchActive();
|
160
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
161
|
-
};
|
162
|
-
|
163
|
-
EventDispatcherTest.prototype.testClassNamesOnActiveThenInactiveLoad = function() {
|
164
|
-
this.eventDispatcher_.dispatchLoading();
|
165
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
166
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
167
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
168
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
169
|
-
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
170
|
-
this.eventDispatcher_.dispatchActive();
|
171
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
172
|
-
this.eventDispatcher_.dispatchLoading();
|
173
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
174
|
-
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
|
175
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
|
176
|
-
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
|
177
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
|
178
|
-
this.eventDispatcher_.dispatchInactive();
|
179
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
|
180
|
-
};
|
181
|
-
|
182
|
-
EventDispatcherTest.prototype.testClassNamesOnActiveThenInactiveLoadSameFont = function() {
|
183
|
-
this.eventDispatcher_.dispatchLoading();
|
184
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
185
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
186
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
187
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
188
|
-
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
189
|
-
this.eventDispatcher_.dispatchActive();
|
190
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
191
|
-
this.eventDispatcher_.dispatchLoading();
|
192
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
193
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
194
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
195
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
196
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
197
|
-
this.eventDispatcher_.dispatchInactive();
|
198
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
199
|
-
};
|
200
|
-
|
201
|
-
EventDispatcherTest.prototype.testClassNamesOnActiveThenActiveLoad = function() {
|
202
|
-
this.eventDispatcher_.dispatchLoading();
|
203
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
204
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
205
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
206
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
207
|
-
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
208
|
-
this.eventDispatcher_.dispatchActive();
|
209
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
210
|
-
this.eventDispatcher_.dispatchLoading();
|
211
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
212
|
-
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
|
213
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
|
214
|
-
this.eventDispatcher_.dispatchFontActive('My Family 2', 'n4');
|
215
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
|
216
|
-
this.eventDispatcher_.dispatchActive();
|
217
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-myfamily2-n4-active', this.fakeHtmlElement_.className);
|
218
|
-
};
|
219
|
-
|
220
|
-
EventDispatcherTest.prototype.testClassNamesOnActiveThenActiveLoadSameFont = function() {
|
221
|
-
this.eventDispatcher_.dispatchLoading();
|
222
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
223
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
224
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
225
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
226
|
-
assertEquals('ns-loading ns-myfamily-n4-active', this.fakeHtmlElement_.className);
|
227
|
-
this.eventDispatcher_.dispatchActive();
|
228
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
229
|
-
this.eventDispatcher_.dispatchLoading();
|
230
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
231
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
232
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
233
|
-
this.eventDispatcher_.dispatchFontActive('My Family', 'n4');
|
234
|
-
assertEquals('ns-myfamily-n4-active ns-active ns-loading', this.fakeHtmlElement_.className);
|
235
|
-
this.eventDispatcher_.dispatchActive();
|
236
|
-
assertEquals('ns-myfamily-n4-active ns-active', this.fakeHtmlElement_.className);
|
237
|
-
};
|
238
|
-
|
239
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveThenInactiveLoad = function() {
|
240
|
-
this.eventDispatcher_.dispatchLoading();
|
241
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
242
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
243
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
244
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
245
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
246
|
-
this.eventDispatcher_.dispatchInactive();
|
247
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
248
|
-
this.eventDispatcher_.dispatchLoading();
|
249
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
|
250
|
-
this.eventDispatcher_.dispatchFontLoading('My Family 2', 'n4');
|
251
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-loading', this.fakeHtmlElement_.className);
|
252
|
-
this.eventDispatcher_.dispatchFontInactive('My Family 2', 'n4');
|
253
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
|
254
|
-
this.eventDispatcher_.dispatchInactive();
|
255
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-myfamily2-n4-inactive', this.fakeHtmlElement_.className);
|
256
|
-
};
|
257
|
-
|
258
|
-
EventDispatcherTest.prototype.testClassNamesOnInactiveThenInactiveLoadSameFont = function() {
|
259
|
-
this.eventDispatcher_.dispatchLoading();
|
260
|
-
assertEquals('ns-loading', this.fakeHtmlElement_.className);
|
261
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
262
|
-
assertEquals('ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
263
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
264
|
-
assertEquals('ns-loading ns-myfamily-n4-inactive', this.fakeHtmlElement_.className);
|
265
|
-
this.eventDispatcher_.dispatchInactive();
|
266
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
267
|
-
this.eventDispatcher_.dispatchLoading();
|
268
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
|
269
|
-
this.eventDispatcher_.dispatchFontLoading('My Family', 'n4');
|
270
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading ns-myfamily-n4-loading', this.fakeHtmlElement_.className);
|
271
|
-
this.eventDispatcher_.dispatchFontInactive('My Family', 'n4');
|
272
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive ns-loading', this.fakeHtmlElement_.className);
|
273
|
-
this.eventDispatcher_.dispatchInactive();
|
274
|
-
assertEquals('ns-myfamily-n4-inactive ns-inactive', this.fakeHtmlElement_.className);
|
275
|
-
};
|
@@ -1,30 +0,0 @@
|
|
1
|
-
var FontModuleLoaderTest = TestCase('FontModuleLoaderTest');
|
2
|
-
|
3
|
-
FontModuleLoaderTest.prototype.testGetProperModuleList = function() {
|
4
|
-
var fontModuleLoader = new webfont.FontModuleLoader();
|
5
|
-
|
6
|
-
fontModuleLoader.addModuleFactory('booh', function() { return { scary: true }; });
|
7
|
-
fontModuleLoader.addModuleFactory('haha', function() { return { funny: true }; });
|
8
|
-
fontModuleLoader.addModuleFactory('moo', function() { return { cowy: true }; });
|
9
|
-
var modules = fontModuleLoader.getModules({ booh: {}, moo: {}, nothing: {} });
|
10
|
-
|
11
|
-
assertNotNull(modules);
|
12
|
-
assertEquals(2, modules.length);
|
13
|
-
var module1 = modules[0];
|
14
|
-
|
15
|
-
assertNotNull(module1);
|
16
|
-
assertTrue(module1.scary || module1.cowy);
|
17
|
-
var module2 = modules[1];
|
18
|
-
|
19
|
-
assertNotNull(module2);
|
20
|
-
assertTrue(module2.scary || module2.cowy);
|
21
|
-
};
|
22
|
-
|
23
|
-
FontModuleLoaderTest.prototype.testNotModuleShouldHaveEmptyModuleList =
|
24
|
-
function() {
|
25
|
-
var fontModuleLoader = new webfont.FontModuleLoader();
|
26
|
-
var modules = fontModuleLoader.getModules();
|
27
|
-
|
28
|
-
assertNotNull(modules);
|
29
|
-
assertEquals(0, modules.length);
|
30
|
-
};
|
data/src-test/core/fonttest.js
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
var FontTest = TestCase('FontTest');
|
2
|
-
|
3
|
-
FontTest.prototype.setUp = function() {
|
4
|
-
this.fontModuleLoader_ = new webfont.FontModuleLoader();
|
5
|
-
};
|
6
|
-
|
7
|
-
FontTest.prototype.testFontLoad = function() {
|
8
|
-
var browserInfo = new webfont.BrowserInfo(true, false);
|
9
|
-
var userAgent = new webfont.UserAgent('Firefox', '3.6', 'Gecko', '1.9.2',
|
10
|
-
'Macintosh', '10.6', undefined, browserInfo);
|
11
|
-
var font = new webfont.WebFont(window, this.fontModuleLoader_,
|
12
|
-
function(func, timeout) { func(); }, userAgent);
|
13
|
-
var testModule = null;
|
14
|
-
|
15
|
-
font.addModule('test', function(conf, domHelper) {
|
16
|
-
testModule = new function() {
|
17
|
-
this.conf = conf;
|
18
|
-
this.domHelper = domHelper;
|
19
|
-
this.loadCalled = false;
|
20
|
-
this.supportUserAgentCalled = false;
|
21
|
-
};
|
22
|
-
testModule.load = function(onReady) {
|
23
|
-
this.loadCalled = true;
|
24
|
-
onReady([]);
|
25
|
-
};
|
26
|
-
testModule.supportUserAgent = function(ua, support) {
|
27
|
-
this.supportUserAgentCalled = true;
|
28
|
-
support(true);
|
29
|
-
};
|
30
|
-
return testModule;
|
31
|
-
});
|
32
|
-
|
33
|
-
assertEquals(0, font.moduleFailedLoading_);
|
34
|
-
assertEquals(0, font.moduleLoading_);
|
35
|
-
|
36
|
-
var loadingEventCalled = false;
|
37
|
-
font.load({
|
38
|
-
test: {
|
39
|
-
somedata: 'in french a cow says meuh'
|
40
|
-
},
|
41
|
-
loading: function() {
|
42
|
-
loadingEventCalled = true;
|
43
|
-
}
|
44
|
-
});
|
45
|
-
|
46
|
-
assertEquals(1, font.moduleFailedLoading_);
|
47
|
-
assertEquals(0, font.moduleLoading_);
|
48
|
-
assertNotNull(testModule);
|
49
|
-
assertNotUndefined(testModule.conf);
|
50
|
-
assertNotNull(testModule.conf);
|
51
|
-
assertNotUndefined(testModule.domHelper);
|
52
|
-
assertNotNull(testModule.domHelper);
|
53
|
-
assertSame(window, testModule.domHelper.getMainWindow());
|
54
|
-
assertSame(window, testModule.domHelper.getLoadWindow());
|
55
|
-
assertEquals('in french a cow says meuh', testModule.conf.somedata);
|
56
|
-
assertTrue(testModule.loadCalled);
|
57
|
-
assertTrue(testModule.supportUserAgentCalled);
|
58
|
-
assertTrue(loadingEventCalled);
|
59
|
-
};
|
60
|
-
|
61
|
-
FontTest.prototype.testFontLoadWithContext = function() {
|
62
|
-
var fakeMainWindow = {};
|
63
|
-
var browserInfo = new webfont.BrowserInfo(true, false);
|
64
|
-
var userAgent = new webfont.UserAgent('Firefox', '3.6', 'Gecko', '1.9.2',
|
65
|
-
'Macintosh', '10.6', undefined, browserInfo);
|
66
|
-
var font = new webfont.WebFont(fakeMainWindow, this.fontModuleLoader_,
|
67
|
-
function(func, timeout) { func(); }, userAgent);
|
68
|
-
var testModule = null;
|
69
|
-
|
70
|
-
font.addModule('test', function(conf, domHelper) {
|
71
|
-
testModule = new function() {
|
72
|
-
this.domHelper = domHelper;
|
73
|
-
};
|
74
|
-
testModule.load = function() {};
|
75
|
-
testModule.supportUserAgent = function(ua, support) {
|
76
|
-
support(true);
|
77
|
-
};
|
78
|
-
return testModule;
|
79
|
-
});
|
80
|
-
|
81
|
-
font.load({
|
82
|
-
test: {
|
83
|
-
somedata: 'in french a cow says meuh'
|
84
|
-
},
|
85
|
-
context: window
|
86
|
-
});
|
87
|
-
|
88
|
-
assertNotUndefined(testModule.domHelper);
|
89
|
-
assertNotNull(testModule.domHelper);
|
90
|
-
assertSame(fakeMainWindow, testModule.domHelper.getMainWindow());
|
91
|
-
assertSame(window, testModule.domHelper.getLoadWindow());
|
92
|
-
};
|
93
|
-
|
94
|
-
FontTest.prototype.testFontInactive = function() {
|
95
|
-
var userAgent = new webfont.UserAgent('Firefox', '3.0', 'Gecko', '1.9.2',
|
96
|
-
'Macintosh', '10.6', undefined, new webfont.BrowserInfo(false, false));
|
97
|
-
var font = new webfont.WebFont(window, this.fontModuleLoader_,
|
98
|
-
function(func, timeout) { func(); }, userAgent);
|
99
|
-
var testModule;
|
100
|
-
|
101
|
-
font.addModule('test', function(conf) {
|
102
|
-
testModule = new function() {
|
103
|
-
this.conf = conf;
|
104
|
-
this.loadCalled = false;
|
105
|
-
};
|
106
|
-
testModule.load = function(onReady) { };
|
107
|
-
return testModule;
|
108
|
-
});
|
109
|
-
var onInactiveCalled = false;
|
110
|
-
|
111
|
-
font.load({
|
112
|
-
test: {
|
113
|
-
somedata: 'in french a cow says meuh'
|
114
|
-
},
|
115
|
-
inactive: function() {
|
116
|
-
onInactiveCalled = true;
|
117
|
-
}
|
118
|
-
});
|
119
|
-
assertUndefined(testModule);
|
120
|
-
assertTrue(onInactiveCalled);
|
121
|
-
};
|
@@ -1,76 +0,0 @@
|
|
1
|
-
var FontVariationDescriptionTest = TestCase('FontVariationDescription');
|
2
|
-
|
3
|
-
FontVariationDescriptionTest.prototype.setUp = function() {
|
4
|
-
this.fvd_ = new webfont.FontVariationDescription();
|
5
|
-
};
|
6
|
-
|
7
|
-
FontVariationDescriptionTest.prototype.testCompactEmptyString = function() {
|
8
|
-
assertEquals('n4', this.fvd_.compact(''));
|
9
|
-
};
|
10
|
-
|
11
|
-
FontVariationDescriptionTest.prototype.testCompactFontStyle = function() {
|
12
|
-
assertEquals('n4', this.fvd_.compact('font-style: normal;'));
|
13
|
-
assertEquals('i4', this.fvd_.compact('font-style: italic;'));
|
14
|
-
assertEquals('o4', this.fvd_.compact('font-style: oblique;'));
|
15
|
-
};
|
16
|
-
|
17
|
-
FontVariationDescriptionTest.prototype.testCompactInvalidFontStyle = function() {
|
18
|
-
assertEquals('n4', this.fvd_.compact('font-style: other;'));
|
19
|
-
};
|
20
|
-
|
21
|
-
FontVariationDescriptionTest.prototype.testCompactFontWeight = function() {
|
22
|
-
assertEquals('n4', this.fvd_.compact('font-weight: normal;'));
|
23
|
-
assertEquals('n7', this.fvd_.compact('font-weight: bold;'));
|
24
|
-
assertEquals('n1', this.fvd_.compact('font-weight: 100;'));
|
25
|
-
assertEquals('n2', this.fvd_.compact('font-weight: 200;'));
|
26
|
-
assertEquals('n3', this.fvd_.compact('font-weight: 300;'));
|
27
|
-
assertEquals('n4', this.fvd_.compact('font-weight: 400;'));
|
28
|
-
assertEquals('n5', this.fvd_.compact('font-weight: 500;'));
|
29
|
-
assertEquals('n6', this.fvd_.compact('font-weight: 600;'));
|
30
|
-
assertEquals('n7', this.fvd_.compact('font-weight: 700;'));
|
31
|
-
assertEquals('n8', this.fvd_.compact('font-weight: 800;'));
|
32
|
-
assertEquals('n9', this.fvd_.compact('font-weight: 900;'));
|
33
|
-
};
|
34
|
-
|
35
|
-
FontVariationDescriptionTest.prototype.testCompactInvalidFontWeight = function() {
|
36
|
-
assertEquals('n4', this.fvd_.compact('font-weight: 140;'));
|
37
|
-
assertEquals('n4', this.fvd_.compact('font-weight: other;'));
|
38
|
-
};
|
39
|
-
|
40
|
-
FontVariationDescriptionTest.prototype.testCompactAllProperties = function() {
|
41
|
-
assertEquals('i7', this.fvd_.compact('font-style: italic; font-weight: bold;'));
|
42
|
-
assertEquals('i7', this.fvd_.compact('; font-style: italic; font-weight: bold'));
|
43
|
-
assertEquals('i7', this.fvd_.compact('font-style:italic;font-weight:bold;'));
|
44
|
-
assertEquals('i7', this.fvd_.compact(' font-style: italic ;\n\nfont-weight : bold; '));
|
45
|
-
};
|
46
|
-
|
47
|
-
FontVariationDescriptionTest.prototype.testInvalidProperties = function() {
|
48
|
-
assertEquals('n4', this.fvd_.compact('src: url(/font.otf);'));
|
49
|
-
assertEquals('n9', this.fvd_.compact('font-weight: 900; src: url(/font.otf);'));
|
50
|
-
assertEquals('n8', this.fvd_.compact('font-weight: 800; font-stretch:condensed'));
|
51
|
-
};
|
52
|
-
|
53
|
-
FontVariationDescriptionTest.prototype.testExpandFontStyle = function() {
|
54
|
-
assertEquals('font-style:normal;font-weight:400;', this.fvd_.expand('n4'));
|
55
|
-
assertEquals('font-style:italic;font-weight:400;', this.fvd_.expand('i4'));
|
56
|
-
assertEquals('font-style:oblique;font-weight:400;', this.fvd_.expand('o4'));
|
57
|
-
};
|
58
|
-
|
59
|
-
FontVariationDescriptionTest.prototype.testExpandFontWeight = function() {
|
60
|
-
assertEquals('font-style:normal;font-weight:100;', this.fvd_.expand('n1'));
|
61
|
-
assertEquals('font-style:normal;font-weight:200;', this.fvd_.expand('n2'));
|
62
|
-
assertEquals('font-style:normal;font-weight:300;', this.fvd_.expand('n3'));
|
63
|
-
assertEquals('font-style:normal;font-weight:400;', this.fvd_.expand('n4'));
|
64
|
-
assertEquals('font-style:normal;font-weight:500;', this.fvd_.expand('n5'));
|
65
|
-
assertEquals('font-style:normal;font-weight:600;', this.fvd_.expand('n6'));
|
66
|
-
assertEquals('font-style:normal;font-weight:700;', this.fvd_.expand('n7'));
|
67
|
-
assertEquals('font-style:normal;font-weight:800;', this.fvd_.expand('n8'));
|
68
|
-
assertEquals('font-style:normal;font-weight:900;', this.fvd_.expand('n9'));
|
69
|
-
};
|
70
|
-
|
71
|
-
FontVariationDescriptionTest.prototype.testExpandInvalid = function() {
|
72
|
-
assertEquals(null, this.fvd_.expand(''));
|
73
|
-
assertEquals(null, this.fvd_.expand('n'));
|
74
|
-
assertEquals(null, this.fvd_.expand('1'));
|
75
|
-
assertEquals(null, this.fvd_.expand('n1x'));
|
76
|
-
};
|