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

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: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/dom/SVGLength-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML>
2 <html> 2 <title>SVGLength interface</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("NotSupportedError", function() { length.convertToSpecifiedUnits (SVGLength.SVG_LENGTHTYPE_UNKNOWN); });
25 assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits (-1); });
26 assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits (11); });
27 assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits ('aString'); });
28 assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits (length); });
29 assert_throws("NotSupportedError", function() { length.convertToSpecifiedUnits (svgElement); });
30 assert_throws(new TypeError(), function() { length.convertToSpecifiedUnits(); });
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.valueAsString, "2px");
35
36 // Check invalid arguments for 'newValueSpecifiedUnits'.
37 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( SVGLength.SVG_LENGTHTYPE_UNKNOWN, 4); });
38 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( -1, 4); });
39 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( 11, 4); });
40 // ECMA-262, 9.3, "ToNumber".
41 length.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 0);
42 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX, 'aString'); });
43 assert_equals(length.value, 0);
44 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX, length); });
45 assert_equals(length.value, 0);
46 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX, svgElement); });
47 assert_equals(length.value, 0);
48 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX, NaN); });
49 assert_equals(length.value, 0);
50 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX, Infinity); });
51 assert_equals(length.value, 0);
52 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(SVGL ength.SVG_LENGTHTYPE_PX); });
53 // Reset to original value above.
54 length.valueAsString = "2px";
55 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( 'aString', 4); });
56 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( length, 4); });
57 assert_throws("NotSupportedError", function() { length.newValueSpecifiedUnits( svgElement, 4); });
58 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits('aSt ring', 'aString'); });
59 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(leng th, length); });
60 assert_throws(new TypeError(), function() { length.newValueSpecifiedUnits(svgE lement, svgElement); });
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.valueAsString, "2px");
65
66 // Check setting invalid 'valueAsString' arguments.
67 assert_throws("SyntaxError", 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("SyntaxError", 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("SyntaxError", 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(new TypeError(), function() { length.value = NaN; });
95 assert_throws(new TypeError(), 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(new TypeError(), function() { length.valueInSpecifiedUnits = NaN ; });
102 assert_throws(new TypeError(), function() { length.valueInSpecifiedUnits = Inf inity; });
103 assert_equals(length.value, 2);
104 assert_equals(length.valueInSpecifiedUnits, 2);
105 assert_equals(length.unitType, SVGLength.SVG_LENGTHTYPE_PX);
106 });
107 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/dom/SVGLength-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698