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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLength.html

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: 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
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML>
2 <html> 2 <title>Checks the SVGLength API</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 </head> 5 <script>
6 <body> 6 test(function() {
7 <p id="description"></p> 7 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg") ;
8 <div id="console"></div> 8 var length = svgElement.createSVGLength();
9 <script src="script-tests/SVGLength.js"></script> 9
10 </body> 10 // Check initial length values
11 </html> 11 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_NUMBER);
12 assert_equals(length.value, 0);
13 assert_equals(length.valueInSpecifiedUnits, 0);
14 assert_equals(length.valueAsString, "0");
15
16 // Set value to be 2px
17 length.valueAsString = "2px";
18 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
19 assert_equals(length.value, 2);
20 assert_equals(length.valueInSpecifiedUnits, 2);
21 assert_equals(length.valueAsString, "2px");
22
23 // Check invalid arguments for 'convertToSpecifiedUnits'
24 assert_throws(null, function() { length.convertToSpecifiedUnits(SVGLength.SVG_ LENGTHTYPE_UNKNOWN); });
25 assert_throws(null, function() { length.convertToSpecifiedUnits(-1); });
26 assert_throws(null, function() { length.convertToSpecifiedUnits(11); });
27 assert_throws(null, function() { length.convertToSpecifiedUnits('aString'); }) ;
28 assert_throws(null, function() { length.convertToSpecifiedUnits(length); });
29 assert_throws(null, function() { length.convertToSpecifiedUnits(svgElement); } );
30 assert_throws(null, function() { length.convertToSpecifiedUnits(); });
Srirama 2016/08/25 05:18:52 can you check for TypeError instead of null as in
Shanmuga Pandi 2016/08/25 07:14:52 Done.
31 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
32 assert_equals(length.value, 2);
33 assert_equals(length.valueInSpecifiedUnits, 2);
34 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
35
36 // Check invalid arguments for 'newValueSpecifiedUnits'
37 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_UNKNOWN, 4); });
38 assert_throws(null, function() { length.newValueSpecifiedUnits(-1, 4); });
39 assert_throws(null, function() { length.newValueSpecifiedUnits(11, 4); });
40 // ECMA-262, 9.3, "ToNumber"
41 length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0);
42 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX, 'aString'); });
43 assert_equals(length.value, 0);
44 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX, length); });
45 assert_equals(length.value, 0);
46 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX, svgElement); });
47 assert_equals(length.value, 0);
48 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX, NaN); });
49 assert_equals(length.value, 0);
50 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX, Infinity); });
51 assert_equals(length.value, 0);
52 assert_throws(null, function() { length.newValueSpecifiedUnits(SVGLength.SVG_L ENGTHTYPE_PX); });
53 // Reset to original value above.
54 length.valueAsString = "2px";
55 assert_throws(null, function() { length.newValueSpecifiedUnits('aString', 4); });
56 assert_throws(null, function() { length.newValueSpecifiedUnits(length, 4); });
57 assert_throws(null, function() { length.newValueSpecifiedUnits(svgElement, 4); });
58 assert_throws(null, function() { length.newValueSpecifiedUnits('aString', 'aSt ring'); });
59 assert_throws(null, function() { length.newValueSpecifiedUnits(length, length) ; });
60 assert_throws(null, function() { length.newValueSpecifiedUnits(svgElement, svg Element); });
61 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
62 assert_equals(length.value, 2);
63 assert_equals(length.valueInSpecifiedUnits, 2);
64 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
65
66 // Check setting invalid 'valueAsString' arguments
67 assert_throws(null, function() { length.valueAsString = '10deg'; });
68 assert_equals(length.valueAsString, "2px");
69 assert_equals(length.value, 2);
70 assert_equals(length.valueInSpecifiedUnits, 2);
71 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
72
73 length.valueAsString = '1pX'; // should not throw exception
74 assert_equals(length.valueAsString, "1px");
75 assert_equals(length.value, 1);
76 assert_equals(length.valueInSpecifiedUnits, 1);
77 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
78
79 length.valueAsString = "2px"; // reset to 2px
80
81 assert_throws(null, function() { length.valueAsString = ',5 em'; });
82 assert_equals(length.valueAsString, "2px");
83 assert_equals(length.value, 2);
84 assert_equals(length.valueInSpecifiedUnits, 2);
85 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
86
87 assert_throws(null, function() { length.valueAsString = null; });
88 assert_equals(length.valueAsString, "2px");
89 assert_equals(length.value, 2);
90 assert_equals(length.valueInSpecifiedUnits, 2);
91 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
92
93 // Check setting invalid 'value' arguments
94 assert_throws(null, function() { length.value = NaN; });
95 assert_throws(null, function() { length.value = Infinity; });
96 assert_equals(length.value, 2);
97 assert_equals(length.valueInSpecifiedUnits, 2);
98 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
99
100 // Check setting invalid 'valueInSpecifiedUnits' arguments
101 assert_throws(null, function() { length.valueInSpecifiedUnits = NaN; });
102 assert_throws(null, function() { length.valueInSpecifiedUnits = Infinity; });
103 assert_equals(length.value, 2);
104 assert_equals(length.valueInSpecifiedUnits, 2);
105 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
106 });
107 </script>
108
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698