webfontloader 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +9 -0
  2. data/Gemfile +2 -8
  3. data/README.md +31 -32
  4. data/Rakefile +2 -33
  5. data/docs/EVENTS.md +10 -1
  6. data/docs/MODULES.md +4 -3
  7. data/lib/webfontloader.rb +1 -1
  8. data/spec/ascender/ascenderscript_spec.js +43 -0
  9. data/spec/core/cssclassname_spec.js +42 -0
  10. data/spec/core/cssfontfamilyname_spec.js +38 -0
  11. data/spec/core/domhelper_spec.js +158 -0
  12. data/spec/core/eventdispatcher_spec.js +209 -0
  13. data/spec/core/font_spec.js +218 -0
  14. data/spec/core/fontmoduleloader_spec.js +55 -0
  15. data/spec/core/fontruler_spec.js +33 -0
  16. data/spec/core/fontvariationdescription_spec.js +67 -0
  17. data/spec/core/fontwatcher_spec.js +204 -0
  18. data/spec/core/fontwatchrunner_spec.js +398 -0
  19. data/spec/core/size_spec.js +17 -0
  20. data/spec/core/useragentparser_spec.js +921 -0
  21. data/spec/custom/customcss_spec.js +36 -0
  22. data/spec/fontdeck/fontdeckscript_spec.js +111 -0
  23. data/spec/fonts/LICENSE.txt +93 -0
  24. data/spec/fonts/nullfont.css +1 -0
  25. data/spec/fonts/nullfont1.css +1 -0
  26. data/spec/fonts/nullfont2.css +1 -0
  27. data/spec/fonts/nullfont3.css +1 -0
  28. data/spec/fonts/sourcesans.eot +0 -0
  29. data/spec/fonts/sourcesans.otf +0 -0
  30. data/spec/fonts/sourcesans.svg +2523 -0
  31. data/spec/fonts/sourcesans.ttf +0 -0
  32. data/spec/fonts/sourcesans.woff +0 -0
  33. data/spec/fonts/sourcesansa.css +1 -0
  34. data/spec/fonts/sourcesansb.css +1 -0
  35. data/spec/google/fontapiparser_spec.js +348 -0
  36. data/spec/google/fontapiurlbuilder_spec.js +40 -0
  37. data/spec/google/googlefontapi_spec.js +123 -0
  38. data/spec/google/lastresortwebkitfontwatchrunner_spec.js +145 -0
  39. data/spec/index.html +95 -0
  40. data/spec/monotype/monotypescript_spec.js +49 -0
  41. data/spec/typekit/typekitscript_spec.js +93 -0
  42. data/src/core/domhelper.js +6 -3
  43. data/src/core/fontruler.js +1 -1
  44. data/src/core/fontwatcher.js +5 -0
  45. data/src/core/fontwatchrunner.js +7 -4
  46. data/src/monotype/monotype_script.js +4 -3
  47. data/tools/jasmine-phantomjs/jasmine-phantomjs.js +26 -0
  48. data/tools/jasmine-phantomjs/terminal-reporter.js +177 -0
  49. data/tools/jasmine/MIT.LICENSE +20 -0
  50. data/tools/jasmine/jasmine-html.js +681 -0
  51. data/tools/jasmine/jasmine.css +82 -0
  52. data/tools/jasmine/jasmine.js +2600 -0
  53. data/webfontloader.gemspec +46 -25
  54. metadata +77 -42
  55. data/src-test/ascender/ascender_script_test.js +0 -51
  56. data/src-test/core/cssclassnametest.js +0 -42
  57. data/src-test/core/cssfontfamilynametest.js +0 -54
  58. data/src-test/core/domhelpertest.js +0 -151
  59. data/src-test/core/eventdispatchertest.js +0 -275
  60. data/src-test/core/fontmoduleloadertest.js +0 -30
  61. data/src-test/core/fonttest.js +0 -121
  62. data/src-test/core/fontvariationdescriptiontest.js +0 -76
  63. data/src-test/core/fontwatchertest.js +0 -287
  64. data/src-test/core/fontwatchrunnertest.js +0 -454
  65. data/src-test/core/useragenttest.js +0 -755
  66. data/src-test/custom/customcsstest.js +0 -35
  67. data/src-test/fontdeck/fontdeck_script_test.js +0 -116
  68. data/src-test/google/fontapiparsertest.js +0 -252
  69. data/src-test/google/fontapiurlbuildertest.js +0 -71
  70. data/src-test/google/googlefontapitest.js +0 -185
  71. data/src-test/google/lastresortwebkitfontwatchrunnertest.js +0 -204
  72. data/src-test/monotype/monotype_script_test.js +0 -304
  73. data/src-test/typekit/typekit_script_test.js +0 -195
  74. data/tools/jstestdriver/JsTestDriver-1.2.1.jar +0 -0
@@ -1,195 +0,0 @@
1
- var TypekitScriptTest = TestCase('TypeKitScriptTest');
2
-
3
- TypekitScriptTest.prototype.testSupportAndLoadLifecycle = function() {
4
- var configuration = {
5
- 'id': 'abc'
6
- };
7
- var insert = '';
8
- var src = '';
9
- var global = {};
10
- var fakeDomHelper = {
11
- insertInto: function(tag, e) {
12
- insert = tag;
13
- },
14
- createScriptSrc: function(srcLink) {
15
- src = srcLink;
16
- },
17
- getLoadWindow: function() {
18
- return global;
19
- },
20
- getProtocol: function() {
21
- return 'http:';
22
- }
23
- };
24
- var typeKit = new webfont.TypekitScript(fakeDomHelper, configuration);
25
-
26
- // supportUserAgent
27
- var userAgent = 'user agent';
28
- var isSupport = null;
29
-
30
- typeKit.supportUserAgent(userAgent, function(support) { isSupport = support; });
31
- assertEquals('head', insert);
32
- assertEquals('http://use.typekit.com/abc.js', src);
33
- assertEquals(null, isSupport);
34
-
35
- assertNotNull(global.__webfonttypekitmodule__);
36
- assertNotNull(global.__webfonttypekitmodule__['abc']);
37
-
38
- // Typekit script calls initializer.
39
- global.__webfonttypekitmodule__['abc'](function(ua, config, init) {
40
- assertEquals('user agent', ua);
41
- assertEquals(config, configuration);
42
- assertNotNull(init);
43
- init(true, ['Font1', 'Font2'], {});
44
- });
45
- assertEquals(true, isSupport);
46
-
47
- // load
48
- var families = null;
49
- var descriptions = null;
50
-
51
- typeKit.load(function(fontFamilies, fontDescriptions) {
52
- families = fontFamilies;
53
- descriptions = fontDescriptions;
54
- });
55
-
56
- assertNotNull(families);
57
- assertEquals(2, families.length);
58
- assertEquals('Font1', families[0]);
59
- assertEquals('Font2', families[1]);
60
-
61
- var font1Descriptions = descriptions['Font1'];
62
- assertUndefined(font1Descriptions);
63
-
64
- var font2Descriptions = descriptions['Font2'];
65
- assertUndefined(font2Descriptions);
66
- };
67
-
68
- TypekitScriptTest.prototype.testLoadWithVariations = function() {
69
- var configuration = {
70
- 'id': 'abc'
71
- };
72
- var insert = '';
73
- var src = '';
74
- var global = {};
75
- var fakeDomHelper = {
76
- insertInto: function(tag, e) {
77
- insert = tag;
78
- },
79
- createScriptSrc: function(srcLink) {
80
- src = srcLink;
81
- },
82
- getLoadWindow: function() {
83
- return global;
84
- },
85
- getProtocol: function() {
86
- return 'http:';
87
- }
88
- };
89
- var typeKit = new webfont.TypekitScript(fakeDomHelper, configuration);
90
-
91
- // supportUserAgent
92
- var userAgent = 'user agent';
93
- var isSupport = null;
94
-
95
- typeKit.supportUserAgent(userAgent, function(support) { isSupport = support; });
96
- assertEquals(null, isSupport);
97
-
98
- assertNotNull(global.__webfonttypekitmodule__);
99
- assertNotNull(global.__webfonttypekitmodule__['abc']);
100
-
101
- // Typekit script calls initializer.
102
- global.__webfonttypekitmodule__['abc'](function(ua, config, init) {
103
- init(true, ['Font1', 'Font2'], {
104
- 'Font1': ['n7', 'i7']
105
- });
106
- });
107
-
108
- // load
109
- var families = null;
110
- var descriptions = null;
111
-
112
- typeKit.load(function(fontFamilies, fontDescriptions) {
113
- families = fontFamilies;
114
- descriptions = fontDescriptions;
115
- });
116
-
117
- assertNotNull(families);
118
- assertEquals(2, families.length);
119
- assertEquals('Font1', families[0]);
120
- assertEquals('Font2', families[1]);
121
-
122
- var font1Descriptions = descriptions['Font1'];
123
- assertEquals(2, font1Descriptions.length);
124
- assertEquals('n7', font1Descriptions[0]);
125
- assertEquals('i7', font1Descriptions[1]);
126
-
127
- var font2Descriptions = descriptions['Font2'];
128
- assertUndefined(font2Descriptions);
129
- };
130
-
131
- TypekitScriptTest.prototype.testAlternateApi = function() {
132
- var configuration = {
133
- 'id': 'abc',
134
- 'api': '/test'
135
- };
136
- var insert = '';
137
- var src = '';
138
- var fakeDomHelper = {
139
- insertInto: function(tag, e) {
140
- insert = tag;
141
- },
142
- createScriptSrc: function(srcLink) {
143
- src = srcLink;
144
- },
145
- getLoadWindow: function() {
146
- return {};
147
- },
148
- getProtocol: function() {
149
- return 'http:';
150
- }
151
- };
152
- var typeKit = new webfont.TypekitScript(fakeDomHelper, configuration);
153
- var userAgent = 'user agent';
154
- var isSupport = null;
155
-
156
- typeKit.supportUserAgent(userAgent, function(support) { isSupport = support; });
157
- assertEquals('head', insert);
158
- assertEquals('/test/abc.js', src);
159
- };
160
-
161
- TypekitScriptTest.prototype.testNoKitId = function() {
162
- var configuration = {
163
- 'id': null,
164
- };
165
- var insert = null;
166
- var src = null;
167
- var fakeDomHelper = {
168
- insertInto: function(tag, e) {
169
- insert = tag;
170
- },
171
- createScriptSrc: function(srcLink) {
172
- src = srcLink;
173
- },
174
- getLoadWindow: function() {
175
- return {};
176
- },
177
- getProtocol: function() {
178
- return 'http:';
179
- }
180
- };
181
- var typeKit = new webfont.TypekitScript(fakeDomHelper, configuration);
182
- var userAgent = 'user agent';
183
- var isSupport = null;
184
-
185
- // supportUserAgent
186
- typeKit.supportUserAgent(userAgent, function(support) { isSupport = support; });
187
- assertNull(insert);
188
- assertNull(src);
189
- assertEquals(true, isSupport);
190
-
191
- // load
192
- typeKit.load(function(fontFamilies) { families = fontFamilies; });
193
-
194
- assertEquals([], families);
195
- };