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
@@ -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.0'
17
- s.date = '2013-01-30'
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('rack', ["~>1.2.1"])
60
- s.add_development_dependency('sinatra', ["~>1.0"])
61
- s.add_development_dependency('vegas', ["~>0.1.6"])
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
- src-test/ascender/ascender_script_test.js
111
- src-test/core/cssclassnametest.js
112
- src-test/core/cssfontfamilynametest.js
113
- src-test/core/domhelpertest.js
114
- src-test/core/eventdispatchertest.js
115
- src-test/core/fontmoduleloadertest.js
116
- src-test/core/fonttest.js
117
- src-test/core/fontvariationdescriptiontest.js
118
- src-test/core/fontwatchertest.js
119
- src-test/core/fontwatchrunnertest.js
120
- src-test/core/useragenttest.js
121
- src-test/custom/customcsstest.js
122
- src-test/fontdeck/fontdeck_script_test.js
123
- src-test/google/fontapiparsertest.js
124
- src-test/google/fontapiurlbuildertest.js
125
- src-test/google/googlefontapitest.js
126
- src-test/google/lastresortwebkitfontwatchrunnertest.js
127
- src-test/monotype/monotype_script_test.js
128
- src-test/typekit/typekit_script_test.js
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/jstestdriver/JsTestDriver-1.2.1.jar
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
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-01-30 00:00:00 Z
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
- requirement: &id001 !ruby/object:Gem::Requirement
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: 29
42
+ hash: 1
30
43
  segments:
31
44
  - 1
32
- - 2
45
+ - 5
33
46
  - 1
34
- version: 1.2.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
- requirement: &id002 !ruby/object:Gem::Requirement
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: 15
58
+ hash: 19
46
59
  segments:
47
60
  - 1
48
- - 0
49
- version: "1.0"
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
- requirement: &id003 !ruby/object:Gem::Requirement
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: 23
74
+ hash: 13
61
75
  segments:
62
76
  - 0
63
77
  - 1
64
- - 6
65
- version: 0.1.6
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
- - src-test/ascender/ascender_script_test.js
128
- - src-test/core/cssclassnametest.js
129
- - src-test/core/cssfontfamilynametest.js
130
- - src-test/core/domhelpertest.js
131
- - src-test/core/eventdispatchertest.js
132
- - src-test/core/fontmoduleloadertest.js
133
- - src-test/core/fonttest.js
134
- - src-test/core/fontvariationdescriptiontest.js
135
- - src-test/core/fontwatchertest.js
136
- - src-test/core/fontwatchrunnertest.js
137
- - src-test/core/useragenttest.js
138
- - src-test/custom/customcsstest.js
139
- - src-test/fontdeck/fontdeck_script_test.js
140
- - src-test/google/fontapiparsertest.js
141
- - src-test/google/fontapiurlbuildertest.js
142
- - src-test/google/googlefontapitest.js
143
- - src-test/google/lastresortwebkitfontwatchrunnertest.js
144
- - src-test/monotype/monotype_script_test.js
145
- - src-test/typekit/typekit_script_test.js
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/jstestdriver/JsTestDriver-1.2.1.jar
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
- };