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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.xhtml

Issue 2362653002: Convert LayoutTests/svg/dom/SVGTransform*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: Align with review comments 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 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <script>window.enablePixelTesting = true;</script>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/SVGTransformList-helper.js"></script>
6 </head>
7 <body>
8 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
9 <circle id="circle1" cx="40" cy="40" r="40" fill="green" transform="scale(2, 2) translate(10 10)"/>
10 </svg>
11
12 <p id="description"></p>
13 <div id="console"></div>
14 <script type="text/javascript">
15 <![CDATA[
16 description("This is a test of the simple SVGTransformList API parts.");
17
18 if (window.testRunner)
19 testRunner.dumpAsText();
20
21 var svg = document.getElementById("svg");
22 var circle1 = document.getElementById("circle1");
23 var transformList = circle1.transform.baseVal;
24
25 // Spec: The object referenced by animVal will always be distinct from the o ne referenced by baseVal, even when the attribute is not animated.
26 shouldBeTrue("circle1.transform.baseVal != circle1.transform.animVal");
27
28 shouldBe("circle1.transform.baseVal.numberOfItems", "2");
29 shouldBe("circle1.transform.animVal.numberOfItems", "2");
30 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
31 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
32
33 debug("");
34 debug("Test uncommon arguments for initialize()");
35 shouldThrow("transformList.initialize(30)");
36 shouldThrow("transformList.initialize('aString')");
37 shouldThrow("transformList.initialize(circle1)");
38 shouldThrow("transformList.initialize(null)");
39
40 debug("");
41 debug("Test uncommon arguments for getItem()");
42 shouldThrow("transformList.getItem(30)");
43 shouldBeEqualToString("transformList.getItem('aString').toString()", "type=S VG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
44 shouldBeEqualToString("transformList.getItem(circle1).toString()", "type=SVG _TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
45 shouldBeEqualToString("transformList.getItem(null).toString()", "type=SVG_TR ANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
46
47 debug("");
48 debug("Test uncommon arguments for insertItemBefore()");
49 shouldThrow("transformList.insertItemBefore(30)");
50 shouldThrow("transformList.insertItemBefore('aString')");
51 shouldThrow("transformList.insertItemBefore(circle1)");
52 shouldThrow("transformList.insertItemBefore(null)");
53
54 shouldBeEqualToString("transformList.insertItemBefore(transformList.getItem( 1), 'aString').toString()", "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1. 0 10.0 10.0]");
55 shouldBe("transformList.numberOfItems", "3");
56 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
57 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
58 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
59 shouldBeEqualToString("circle1.getAttribute('transform')", "translate(10 10) scale(2 2) translate(10 10)");
60
61 shouldBeEqualToString("transformList.insertItemBefore(transformList.getItem( 1), circle1).toString()", "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
62 shouldBe("transformList.numberOfItems", "4");
63 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
64 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
65 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
66 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
67 shouldBeEqualToString("circle1.getAttribute('transform')", "scale(2 2) trans late(10 10) scale(2 2) translate(10 10)");
68
69 shouldBeEqualToString("transformList.insertItemBefore(transformList.getItem( 1), null).toString()", "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10. 0 10.0]");
70 shouldBe("transformList.numberOfItems", "5");
71 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
72 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
73 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
74 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
75 shouldBeEqualToString("transformList.getItem(4).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
76 shouldBeEqualToString("circle1.getAttribute('transform')", "translate(10 10) scale(2 2) translate(10 10) scale(2 2) translate(10 10)");
77
78 shouldBeEqualToString("transformList.insertItemBefore(transformList.getItem( 1), 0).toString()", "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]") ;
79 shouldBe("transformList.numberOfItems", "6");
80 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
81 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
82 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
83 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
84 shouldBeEqualToString("transformList.getItem(4).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
85 shouldBeEqualToString("transformList.getItem(5).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
86 shouldBeEqualToString("circle1.getAttribute('transform')", "scale(2 2) trans late(10 10) scale(2 2) translate(10 10) scale(2 2) translate(10 10)");
87
88 shouldThrow("transformList.insertItemBefore(30, 0)");
89 shouldThrow("transformList.insertItemBefore('aString', 0)");
90 shouldThrow("transformList.insertItemBefore(circle1, 0)");
91 shouldThrow("transformList.insertItemBefore(null, 0)");
92
93 debug("");
94 debug("Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1");
95 shouldBeUndefined("circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)')");
96 shouldBe("transformList.numberOfItems", "4");
97 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
98 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
99 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
100 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
101 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(90) scale (2 2) translate(10 10) skewX(45)");
102
103 debug("");
104 debug("Test uncommon arguments for replaceItem()");
105 shouldThrow("transformList.replaceItem(30)");
106 shouldThrow("transformList.replaceItem('aString')");
107 shouldThrow("transformList.replaceItem(circle1)");
108 shouldThrow("transformList.replaceItem(null)");
109 shouldThrow("transformList.replaceItem(30, 0)");
110 shouldThrow("transformList.replaceItem('aString', 0)");
111 shouldThrow("transformList.replaceItem(circle1, 0)");
112 shouldThrow("transformList.replaceItem(null, 0)");
113
114 debug("");
115 debug("Test uncommon values for indexed setter");
116 shouldThrow("transformList[0] = 30");
117 shouldThrow("transformList[0] = 'aString'");
118 shouldThrow("transformList[0] = circle1");
119 shouldThrow("transformList[0] = null");
120
121 shouldBeEqualToString("transformList.replaceItem(transformList.getItem(0), 0 ).toString()", "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
122 shouldBe("transformList.numberOfItems", "4");
123 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
124 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
125 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
126 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
127 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(90) scale (2 2) translate(10 10) skewX(45)");
128
129 shouldBeEqualToString("transformList.replaceItem(transformList.getItem(0), ' aString').toString()", "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0 .0]");
130 shouldBe("transformList.numberOfItems", "4");
131 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
132 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
133 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
134 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
135 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(90) scale (2 2) translate(10 10) skewX(45)");
136
137 shouldBeEqualToString("transformList.replaceItem(transformList.getItem(0), c ircle1).toString()", "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0 ]");
138 shouldBe("transformList.numberOfItems", "4");
139 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
140 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
141 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
142 shouldBeEqualToString("transformList.getItem(3).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
143 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(90) scale (2 2) translate(10 10) skewX(45)");
144
145 shouldBeEqualToString("transformList.replaceItem(transformList.getItem(0), n ull).toString()", "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]") ;
146 shouldBe("transformList.numberOfItems", "4");
147 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(90) scale (2 2) translate(10 10) skewX(45)");
148
149 debug("");
150 debug("Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1");
151 shouldBeUndefined("circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)')");
152
153 debug("");
154 debug("Test uncommon arguments for removeItem()");
155 shouldThrow("transformList.removeItem(30)");
156
157 shouldBeEqualToString("transformList.removeItem(0).toString()", "type=SVG_TR ANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
158 shouldBe("transformList.numberOfItems", "3");
159 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
160 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
161 shouldBeEqualToString("transformList.getItem(2).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
162 shouldBeEqualToString("circle1.getAttribute('transform')", "scale(2 2) trans late(10 10) skewX(45)");
163
164 shouldBeEqualToString("transformList.removeItem('aString').toString()", "typ e=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
165 shouldBe("transformList.numberOfItems", "2");
166 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
167 shouldBeEqualToString("transformList.getItem(1).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
168 shouldBeEqualToString("circle1.getAttribute('transform')", "translate(10 10) skewX(45)");
169
170 shouldBeEqualToString("transformList.removeItem(circle1).toString()", "type= SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
171 shouldBe("transformList.numberOfItems", "1");
172 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
173 shouldBeEqualToString("circle1.getAttribute('transform')", "skewX(45)");
174
175 debug("");
176 debug("Test uncommon arguments for appendItem()");
177 shouldThrow("transformList.appendItem(30)");
178 shouldThrow("transformList.appendItem('aString')");
179 shouldThrow("transformList.appendItem(circle1)");
180 shouldThrow("transformList.appendItem(null)");
181
182 debug("");
183 debug("Testing animVal clear throws");
184 shouldThrow("circle1.transform.animVal.clear()");
185 shouldBeUndefined("transformList.clear()");
186
187 debug("");
188 debug("Creating new SVGTransform, with 45 deg rotation about x=50, y=100 and append it to the transform list");
189 var transform;
190 shouldBeEqualToString("(transform = svg.createSVGTransform()).toString()", " type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 0.0 0.0]");
191 shouldBeUndefined("transform.setRotate(45, 50, 100)");
192
193 shouldBeEqualToString("transformList.appendItem(transform).toString()", "typ e=SVG_TRANSFORM_ROTATE matrix=[0.7 0.7 -0.7 0.7 85.4 -6.1]");
194 shouldBe("transformList.numberOfItems", "1");
195 shouldBeEqualToString("transformList.getItem(0).toString()", "type=SVG_TRANS FORM_ROTATE matrix=[0.7 0.7 -0.7 0.7 85.4 -6.1]");
196 shouldBeEqualToString("circle1.getAttribute('transform')", "rotate(45 50 100 )");
197
198 ]]>
199 </script>
200 </body>
201 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698