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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/script-tests/SVGLength.js

Issue 2271223002: Convert LayoutTests/svg/dom/SVGLength*.html js-tests.js tests to testharness.js based tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved length to local Created 4 years, 3 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
OLDNEW
(Empty)
1 description("This test checks the SVGLength API");
2
3 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4 var length = svgElement.createSVGLength();
5
6 debug("");
7 debug("Check initial length values");
8 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_NUMBER");
9 shouldBe("length.value", "0");
10 shouldBe("length.valueInSpecifiedUnits", "0");
11 shouldBeEqualToString("length.valueAsString", "0");
12
13 debug("");
14 debug("Set value to be 2px");
15 length.valueAsString = "2px";
16 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
17 shouldBe("length.value", "2");
18 shouldBe("length.valueInSpecifiedUnits", "2");
19 shouldBeEqualToString("length.valueAsString", "2px");
20
21 debug("");
22 debug("Check invalid arguments for 'convertToSpecifiedUnits'");
23 shouldThrow("length.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN)");
24 shouldThrow("length.convertToSpecifiedUnits(-1)");
25 shouldThrow("length.convertToSpecifiedUnits(11)");
26 shouldThrow("length.convertToSpecifiedUnits('aString')");
27 shouldThrow("length.convertToSpecifiedUnits(length)");
28 shouldThrow("length.convertToSpecifiedUnits(svgElement)");
29 shouldThrow("length.convertToSpecifiedUnits()");
30 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
31 shouldBe("length.value", "2");
32 shouldBe("length.valueInSpecifiedUnits", "2");
33 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
34
35 debug("");
36 debug("Check invalid arguments for 'newValueSpecifiedUnits'");
37 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4)" );
38 shouldThrow("length.newValueSpecifiedUnits(-1, 4)");
39 shouldThrow("length.newValueSpecifiedUnits(11, 4)");
40 // ECMA-262, 9.3, "ToNumber"
41 shouldBeUndefined("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0) ");
42 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 'aString ')");
43 shouldBe("length.value", "0");
44 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, length)" );
45 shouldBe("length.value", "0");
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");
52 shouldThrow("length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX)");
53 // Reset to original value above.
54 length.valueAsString = "2px";
55 shouldThrow("length.newValueSpecifiedUnits('aString', 4)");
56 shouldThrow("length.newValueSpecifiedUnits(length, 4)");
57 shouldThrow("length.newValueSpecifiedUnits(svgElement, 4)");
58 shouldThrow("length.newValueSpecifiedUnits('aString', 'aString')");
59 shouldThrow("length.newValueSpecifiedUnits(length, length)");
60 shouldThrow("length.newValueSpecifiedUnits(svgElement, svgElement)");
61 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
62 shouldBe("length.value", "2");
63 shouldBe("length.valueInSpecifiedUnits", "2");
64 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
65
66 debug("");
67 debug("Check setting invalid 'valueAsString' arguments");
68 shouldThrow("length.valueAsString = '10deg'");
69 shouldBeEqualToString("length.valueAsString", "2px");
70 shouldBe("length.value", "2");
71 shouldBe("length.valueInSpecifiedUnits", "2");
72 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
73
74 shouldNotThrow("length.valueAsString = '1pX'");
75 shouldBeEqualToString("length.valueAsString", "1px");
76 shouldBe("length.value", "1");
77 shouldBe("length.valueInSpecifiedUnits", "1");
78 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
79
80 length.valueAsString = "2px"; // reset to 2px
81
82 shouldThrow("length.valueAsString = ',5 em'");
83 shouldBeEqualToString("length.valueAsString", "2px");
84 shouldBe("length.value", "2");
85 shouldBe("length.valueInSpecifiedUnits", "2");
86 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
87
88 shouldThrow("length.valueAsString = null");
89 shouldBeEqualToString("length.valueAsString", "2px");
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 'value' arguments");
96 shouldThrow("length.value = NaN");
97 shouldThrow("length.value = Infinity");
98 shouldBe("length.value", "2");
99 shouldBe("length.valueInSpecifiedUnits", "2");
100 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
101
102 debug("");
103 debug("Check setting invalid 'valueInSpecifiedUnits' arguments");
104 shouldThrow("length.valueInSpecifiedUnits = NaN");
105 shouldThrow("length.valueInSpecifiedUnits = Infinity");
106 shouldBe("length.value", "2");
107 shouldBe("length.valueInSpecifiedUnits", "2");
108 shouldBe("length.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
109
110 successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698