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

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

Issue 2741153003: Convert LayoutTests/svg/dom/*.html js-tests.js to testharness.js based tests. (Closed)
Patch Set: Align with review comments Created 3 years, 9 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>SVGMatrix 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 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
7 <p id="description"></p> 7
8 <div id="console"></div> 8 function assert_matrix_component_numeric(matrix, component) {
9 <script src="script-tests/SVGMatrix.js"></script> 9 matrix[component] = matrix;
10 </body> 10 assert_equals(matrix[component], NaN);
11 </html> 11 matrix[component] = 0;
12 assert_equals(matrix[component], 0);
13 matrix[component] = svgElement;
14 assert_equals(matrix[component], NaN);
15 matrix[component] = 0;
16 assert_equals(matrix[component], 0);
17 matrix[component] = 'aString';
18 assert_equals(matrix[component], NaN);
19 }
20
21 test(function() {
22 // This test checks the SVGMatrix API.
23 var matrix = svgElement.createSVGMatrix();
24
25 // Check initial matrix values.
26 assert_equals(matrix.a, 1);
27 assert_equals(matrix.b, 0);
28 assert_equals(matrix.c, 0);
29 assert_equals(matrix.d, 1);
30 assert_equals(matrix.e, 0);
31 assert_equals(matrix.f, 0);
32
33 // Check assigning matrices.
34 matrix.a = 2;
35 assert_equals(matrix.a, 2);
36 matrix.f = 200;
37 assert_equals(matrix.f, 200);
38
39 // Check assigning invalid matrices.
40 assert_matrix_component_numeric(matrix, 'a');
41 // Reset to previous value.
42 matrix.a = 2;
43 assert_equals(matrix.a, 2);
44
45 assert_matrix_component_numeric(matrix, 'b');
46 // Reset to previous value.
47 matrix.b = 0;
48 assert_equals(matrix.b, 0);
49
50 assert_matrix_component_numeric(matrix, 'c');
51 // Reset to previous value.
52 matrix.c = 0;
53 assert_equals(matrix.c, 0);
54
55 assert_matrix_component_numeric(matrix, 'd');
56 // Reset to previous value.
57 matrix.d = 1;
58 assert_equals(matrix.d, 1);
59
60 assert_matrix_component_numeric(matrix, 'e');
61 // Reset to previous value.
62 matrix.e = 0;
63 assert_equals(matrix.e, 0);
64
65 assert_matrix_component_numeric(matrix, 'f');
66 // Reset to previous value.
67 matrix.f = 200;
68 assert_equals(matrix.f, 200);
69
70 // Check that the matrix is still containing the correct values.
71 assert_equals(matrix.a, 2);
72 assert_equals(matrix.b, 0);
73 assert_equals(matrix.c, 0);
74 assert_equals(matrix.d, 1);
75 assert_equals(matrix.e, 0);
76 assert_equals(matrix.f, 200);
77
78 // Check assigning null works as expected.
79 matrix.f = null;
80 assert_equals(matrix.a, 2);
81 assert_equals(matrix.b, 0);
82 assert_equals(matrix.c, 0);
83 assert_equals(matrix.d, 1);
84 assert_equals(matrix.e, 0);
85 assert_equals(matrix.f, 0);
86
87 // Check calling 'multiply' with invalid arguments.
88 assert_throws(new TypeError(), function() { matrix.multiply(); });
89 assert_throws(new TypeError(), function() { matrix.multiply(true); });
90 assert_throws(new TypeError(), function() { matrix.multiply(2); });
91 assert_throws(new TypeError(), function() { matrix.multiply('aString'); });
92 assert_throws(new TypeError(), function() { matrix.multiply(svgElement); });
93
94 // Check calling 'translate' with invalid arguments.
95 assert_throws(new TypeError(), function() { matrix.translate(); });
96 assert_throws(new TypeError(), function() { matrix.translate(true); });
97 assert_throws(new TypeError(), function() { matrix.translate(2); });
98 assert_throws(new TypeError(), function() { matrix.translate('aString'); });
99 assert_throws(new TypeError(), function() { matrix.translate(svgElement); });
100 // The following string and object arguments convert to NaN
101 // per ECMA-262, 9.3, "ToNumber".
102 assert_not_equals(matrix.translate('aString', 'aString'), null);
103 assert_not_equals(matrix.translate(svgElement, svgElement), null);
104 assert_not_equals(matrix.translate(2, 'aString'), null);
105 assert_not_equals(matrix.translate(2, svgElement), null);
106 assert_not_equals(matrix.translate('aString', 2), null);
107 assert_not_equals(matrix.translate(svgElement, 2), null);
108
109 // Check calling 'scale' with invalid arguments.
110 assert_throws(new TypeError(), function() { matrix.scale(); });
111 assert_not_equals(matrix.scale('aString'), null);
112 assert_not_equals(matrix.scale(svgElement), null);
113
114
115 // Check calling 'scaleNonUniform' with invalid arguments.
116 assert_throws(new TypeError(), function() { matrix.scaleNonUniform(); });
117 assert_throws(new TypeError(), function() { matrix.scaleNonUniform(true); });
118 assert_throws(new TypeError(), function() { matrix.scaleNonUniform(2); });
119 assert_throws(new TypeError(), function() { matrix.scaleNonUniform('aString'); });
120 assert_throws(new TypeError(), function() { matrix.scaleNonUniform(svgElement) ; });
121 assert_not_equals(matrix.scaleNonUniform('aString', 'aString'), null);
122 assert_not_equals(matrix.scaleNonUniform(svgElement, svgElement), null);
123 assert_not_equals(matrix.scaleNonUniform(2, 'aString'), null);
124 assert_not_equals(matrix.scaleNonUniform(2, svgElement), null);
125 assert_not_equals(matrix.scaleNonUniform('aString', 2), null);
126 assert_not_equals(matrix.scaleNonUniform(svgElement, 2), null);
127
128 // Check calling 'rotate' with invalid arguments.
129 assert_throws(new TypeError(), function() { matrix.rotate(); });
130 assert_not_equals(matrix.rotate('aString'), null);
131 assert_not_equals(matrix.rotate(svgElement), null);
132
133 // Check calling 'rotateFromVector' with invalid arguments.
134 assert_throws(new TypeError(), function() { matrix.rotateFromVector(); });
135 assert_throws(new TypeError(), function() { matrix.rotateFromVector(true); });
136 assert_throws(new TypeError(), function() { matrix.rotateFromVector(2); });
137 assert_throws(new TypeError(), function() { matrix.rotateFromVector('aString') ; });
138 assert_throws(new TypeError(), function() { matrix.rotateFromVector(svgElement ); });
139 assert_not_equals(matrix.rotateFromVector('aString', 'aString'), null);
140 assert_not_equals(matrix.rotateFromVector(svgElement, svgElement), null);
141 assert_not_equals(matrix.rotateFromVector(2, 'aString'), null);
142 assert_not_equals(matrix.rotateFromVector(2, svgElement), null);
143 assert_not_equals(matrix.rotateFromVector('aString', 2), null);
144 assert_not_equals(matrix.rotateFromVector(svgElement, 2), null);
145
146 // Check calling 'skewX' with invalid arguments.
147 assert_throws(new TypeError(), function() { matrix.skewX(); });
148 assert_not_equals(matrix.skewX('aString'), null);
149 assert_not_equals(matrix.skewX(svgElement), null);
150
151 // Check calling 'skewY' with invalid arguments;
152 assert_throws(new TypeError(), function() { matrix.skewY(); });
153 assert_not_equals(matrix.skewY('aString'), null);
154 assert_not_equals(matrix.skewY(svgElement), null);
155 });
156 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698