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

Side by Side Diff: LayoutTests/svg/dom/script-tests/SVGLength.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 SVGLength API"); 1 description("This test checks the SVGLength 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 length = svgElement.createSVGLength(); 4 var length = svgElement.createSVGLength();
5 5
6 debug(""); 6 debug("");
7 debug("Check initial length values"); 7 debug("Check initial length values");
8 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_NUMBER"); 8 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_NUMBER");
9 shouldBe("length.value", "0"); 9 shouldBe("length.value", "0");
10 shouldBe("length.valueInSpecifiedUnits", "0"); 10 shouldBe("length.valueInSpecifiedUnits", "0");
(...skipping 20 matching lines...) Expand all
31 shouldBe("length.value", "2"); 31 shouldBe("length.value", "2");
32 shouldBe("length.valueInSpecifiedUnits", "2"); 32 shouldBe("length.valueInSpecifiedUnits", "2");
33 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX"); 33 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
34 34
35 debug(""); 35 debug("");
36 debug("Check invalid arguments for 'newValueSpecifiedUnits'"); 36 debug("Check invalid arguments for 'newValueSpecifiedUnits'");
37 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4)" ); 37 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4)" );
38 shouldThrow("length.newValueSpecifiedUnits(-1, 4)"); 38 shouldThrow("length.newValueSpecifiedUnits(-1, 4)");
39 shouldThrow("length.newValueSpecifiedUnits(11, 4)"); 39 shouldThrow("length.newValueSpecifiedUnits(11, 4)");
40 // ECMA-262, 9.3, "ToNumber" 40 // ECMA-262, 9.3, "ToNumber"
41 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 'a String')");
42 shouldBe("length.value", "NaN");
43 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0) "); 41 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0) ");
44 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, le ngth)"); 42 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 'aString ')");
45 shouldBe("length.value", "NaN"); 43 shouldBe("length.value", "0");
46 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0) "); 44 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, length)" );
47 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, sv gElement)"); 45 shouldBe("length.value", "0");
48 shouldBe("length.value", "NaN"); 46 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, svgEleme nt)");
47 shouldBe("length.value", "0");
48 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, NaN)");
49 shouldBe("length.value", "0");
50 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, Infinity )");
51 shouldBe("length.value", "0");
49 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX)"); 52 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX)");
50 // Reset to original value above. 53 // Reset to original value above.
51 length.valueAsString = "2px"; 54 length.valueAsString = "2px";
52 shouldThrow("length.newValueSpecifiedUnits('aString', 4)"); 55 shouldThrow("length.newValueSpecifiedUnits('aString', 4)");
53 shouldThrow("length.newValueSpecifiedUnits(length, 4)"); 56 shouldThrow("length.newValueSpecifiedUnits(length, 4)");
54 shouldThrow("length.newValueSpecifiedUnits(svgElement, 4)"); 57 shouldThrow("length.newValueSpecifiedUnits(svgElement, 4)");
55 shouldThrow("length.newValueSpecifiedUnits('aString', 'aString')"); 58 shouldThrow("length.newValueSpecifiedUnits('aString', 'aString')");
56 shouldThrow("length.newValueSpecifiedUnits(length, length)"); 59 shouldThrow("length.newValueSpecifiedUnits(length, length)");
57 shouldThrow("length.newValueSpecifiedUnits(svgElement, svgElement)"); 60 shouldThrow("length.newValueSpecifiedUnits(svgElement, svgElement)");
58 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX"); 61 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
(...skipping 14 matching lines...) Expand all
73 shouldBe("length.value", "2"); 76 shouldBe("length.value", "2");
74 shouldBe("length.valueInSpecifiedUnits", "2"); 77 shouldBe("length.valueInSpecifiedUnits", "2");
75 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX"); 78 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
76 79
77 shouldThrow("length.valueAsString = ',5 em'"); 80 shouldThrow("length.valueAsString = ',5 em'");
78 shouldBeEqualToString("length.valueAsString", "2px"); 81 shouldBeEqualToString("length.valueAsString", "2px");
79 shouldBe("length.value", "2"); 82 shouldBe("length.value", "2");
80 shouldBe("length.valueInSpecifiedUnits", "2"); 83 shouldBe("length.valueInSpecifiedUnits", "2");
81 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX"); 84 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
82 85
86 debug("");
87 debug("Check setting invalid 'value' arguments");
88 shouldThrow("length.value = NaN");
89 shouldThrow("length.value = Infinity");
90 shouldBe("length.value", "2");
91 shouldBe("length.valueInSpecifiedUnits", "2");
92 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
93
94 debug("");
95 debug("Check setting invalid 'valueInSpecifiedUnits' arguments");
96 shouldThrow("length.valueInSpecifiedUnits = NaN");
97 shouldThrow("length.valueInSpecifiedUnits = Infinity");
98 shouldBe("length.value", "2");
99 shouldBe("length.valueInSpecifiedUnits", "2");
100 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
101
83 successfullyParsed = true; 102 successfullyParsed = true;
OLDNEW
« no previous file with comments | « LayoutTests/svg/dom/script-tests/SVGAnimatedNumber.js ('k') | LayoutTests/svg/dom/script-tests/SVGNumber.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698