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
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.2.
|
17
|
-
s.date = '2013-
|
16
|
+
s.version = '1.2.1'
|
17
|
+
s.date = '2013-02-26'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -56,9 +56,10 @@ DESC
|
|
56
56
|
|
57
57
|
## List your development dependencies here. Development dependencies are
|
58
58
|
## those that are only needed during development
|
59
|
-
s.add_development_dependency('
|
60
|
-
s.add_development_dependency('
|
61
|
-
s.add_development_dependency('
|
59
|
+
s.add_development_dependency('rake')
|
60
|
+
s.add_development_dependency('rack', ["~>1.5.1"])
|
61
|
+
s.add_development_dependency('sinatra', ["~>1.3.4"])
|
62
|
+
s.add_development_dependency('vegas', ["~>0.1.11"])
|
62
63
|
|
63
64
|
## Leave this section as-is. It will be automatically generated from the
|
64
65
|
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
@@ -107,25 +108,40 @@ DESC
|
|
107
108
|
lib/webfontloader/demo/public/typekit.html
|
108
109
|
lib/webfontloader/demo/server.rb
|
109
110
|
lib/webfontloader/modules.rb
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
111
|
+
spec/ascender/ascenderscript_spec.js
|
112
|
+
spec/core/cssclassname_spec.js
|
113
|
+
spec/core/cssfontfamilyname_spec.js
|
114
|
+
spec/core/domhelper_spec.js
|
115
|
+
spec/core/eventdispatcher_spec.js
|
116
|
+
spec/core/font_spec.js
|
117
|
+
spec/core/fontmoduleloader_spec.js
|
118
|
+
spec/core/fontruler_spec.js
|
119
|
+
spec/core/fontvariationdescription_spec.js
|
120
|
+
spec/core/fontwatcher_spec.js
|
121
|
+
spec/core/fontwatchrunner_spec.js
|
122
|
+
spec/core/size_spec.js
|
123
|
+
spec/core/useragentparser_spec.js
|
124
|
+
spec/custom/customcss_spec.js
|
125
|
+
spec/fontdeck/fontdeckscript_spec.js
|
126
|
+
spec/fonts/LICENSE.txt
|
127
|
+
spec/fonts/nullfont.css
|
128
|
+
spec/fonts/nullfont1.css
|
129
|
+
spec/fonts/nullfont2.css
|
130
|
+
spec/fonts/nullfont3.css
|
131
|
+
spec/fonts/sourcesans.eot
|
132
|
+
spec/fonts/sourcesans.otf
|
133
|
+
spec/fonts/sourcesans.svg
|
134
|
+
spec/fonts/sourcesans.ttf
|
135
|
+
spec/fonts/sourcesans.woff
|
136
|
+
spec/fonts/sourcesansa.css
|
137
|
+
spec/fonts/sourcesansb.css
|
138
|
+
spec/google/fontapiparser_spec.js
|
139
|
+
spec/google/fontapiurlbuilder_spec.js
|
140
|
+
spec/google/googlefontapi_spec.js
|
141
|
+
spec/google/lastresortwebkitfontwatchrunner_spec.js
|
142
|
+
spec/index.html
|
143
|
+
spec/monotype/monotypescript_spec.js
|
144
|
+
spec/typekit/typekitscript_spec.js
|
129
145
|
src/ascender/ascender_script.js
|
130
146
|
src/async_load.js
|
131
147
|
src/closure.js
|
@@ -155,7 +171,12 @@ DESC
|
|
155
171
|
src/monotype/monotype_script.js
|
156
172
|
src/typekit/typekit_script.js
|
157
173
|
tools/compiler/compiler.jar
|
158
|
-
tools/
|
174
|
+
tools/jasmine-phantomjs/jasmine-phantomjs.js
|
175
|
+
tools/jasmine-phantomjs/terminal-reporter.js
|
176
|
+
tools/jasmine/MIT.LICENSE
|
177
|
+
tools/jasmine/jasmine-html.js
|
178
|
+
tools/jasmine/jasmine.css
|
179
|
+
tools/jasmine/jasmine.js
|
159
180
|
webfontloader.gemspec
|
160
181
|
]
|
161
182
|
# = MANIFEST =
|
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: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Carver
|
@@ -16,55 +16,70 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-02-26 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: rack
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
requirement: *id001
|
33
|
+
name: rake
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
25
38
|
none: false
|
26
39
|
requirements:
|
27
40
|
- - ~>
|
28
41
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
42
|
+
hash: 1
|
30
43
|
segments:
|
31
44
|
- 1
|
32
|
-
-
|
45
|
+
- 5
|
33
46
|
- 1
|
34
|
-
version: 1.
|
47
|
+
version: 1.5.1
|
48
|
+
requirement: *id002
|
49
|
+
name: rack
|
35
50
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
51
|
- !ruby/object:Gem::Dependency
|
38
|
-
name: sinatra
|
39
52
|
prerelease: false
|
40
|
-
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
54
|
none: false
|
42
55
|
requirements:
|
43
56
|
- - ~>
|
44
57
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
58
|
+
hash: 19
|
46
59
|
segments:
|
47
60
|
- 1
|
48
|
-
-
|
49
|
-
|
61
|
+
- 3
|
62
|
+
- 4
|
63
|
+
version: 1.3.4
|
64
|
+
requirement: *id003
|
65
|
+
name: sinatra
|
50
66
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
67
|
- !ruby/object:Gem::Dependency
|
53
|
-
name: vegas
|
54
68
|
prerelease: false
|
55
|
-
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
56
70
|
none: false
|
57
71
|
requirements:
|
58
72
|
- - ~>
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
74
|
+
hash: 13
|
61
75
|
segments:
|
62
76
|
- 0
|
63
77
|
- 1
|
64
|
-
-
|
65
|
-
version: 0.1.
|
78
|
+
- 11
|
79
|
+
version: 0.1.11
|
80
|
+
requirement: *id004
|
81
|
+
name: vegas
|
66
82
|
type: :development
|
67
|
-
version_requirements: *id003
|
68
83
|
description: |
|
69
84
|
WebFont Loader gives you added control when using linked fonts via
|
70
85
|
`@font-face`. It provides a common interface to loading fonts regardless of
|
@@ -124,25 +139,40 @@ files:
|
|
124
139
|
- lib/webfontloader/demo/public/typekit.html
|
125
140
|
- lib/webfontloader/demo/server.rb
|
126
141
|
- lib/webfontloader/modules.rb
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
142
|
+
- spec/ascender/ascenderscript_spec.js
|
143
|
+
- spec/core/cssclassname_spec.js
|
144
|
+
- spec/core/cssfontfamilyname_spec.js
|
145
|
+
- spec/core/domhelper_spec.js
|
146
|
+
- spec/core/eventdispatcher_spec.js
|
147
|
+
- spec/core/font_spec.js
|
148
|
+
- spec/core/fontmoduleloader_spec.js
|
149
|
+
- spec/core/fontruler_spec.js
|
150
|
+
- spec/core/fontvariationdescription_spec.js
|
151
|
+
- spec/core/fontwatcher_spec.js
|
152
|
+
- spec/core/fontwatchrunner_spec.js
|
153
|
+
- spec/core/size_spec.js
|
154
|
+
- spec/core/useragentparser_spec.js
|
155
|
+
- spec/custom/customcss_spec.js
|
156
|
+
- spec/fontdeck/fontdeckscript_spec.js
|
157
|
+
- spec/fonts/LICENSE.txt
|
158
|
+
- spec/fonts/nullfont.css
|
159
|
+
- spec/fonts/nullfont1.css
|
160
|
+
- spec/fonts/nullfont2.css
|
161
|
+
- spec/fonts/nullfont3.css
|
162
|
+
- spec/fonts/sourcesans.eot
|
163
|
+
- spec/fonts/sourcesans.otf
|
164
|
+
- spec/fonts/sourcesans.svg
|
165
|
+
- spec/fonts/sourcesans.ttf
|
166
|
+
- spec/fonts/sourcesans.woff
|
167
|
+
- spec/fonts/sourcesansa.css
|
168
|
+
- spec/fonts/sourcesansb.css
|
169
|
+
- spec/google/fontapiparser_spec.js
|
170
|
+
- spec/google/fontapiurlbuilder_spec.js
|
171
|
+
- spec/google/googlefontapi_spec.js
|
172
|
+
- spec/google/lastresortwebkitfontwatchrunner_spec.js
|
173
|
+
- spec/index.html
|
174
|
+
- spec/monotype/monotypescript_spec.js
|
175
|
+
- spec/typekit/typekitscript_spec.js
|
146
176
|
- src/ascender/ascender_script.js
|
147
177
|
- src/async_load.js
|
148
178
|
- src/closure.js
|
@@ -172,7 +202,12 @@ files:
|
|
172
202
|
- src/monotype/monotype_script.js
|
173
203
|
- src/typekit/typekit_script.js
|
174
204
|
- tools/compiler/compiler.jar
|
175
|
-
- tools/
|
205
|
+
- tools/jasmine-phantomjs/jasmine-phantomjs.js
|
206
|
+
- tools/jasmine-phantomjs/terminal-reporter.js
|
207
|
+
- tools/jasmine/MIT.LICENSE
|
208
|
+
- tools/jasmine/jasmine-html.js
|
209
|
+
- tools/jasmine/jasmine.css
|
210
|
+
- tools/jasmine/jasmine.js
|
176
211
|
- webfontloader.gemspec
|
177
212
|
homepage: http://github.com/typekit/webfontloader
|
178
213
|
licenses: []
|
@@ -1,51 +0,0 @@
|
|
1
|
-
var AscenderScriptTest = TestCase('AscenderScriptTest');
|
2
|
-
|
3
|
-
AscenderScriptTest.prototype.testLoadAndFamilyVariations = function(){
|
4
|
-
|
5
|
-
var insert, css, element;
|
6
|
-
var key = 'ec2de397-11ae-4c10-937f-bf94283a70c1';
|
7
|
-
var onReadyTriggered = false;
|
8
|
-
|
9
|
-
var fakeDomHelper = {
|
10
|
-
insertInto: function(tag, el) {
|
11
|
-
insert = tag;
|
12
|
-
element = el;
|
13
|
-
},
|
14
|
-
createCssLink: function(cssLink) {
|
15
|
-
css = cssLink;
|
16
|
-
return '<link href="' + css + '" type="text/css" />';
|
17
|
-
},
|
18
|
-
getProtocol: function() {
|
19
|
-
return 'http:';
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
var configuration = {
|
24
|
-
key:key,
|
25
|
-
families: ['AndyBold','Arial:bold,regular']
|
26
|
-
};
|
27
|
-
|
28
|
-
var fakeOnReady = function(){
|
29
|
-
onReadyTriggered = true;
|
30
|
-
};
|
31
|
-
|
32
|
-
var as = new webfont.AscenderScript(fakeDomHelper, configuration);
|
33
|
-
|
34
|
-
assertFalse(onReadyTriggered);
|
35
|
-
as.load(fakeOnReady);
|
36
|
-
|
37
|
-
assertEquals('http://webfonts.fontslive.com/css/' + key + '.css', css);
|
38
|
-
assertEquals('<link href="http://webfonts.fontslive.com/css/' + key + '.css" type="text/css" />', element);
|
39
|
-
assertEquals('head', insert);
|
40
|
-
assertTrue(onReadyTriggered);
|
41
|
-
|
42
|
-
assertEquals(['n4'], as.parseVariations('regular'));
|
43
|
-
assertEquals(['n7'], as.parseVariations('bold'));
|
44
|
-
assertEquals(['i4'], as.parseVariations('italic'));
|
45
|
-
assertEquals(['i7'], as.parseVariations('bolditalic'));
|
46
|
-
assertEquals(['n4'], as.parseVariations('regular,'));
|
47
|
-
assertEquals(['n4','n7'], as.parseVariations('regular,bold'));
|
48
|
-
assertEquals(['n4','n7'], as.parseVariations('regular,,bold'));
|
49
|
-
assertEquals(['n4','n7'], as.parseVariations('n4,n7'));
|
50
|
-
|
51
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
var CssClassNameTest = TestCase('CssClassName');
|
2
|
-
|
3
|
-
CssClassNameTest.prototype.setUp = function() {
|
4
|
-
this.sanitizer_ = new webfont.CssClassName();
|
5
|
-
};
|
6
|
-
|
7
|
-
CssClassNameTest.prototype.testSanitizeSpacesInName = function() {
|
8
|
-
var result = this.sanitizer_.sanitize(' My Family ');
|
9
|
-
|
10
|
-
assertEquals('myfamily', result);
|
11
|
-
};
|
12
|
-
|
13
|
-
CssClassNameTest.prototype.testSanitizeNumbersInName = function() {
|
14
|
-
var result = this.sanitizer_.sanitize('99 My Family 99');
|
15
|
-
|
16
|
-
assertEquals('99myfamily99', result);
|
17
|
-
};
|
18
|
-
|
19
|
-
CssClassNameTest.prototype.testSanitizeOtherChars = function() {
|
20
|
-
var result = this.sanitizer_.sanitize('_My+Family!-');
|
21
|
-
|
22
|
-
assertEquals('myfamily', result);
|
23
|
-
};
|
24
|
-
|
25
|
-
CssClassNameTest.prototype.testBuildManyParts = function() {
|
26
|
-
var result = this.sanitizer_.build('pre_', 'My Family', '_post');
|
27
|
-
|
28
|
-
assertEquals('pre-myfamily-post', result);
|
29
|
-
};
|
30
|
-
|
31
|
-
CssClassNameTest.prototype.testBuildSomeParts = function() {
|
32
|
-
var result = this.sanitizer_.build('pre!', 'My Family');
|
33
|
-
|
34
|
-
assertEquals('pre-myfamily', result);
|
35
|
-
};
|
36
|
-
|
37
|
-
CssClassNameTest.prototype.testBuildOtherJoinChar = function() {
|
38
|
-
this.sanitizer_ = new webfont.CssClassName('_');
|
39
|
-
var result = this.sanitizer_.build('pre', 'My Family');
|
40
|
-
|
41
|
-
assertEquals('pre_myfamily', result);
|
42
|
-
};
|
@@ -1,54 +0,0 @@
|
|
1
|
-
var CssFontFamilyNameTest = TestCase('CssFontFamilyName');
|
2
|
-
|
3
|
-
CssFontFamilyNameTest.prototype.setUp = function() {
|
4
|
-
this.sanitizer_ = new webfont.CssFontFamilyName();
|
5
|
-
};
|
6
|
-
|
7
|
-
CssFontFamilyNameTest.prototype.testSpaceNameWithoutQuotes = function() {
|
8
|
-
var result = this.sanitizer_.quote('My Family');
|
9
|
-
|
10
|
-
assertEquals("'My Family'", result);
|
11
|
-
};
|
12
|
-
|
13
|
-
CssFontFamilyNameTest.prototype.testSpaceNameWithDoubleQuotes = function() {
|
14
|
-
var result = this.sanitizer_.quote('"My Family"');
|
15
|
-
|
16
|
-
assertEquals("'My Family'", result);
|
17
|
-
};
|
18
|
-
|
19
|
-
CssFontFamilyNameTest.prototype.testSpaceNameWithSingleQuotes = function() {
|
20
|
-
var result = this.sanitizer_.quote('\'My Family\'');
|
21
|
-
|
22
|
-
assertEquals("'My Family'", result);
|
23
|
-
};
|
24
|
-
|
25
|
-
CssFontFamilyNameTest.prototype.testSpaceNameWithCommasAndQuotes = function() {
|
26
|
-
var result = this.sanitizer_.quote('\'family 1\',\'family 2\'');
|
27
|
-
|
28
|
-
assertEquals("'family 1','family 2'", result);
|
29
|
-
};
|
30
|
-
|
31
|
-
CssFontFamilyNameTest.prototype.testSpaceNameWithCommaSpaceAndQuotes = function() {
|
32
|
-
var result = this.sanitizer_.quote('\'family 1\', \'family 2\'');
|
33
|
-
|
34
|
-
assertEquals("'family 1','family 2'", result);
|
35
|
-
};
|
36
|
-
|
37
|
-
CssFontFamilyNameTest.prototype.testNoSpaceNameWithoutQuotes = function() {
|
38
|
-
var result = this.sanitizer_.quote('MyFamily');
|
39
|
-
|
40
|
-
assertEquals('MyFamily', result);
|
41
|
-
};
|
42
|
-
|
43
|
-
CssFontFamilyNameTest.prototype.testNoSpaceNameWithQuotes = function() {
|
44
|
-
var result = this.sanitizer_.quote('"MyFamily"');
|
45
|
-
|
46
|
-
assertEquals('MyFamily', result);
|
47
|
-
};
|
48
|
-
|
49
|
-
CssFontFamilyNameTest.prototype.testNoSpaceNameWithCommasAndQuotes = function() {
|
50
|
-
var result = this.sanitizer_.quote('\'family-1\', \'family-2\'');
|
51
|
-
|
52
|
-
assertEquals('family-1,family-2', result);
|
53
|
-
};
|
54
|
-
|
@@ -1,151 +0,0 @@
|
|
1
|
-
var DomHelperTest = TestCase('DomHelperTest');
|
2
|
-
|
3
|
-
DomHelperTest.prototype.setUp = function() {
|
4
|
-
this.domHelper_ = new webfont.DomHelper(window);
|
5
|
-
};
|
6
|
-
|
7
|
-
DomHelperTest.prototype.testCreateElementNoAttr = function() {
|
8
|
-
var span = this.domHelper_.createElement('span');
|
9
|
-
|
10
|
-
assertNotNull(span);
|
11
|
-
};
|
12
|
-
|
13
|
-
DomHelperTest.prototype.testCreateElementEmptyAttrInnerHtml = function() {
|
14
|
-
var span = this.domHelper_.createElement('span', {}, 'moo');
|
15
|
-
|
16
|
-
assertNotNull(span);
|
17
|
-
assertEquals('moo', span.innerHTML);
|
18
|
-
};
|
19
|
-
|
20
|
-
DomHelperTest.prototype.testCreateElementWithAttrInnerHtml = function() {
|
21
|
-
var span = this.domHelper_.createElement('span', { style: 'font-size: 42px',
|
22
|
-
id: 'mySpan' }, 'hello');
|
23
|
-
|
24
|
-
assertNotNull(span);
|
25
|
-
assertEquals('mySpan', span.id);
|
26
|
-
assertEquals('42px', span.style.fontSize);
|
27
|
-
assertEquals('hello', span.innerHTML);
|
28
|
-
};
|
29
|
-
|
30
|
-
DomHelperTest.prototype.testCreateElementWithPrototypeAugments = function(){
|
31
|
-
|
32
|
-
Object.prototype.extrastuff = function(){ return 'I am a troublemaker.'; }
|
33
|
-
|
34
|
-
var span = this.domHelper_.createElement('span', { id : "augmented" });
|
35
|
-
var spanPar = this.domHelper_.createElement('div', { id : "augmentedpar" });
|
36
|
-
spanPar.appendChild(span);
|
37
|
-
|
38
|
-
|
39
|
-
assertNotNull(span);
|
40
|
-
assertSame(false,!!span.getAttribute('extrastuff'));
|
41
|
-
assertSame(-1,spanPar.innerHTML.indexOf('extrastuff'))
|
42
|
-
|
43
|
-
|
44
|
-
delete Object.prototype.extrastuff;
|
45
|
-
span = spanPar = undefined;
|
46
|
-
}
|
47
|
-
|
48
|
-
DomHelperTest.prototype.testCreateCssLink = function() {
|
49
|
-
var cssLink = this.domHelper_.createCssLink('http://moo/somecss.css');
|
50
|
-
|
51
|
-
assertEquals('stylesheet', cssLink.rel);
|
52
|
-
assertEquals('http://moo/somecss.css', cssLink.href);
|
53
|
-
};
|
54
|
-
|
55
|
-
DomHelperTest.prototype.testCreateScriptSrc = function() {
|
56
|
-
var cssLink = this.domHelper_.createScriptSrc('http://moo/somescript.js');
|
57
|
-
|
58
|
-
assertEquals('http://moo/somescript.js', cssLink.src);
|
59
|
-
};
|
60
|
-
|
61
|
-
DomHelperTest.prototype.testAppendAndRemoveClassNames = function() {
|
62
|
-
var div = this.domHelper_.createElement('div');
|
63
|
-
|
64
|
-
this.domHelper_.appendClassName(div, 'moo');
|
65
|
-
assertEquals('moo', div.className);
|
66
|
-
this.domHelper_.appendClassName(div, 'meuh');
|
67
|
-
assertEquals('moo meuh', div.className);
|
68
|
-
this.domHelper_.removeClassName(div, 'moo');
|
69
|
-
assertEquals('meuh', div.className);
|
70
|
-
|
71
|
-
this.domHelper_.removeClassName(div, 'meuh');
|
72
|
-
this.domHelper_.appendClassName(div, 'spaces and tabs');
|
73
|
-
|
74
|
-
this.domHelper_.removeClassName(div, 'and');
|
75
|
-
assertEquals('spaces tabs', div.className);
|
76
|
-
this.domHelper_.removeClassName(div, 'spaces');
|
77
|
-
this.domHelper_.removeClassName(div, 'tabs');
|
78
|
-
assertEquals('', div.className);
|
79
|
-
|
80
|
-
};
|
81
|
-
|
82
|
-
DomHelperTest.prototype.testHasClassName = function() {
|
83
|
-
var div = this.domHelper_.createElement('div');
|
84
|
-
|
85
|
-
this.domHelper_.appendClassName(div, 'moo');
|
86
|
-
this.domHelper_.appendClassName(div, 'moo-meuh');
|
87
|
-
|
88
|
-
assertTrue(this.domHelper_.hasClassName(div, 'moo'));
|
89
|
-
assertTrue(this.domHelper_.hasClassName(div, 'moo-meuh'));
|
90
|
-
assertFalse(this.domHelper_.hasClassName(div, 'meuh'));
|
91
|
-
assertFalse(this.domHelper_.hasClassName(div, 'missingClassName'));
|
92
|
-
};
|
93
|
-
|
94
|
-
DomHelperTest.prototype.testSetStyle = function() {
|
95
|
-
var e = this.domHelper_.createElement('span')
|
96
|
-
this.domHelper_.setStyle(e, 'left:3px;top:1px;');
|
97
|
-
assertEquals('3px', e.style.left)
|
98
|
-
assertEquals('1px', e.style.top);
|
99
|
-
};
|
100
|
-
|
101
|
-
DomHelperTest.prototype.testHasSupportForStyle = function() {
|
102
|
-
assertUndefined(this.domHelper_.supportForStyle_);
|
103
|
-
assertBoolean(this.domHelper_.hasSupportForStyle_());
|
104
|
-
this.domHelper_.supportForStyle_ = false;
|
105
|
-
assertFalse(this.domHelper_.hasSupportForStyle_());
|
106
|
-
this.domHelper_.supportForStyle_ = true;
|
107
|
-
assertTrue(this.domHelper_.hasSupportForStyle_());
|
108
|
-
};
|
109
|
-
|
110
|
-
DomHelperTest.prototype.testGetWindows = function() {
|
111
|
-
var fakeMainWindow = 'main window';
|
112
|
-
var fakeLoadWindow = 'load window';
|
113
|
-
var domHelper = new webfont.DomHelper(fakeMainWindow, fakeLoadWindow);
|
114
|
-
assertEquals('main window', domHelper.getMainWindow());
|
115
|
-
assertEquals('load window', domHelper.getLoadWindow());
|
116
|
-
};
|
117
|
-
|
118
|
-
DomHelperTest.prototype.testGetProtocol = function() {
|
119
|
-
var fakeWindow = {
|
120
|
-
location: {
|
121
|
-
protocol: 'https:'
|
122
|
-
}
|
123
|
-
};
|
124
|
-
var domHelper = new webfont.DomHelper(fakeWindow);
|
125
|
-
assertEquals('https:', domHelper.getProtocol());
|
126
|
-
};
|
127
|
-
|
128
|
-
DomHelperTest.prototype.testGetProtocolHttpDefault = function() {
|
129
|
-
var fakeWindow = {
|
130
|
-
location: {
|
131
|
-
protocol: 'file:'
|
132
|
-
}
|
133
|
-
};
|
134
|
-
var domHelper = new webfont.DomHelper(fakeWindow);
|
135
|
-
assertEquals('http:', domHelper.getProtocol());
|
136
|
-
};
|
137
|
-
|
138
|
-
DomHelperTest.prototype.testGetProtocolIframeFallback = function() {
|
139
|
-
var fakeMainWindow = {
|
140
|
-
location: {
|
141
|
-
protocol: 'https:'
|
142
|
-
}
|
143
|
-
};
|
144
|
-
var fakeLoadWindow = {
|
145
|
-
location: {
|
146
|
-
protocol: 'about:'
|
147
|
-
}
|
148
|
-
};
|
149
|
-
var domHelper = new webfont.DomHelper(fakeMainWindow, fakeLoadWindow);
|
150
|
-
assertEquals('https:', domHelper.getProtocol());
|
151
|
-
};
|