Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: LayoutTests/svg/dom/script-tests/SVGAngle.js

Issue 930053002: Apply TypeChecking=Unrestricted to SVG{Number,Length,Transform,Angle} (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 description("This test checks the SVGAngle API"); 1 description("This test checks the SVGAngle API");
2 2
3 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); 3 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4 var angle = svgElement.createSVGAngle(); 4 var angle = svgElement.createSVGAngle();
5 5
6 debug(""); 6 debug("");
7 debug("Check initial angle values"); 7 debug("Check initial angle values");
8 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 8 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
9 shouldBeEqualToString("angle.valueAsString", "0"); 9 shouldBeEqualToString("angle.valueAsString", "0");
10 shouldBe("angle.value", "0"); 10 shouldBe("angle.value", "0");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 shouldBe("angle.valueInSpecifiedUnits", "0"); 52 shouldBe("angle.valueInSpecifiedUnits", "0");
53 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 53 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
54 54
55 // Spec: Raised if unitType is SVG_ANGLETYPE_UNKNOWN or not a valid unit type co nstant (one of the other SVG_ANGLETYPE_* constants defined on this interface). 55 // Spec: Raised if unitType is SVG_ANGLETYPE_UNKNOWN or not a valid unit type co nstant (one of the other SVG_ANGLETYPE_* constants defined on this interface).
56 debug(""); 56 debug("");
57 debug("Check invalid arguments for 'newValueSpecifiedUnits'"); 57 debug("Check invalid arguments for 'newValueSpecifiedUnits'");
58 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_UNKNOWN, 50)"); 58 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_UNKNOWN, 50)");
59 shouldThrow("angle.newValueSpecifiedUnits(-1, 50)"); 59 shouldThrow("angle.newValueSpecifiedUnits(-1, 50)");
60 shouldThrow("angle.newValueSpecifiedUnits(5, 50)"); 60 shouldThrow("angle.newValueSpecifiedUnits(5, 50)");
61 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)"); 61 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)");
62 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 'aSt ring')"); 62 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 'aString') ");
63 shouldBe("angle.value", "NaN"); 63 shouldBe("angle.value", "0");
64 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 0)") ; 64 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 0)") ;
65 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, angl e)"); 65 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, angle)");
66 shouldBe("angle.value", "NaN"); 66 shouldBe("angle.value", "0");
67 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, svgE lement)"); 67 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, svgElement )");
68 shouldBe("angle.value", "NaN"); 68 shouldBe("angle.value", "0");
69 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, NaN)");
70 shouldBe("angle.value", "0");
71 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, Infinity)" );
72 shouldBe("angle.value", "0");
69 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)"); 73 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)");
70 // All of the following unitType arguments convert to 0 (SVG_ANGLETYPE_UNKNOWN). 74 // All of the following unitType arguments convert to 0 (SVG_ANGLETYPE_UNKNOWN).
71 shouldThrow("angle.newValueSpecifiedUnits('aString', 4)"); 75 shouldThrow("angle.newValueSpecifiedUnits('aString', 4)");
72 shouldThrow("angle.newValueSpecifiedUnits(angle, 4)"); 76 shouldThrow("angle.newValueSpecifiedUnits(angle, 4)");
73 shouldThrow("angle.newValueSpecifiedUnits(svgElement, 4)"); 77 shouldThrow("angle.newValueSpecifiedUnits(svgElement, 4)");
74 shouldThrow("angle.newValueSpecifiedUnits('aString', 'aString')"); 78 shouldThrow("angle.newValueSpecifiedUnits('aString', 'aString')");
75 shouldThrow("angle.newValueSpecifiedUnits(angle, angle)"); 79 shouldThrow("angle.newValueSpecifiedUnits(angle, angle)");
76 shouldThrow("angle.newValueSpecifiedUnits(svgElement, svgElement)"); 80 shouldThrow("angle.newValueSpecifiedUnits(svgElement, svgElement)");
77 shouldThrow("angle.newValueSpecifiedUnits()"); 81 shouldThrow("angle.newValueSpecifiedUnits()");
78 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG"); 82 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 140 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
137 141
138 shouldThrow("angle.valueAsString = ',5 rad'"); 142 shouldThrow("angle.valueAsString = ',5 rad'");
139 shouldBeEqualToString("angle.valueAsString", "0"); 143 shouldBeEqualToString("angle.valueAsString", "0");
140 shouldBe("angle.value", "0"); 144 shouldBe("angle.value", "0");
141 shouldBe("angle.valueInSpecifiedUnits", "0"); 145 shouldBe("angle.valueInSpecifiedUnits", "0");
142 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 146 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
143 147
144 debug(""); 148 debug("");
145 debug("Check setting invalid 'valueInSpecifiedUnits' arguments"); 149 debug("Check setting invalid 'valueInSpecifiedUnits' arguments");
146 shouldBe("angle.valueInSpecifiedUnits = 'test'", "'test'"); 150 shouldThrow("angle.valueInSpecifiedUnits = 'test'");
147 shouldBe("angle.value", "NaN"); 151 shouldBe("angle.value", "0");
148 shouldBe("angle.valueInSpecifiedUnits", "NaN"); 152 shouldBe("angle.valueInSpecifiedUnits", "0");
149 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 153 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
150 shouldBe("angle.valueInSpecifiedUnits = 0", "0"); 154 shouldBe("angle.valueInSpecifiedUnits = 0", "0");
151 155
152 shouldBe("angle.valueInSpecifiedUnits = angle", "angle"); 156 shouldThrow("angle.valueInSpecifiedUnits = angle");
153 shouldBe("angle.value", "NaN"); 157 shouldBe("angle.value", "0");
154 shouldBe("angle.valueInSpecifiedUnits", "NaN"); 158 shouldThrow("angle.valueInSpecifiedUnits = NaN");
159 shouldBe("angle.value", "0");
160 shouldThrow("angle.valueInSpecifiedUnits = Infinity");
161 shouldBe("angle.value", "0");
162 shouldBe("angle.valueInSpecifiedUnits", "0");
155 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 163 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
156 164
157 debug(""); 165 debug("");
158 debug("Check setting invalid 'value' arguments"); 166 debug("Check setting invalid 'value' arguments");
159 shouldBe("angle.value = 0", "0"); 167 shouldBe("angle.value = 0", "0");
160 shouldBe("angle.value = 'test'", "'test'"); 168 shouldThrow("angle.value = 'test'");
161 shouldBe("angle.value", "NaN"); 169 shouldBe("angle.value", "0");
162 shouldBe("angle.valueInSpecifiedUnits", "NaN"); 170 shouldBe("angle.valueInSpecifiedUnits", "0");
163 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 171 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
164 172
165 shouldBe("angle.value = 0", "0"); 173 shouldBe("angle.value = 0", "0");
166 shouldBe("angle.value = angle", "angle"); 174 shouldThrow("angle.value = angle");
167 shouldBe("angle.value", "NaN"); 175 shouldBe("angle.value", "0");
168 shouldBe("angle.valueInSpecifiedUnits", "NaN"); 176 shouldThrow("angle.value = NaN");
177 shouldBe("angle.value", "0");
178 shouldThrow("angle.value = Infinity");
179 shouldBe("angle.value", "0");
180 shouldBe("angle.valueInSpecifiedUnits", "0");
169 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 181 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED");
170 182
171 debug(""); 183 debug("");
172 debug("Reset to angle in degree units"); 184 debug("Reset to angle in degree units");
173 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 0)") ; 185 shouldBeUndefined("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 0)") ;
174 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG"); 186 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG");
175 187
176 debug(""); 188 debug("");
177 debug("Check setting valid 'value' arguments, assure that 'valueInSpecifiedUnits ' and 'valueAsString' are synchronized"); 189 debug("Check setting valid 'value' arguments, assure that 'valueInSpecifiedUnits ' and 'valueAsString' are synchronized");
178 shouldBe("angle.value = 50", "50"); 190 shouldBe("angle.value = 50", "50");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 229
218 debug(""); 230 debug("");
219 debug("Now convert the RAD value into a DEG value, and assure that all propertie s have been synchronized"); 231 debug("Now convert the RAD value into a DEG value, and assure that all propertie s have been synchronized");
220 shouldBeUndefined("angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)"); 232 shouldBeUndefined("angle.convertToSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)");
221 shouldBeEqualToString("angle.value.toFixed(1)", "180.0"); 233 shouldBeEqualToString("angle.value.toFixed(1)", "180.0");
222 shouldBeEqualToString("angle.valueInSpecifiedUnits.toFixed(1)", "180.0"); 234 shouldBeEqualToString("angle.valueInSpecifiedUnits.toFixed(1)", "180.0");
223 shouldBeEqualToString("angle.valueAsString", "180deg"); 235 shouldBeEqualToString("angle.valueAsString", "180deg");
224 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG"); 236 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_DEG");
225 237
226 successfullyParsed = true; 238 successfullyParsed = true;
OLDNEW
« no previous file with comments | « LayoutTests/svg/dom/SVGTransform-expected.txt ('k') | LayoutTests/svg/dom/script-tests/SVGAnimatedNumber.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698