OLD | NEW |
| (Empty) |
1 description("This test checks the SVGMatrix API"); | |
2 | |
3 var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); | |
4 var matrix = svgElement.createSVGMatrix(); | |
5 | |
6 debug(""); | |
7 debug("Check initial matrix values"); | |
8 shouldBe("matrix.a", "1"); | |
9 shouldBe("matrix.b", "0"); | |
10 shouldBe("matrix.c", "0"); | |
11 shouldBe("matrix.d", "1"); | |
12 shouldBe("matrix.e", "0"); | |
13 shouldBe("matrix.f", "0"); | |
14 | |
15 debug(""); | |
16 debug("Check assigning matrices"); | |
17 shouldBe("matrix.a = 2", "2"); | |
18 shouldBe("matrix.f = 200", "200"); | |
19 | |
20 debug(""); | |
21 debug("Check assigning invalid matrices"); | |
22 shouldBe("matrix.a = matrix", "matrix"); | |
23 shouldBe("matrix.a", "NaN"); | |
24 shouldBe("matrix.a = 0", "0"); | |
25 shouldBe("matrix.a = svgElement", "svgElement"); | |
26 shouldBe("matrix.a", "NaN"); | |
27 shouldBe("matrix.a = 0", "0"); | |
28 shouldBe("matrix.a = 'aString'", "'aString'"); | |
29 shouldBe("matrix.a", "NaN"); | |
30 // Reset to previous value. | |
31 shouldBe("matrix.a = 2", "2"); | |
32 | |
33 shouldBe("matrix.b = matrix", "matrix"); | |
34 shouldBe("matrix.b", "NaN"); | |
35 shouldBe("matrix.b = 0", "0"); | |
36 shouldBe("matrix.b = svgElement", "svgElement"); | |
37 shouldBe("matrix.b", "NaN"); | |
38 shouldBe("matrix.b = 0", "0"); | |
39 shouldBe("matrix.b = 'aString'", "'aString'"); | |
40 shouldBe("matrix.b", "NaN"); | |
41 // Reset to previous value. | |
42 shouldBe("matrix.b = 0", "0"); | |
43 | |
44 shouldBe("matrix.c = matrix", "matrix"); | |
45 shouldBe("matrix.c", "NaN"); | |
46 shouldBe("matrix.c = 0", "0"); | |
47 shouldBe("matrix.c = svgElement", "svgElement"); | |
48 shouldBe("matrix.c", "NaN"); | |
49 shouldBe("matrix.c = 0", "0"); | |
50 shouldBe("matrix.c = 'aString'", "'aString'"); | |
51 shouldBe("matrix.c", "NaN"); | |
52 // Reset to previous value. | |
53 shouldBe("matrix.c = 0", "0"); | |
54 | |
55 shouldBe("matrix.d = matrix", "matrix"); | |
56 shouldBe("matrix.d", "NaN"); | |
57 shouldBe("matrix.d = 0", "0"); | |
58 shouldBe("matrix.d = svgElement", "svgElement"); | |
59 shouldBe("matrix.d", "NaN"); | |
60 shouldBe("matrix.d = 0", "0"); | |
61 shouldBe("matrix.d = 'aString'", "'aString'"); | |
62 shouldBe("matrix.d", "NaN"); | |
63 // Reset to previous value. | |
64 shouldBe("matrix.d = 1", "1"); | |
65 | |
66 shouldBe("matrix.e = matrix", "matrix"); | |
67 shouldBe("matrix.e", "NaN"); | |
68 shouldBe("matrix.e = 0", "0"); | |
69 shouldBe("matrix.e = svgElement", "svgElement"); | |
70 shouldBe("matrix.e", "NaN"); | |
71 shouldBe("matrix.e = 0", "0"); | |
72 shouldBe("matrix.e = 'aString'", "'aString'"); | |
73 shouldBe("matrix.e", "NaN"); | |
74 // Reset to previous value. | |
75 shouldBe("matrix.e = 0", "0"); | |
76 | |
77 shouldBe("matrix.f = matrix", "matrix"); | |
78 shouldBe("matrix.f", "NaN"); | |
79 shouldBe("matrix.f = 0", "0"); | |
80 shouldBe("matrix.f = svgElement", "svgElement"); | |
81 shouldBe("matrix.f", "NaN"); | |
82 shouldBe("matrix.f = 0", "0"); | |
83 shouldBe("matrix.f = 'aString'", "'aString'"); | |
84 shouldBe("matrix.f", "NaN"); | |
85 // Reset to previous value. | |
86 shouldBe("matrix.f = 200", "200"); | |
87 | |
88 debug(""); | |
89 debug("Check that the matrix is still containing the correct values"); | |
90 shouldBe("matrix.a", "2"); | |
91 shouldBe("matrix.b", "0"); | |
92 shouldBe("matrix.c", "0"); | |
93 shouldBe("matrix.d", "1"); | |
94 shouldBe("matrix.e", "0"); | |
95 shouldBe("matrix.f", "200"); | |
96 | |
97 debug(""); | |
98 debug("Check assigning null works as expected"); | |
99 shouldBeNull("matrix.f = null"); | |
100 shouldBe("matrix.a", "2"); | |
101 shouldBe("matrix.b", "0"); | |
102 shouldBe("matrix.c", "0"); | |
103 shouldBe("matrix.d", "1"); | |
104 shouldBe("matrix.e", "0"); | |
105 shouldBe("matrix.f", "0"); | |
106 | |
107 debug(""); | |
108 debug("Check calling 'multiply' with invalid arguments"); | |
109 shouldThrow("matrix.multiply()"); | |
110 shouldThrow("matrix.multiply(true)"); | |
111 shouldThrow("matrix.multiply(2)"); | |
112 shouldThrow("matrix.multiply('aString')"); | |
113 shouldThrow("matrix.multiply(svgElement)"); | |
114 | |
115 debug(""); | |
116 debug("Check calling 'translate' with invalid arguments"); | |
117 shouldThrow("matrix.translate()"); | |
118 shouldThrow("matrix.translate(true)"); | |
119 shouldThrow("matrix.translate(2)"); | |
120 shouldThrow("matrix.translate('aString')"); | |
121 shouldThrow("matrix.translate(svgElement)"); | |
122 // The following string and object arguments convert to NaN | |
123 // per ECMA-262, 9.3, "ToNumber". | |
124 shouldBeNonNull("matrix.translate('aString', 'aString')"); | |
125 shouldBeNonNull("matrix.translate(svgElement, svgElement)"); | |
126 shouldBeNonNull("matrix.translate(2, 'aString')"); | |
127 shouldBeNonNull("matrix.translate(2, svgElement)"); | |
128 shouldBeNonNull("matrix.translate('aString', 2)"); | |
129 shouldBeNonNull("matrix.translate(svgElement, 2)"); | |
130 | |
131 debug(""); | |
132 debug("Check calling 'scale' with invalid arguments"); | |
133 shouldThrow("matrix.scale()"); | |
134 shouldBeNonNull("matrix.scale('aString')"); | |
135 shouldBeNonNull("matrix.scale(svgElement)"); | |
136 | |
137 | |
138 debug(""); | |
139 debug("Check calling 'scaleNonUniform' with invalid arguments"); | |
140 shouldThrow("matrix.scaleNonUniform()"); | |
141 shouldThrow("matrix.scaleNonUniform(true)"); | |
142 shouldThrow("matrix.scaleNonUniform(2)"); | |
143 shouldThrow("matrix.scaleNonUniform('aString')"); | |
144 shouldThrow("matrix.scaleNonUniform(svgElement)"); | |
145 shouldBeNonNull("matrix.scaleNonUniform('aString', 'aString')"); | |
146 shouldBeNonNull("matrix.scaleNonUniform(svgElement, svgElement)"); | |
147 shouldBeNonNull("matrix.scaleNonUniform(2, 'aString')"); | |
148 shouldBeNonNull("matrix.scaleNonUniform(2, svgElement)"); | |
149 shouldBeNonNull("matrix.scaleNonUniform('aString', 2)"); | |
150 shouldBeNonNull("matrix.scaleNonUniform(svgElement, 2)"); | |
151 | |
152 debug(""); | |
153 debug("Check calling 'rotate' with invalid arguments"); | |
154 shouldThrow("matrix.rotate()"); | |
155 shouldBeNonNull("matrix.rotate('aString')"); | |
156 shouldBeNonNull("matrix.rotate(svgElement)"); | |
157 | |
158 debug(""); | |
159 debug("Check calling 'rotateFromVector' with invalid arguments"); | |
160 shouldThrow("matrix.rotateFromVector()"); | |
161 shouldThrow("matrix.rotateFromVector(true)"); | |
162 shouldThrow("matrix.rotateFromVector(2)"); | |
163 shouldThrow("matrix.rotateFromVector('aString')"); | |
164 shouldThrow("matrix.rotateFromVector(svgElement)"); | |
165 shouldBeNonNull("matrix.rotateFromVector('aString', 'aString')"); | |
166 shouldBeNonNull("matrix.rotateFromVector(svgElement, svgElement)"); | |
167 shouldBeNonNull("matrix.rotateFromVector(2, 'aString')"); | |
168 shouldBeNonNull("matrix.rotateFromVector(2, svgElement)"); | |
169 shouldBeNonNull("matrix.rotateFromVector('aString', 2)"); | |
170 shouldBeNonNull("matrix.rotateFromVector(svgElement, 2)"); | |
171 | |
172 debug(""); | |
173 debug("Check calling 'skewX' with invalid arguments"); | |
174 shouldThrow("matrix.skewX()"); | |
175 shouldBeNonNull("matrix.skewX('aString')"); | |
176 shouldBeNonNull("matrix.skewX(svgElement)"); | |
177 | |
178 debug(""); | |
179 debug("Check calling 'skewY' with invalid arguments"); | |
180 shouldThrow("matrix.skewY()"); | |
181 shouldBeNonNull("matrix.skewY('aString')"); | |
182 shouldBeNonNull("matrix.skewY(svgElement)"); | |
183 | |
184 successfullyParsed = true; | |
OLD | NEW |