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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-node/animation-node-after.html

Issue 1866333004: Import web-platform-tests@5a8700479d98852455bee6117558897867eb278a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wpt-sync
Patch Set: Add two potential timeouts to TestExpectations Created 4 years, 8 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 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>AnimationNode after() method tests</title>
4 <meta name="assert" content="Inserts nodes after this animation node">
5 <link rel="help" href="http://w3c.github.io/web-animations/#dom-animationnode-af ter">
6 <link rel="help" href="http://w3c.github.io/web-animations/#insert-children">
7 <link rel="help" href="http://w3c.github.io/web-animations/#remove-an-animation- node">
8 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
9 <link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru" >
10 <script src="../../../../resources/testharness.js"></script>
11 <script src="../../../../resources/testharnessreport.js"></script>
12 <script src="../testcommon.js"></script>
13 <body>
14 <div id="log"></div>
15 <script>
16 // Test step 1. If there is no parent animation group, terminate these steps.
17 test(function() {
18 var nodes = [newAnimation(createDiv(this)), new AnimationGroup([]), new Anim ationSequence([])];
19 nodes.forEach(function(node) {
20 try {
21 node.after(null);
22 } catch(e) {
23 assert_unreached(type(node) + '.after(null) throws unexpected except ion: ' + e);
24 }
25 });
26 }, 'AnimationNode.after() does nothing if the node has no parent animation group . ' +
27 'HierarchyRequestError is not thrown in call node.after(null)');
28
29 test(function() {
30 var nodes = [newAnimation(createDiv(this)), new AnimationGroup([]), new Anim ationSequence([])];
31 nodes.forEach(function(node) {
32 try {
33 node.after(node);
34 } catch(e) {
35 assert_unreached(type(node) + '.after() throws unexpected exception: ' + e);
36 }
37 });
38 }, 'AnimationNode.after() does nothing if the node has no parent animation group . ' +
39 'No HierarchyRequestError is thrown if the node is inserted after itself');
40
41 test(function() {
42 var nodes = [newAnimation(createDiv(this)), new AnimationGroup([]), new Anim ationSequence([])];
43 var node2 = newAnimation(createDiv(this));
44 nodes.forEach(function(node1) {
45 node1.after(node2);
46
47 assert_equals(node1.nextSibling, null, type(node1) + '.after() should do nothing ' +
48 'if the node has no parent animation group');
49 assert_equals(node2.previousSibling, null, type(node1) + '.after() shoul d do nothing ' +
50 'if the node has no parent animation group');
51 });
52 }, 'AnimationNode.after() does nothing if there is no parent animation group');
53
54 // Test step 2. If any of the animation nodes in nodes is an inclusive ancestor of this animation node throw a HierarchyRequestError exception and terminate the se steps.
55 test(function() {
56 var test = this;
57 var parents = [AnimationGroup, AnimationSequence];
58 parents.forEach(function(parentCtor) {
59 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
60 nodes.forEach(function(node) {
61 var parent = new parentCtor([node]);
62
63 assert_throws('HierarchyRequestError', function() {
64 node.after(node);
65 }, type(node) + '.after() should throw HierarchyRequestError ' +
66 'if inserting node after itself');
67 assert_equals(node.parent, parent, type(node) + '.after() should not change ' +
68 'parent attribute before throwing HierarchyRequestError');
69 assert_array_equals(parent.children, [node], type(node) + '.after() ' +
70 'should not change parent children before throwing HierarchyRequ estError');
71 });
72 });
73 }, 'HierarchyRequestError is thrown if node is inserted after itself');
74
75 test(function() {
76 var test = this;
77 var parents = [AnimationGroup, AnimationSequence];
78 parents.forEach(function(parentCtor) {
79 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
80 nodes.forEach(function(node) {
81 var parent = new parentCtor([node]);
82
83 assert_throws('HierarchyRequestError', function() {
84 node.after(parent);
85 }, type(node) + '.after() should throw HierarchyRequestError ' +
86 'if inserting node\'s parent');
87 assert_equals(node.parent, parent, type(node) + '.after() should not change ' +
88 'parent attribute before throwing HierarchyRequestError');
89 assert_array_equals(parent.children, [node], type(node) + '.after() ' +
90 'should not change parent children before throwing HierarchyRequ estError');
91 });
92 });
93 }, 'HierarchyRequestError is thrown if direct parent is inserted after the node' );
94
95 test(function() {
96 var test = this;
97 var parents = [AnimationGroup, AnimationSequence];
98 parents.forEach(function(parentCtor) {
99 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
100 nodes.forEach(function(node) {
101 var parent1 = new parentCtor([node]);
102 var parent2 = new parentCtor([parent1]);
103 var parent3 = new parentCtor([parent2]);
104 var parent4 = new parentCtor([parent3]);
105
106 assert_throws('HierarchyRequestError', function() {
107 node.after(parent3);
108 }, type(node) + '.after() should throw HierarchyRequestError ' +
109 'if inserting node\'s ancestor');
110 assert_equals(node.parent, parent1, type(node) + '.after() should no t change ' +
111 'parent attribute before throwing HierarchyRequestError');
112 assert_array_equals(parent1.children, [node], type(node) + '.after() ' +
113 'should not change parent children before throwing HierarchyRequ estError');
114 assert_equals(parent3.parent, parent4, type(node) + '.after() should not change ' +
115 'parent attribute of inserted node before throwing HierarchyRequ estError');
116 assert_array_equals(parent4.children, [parent3], type(node) + '.afte r() ' +
117 'should not change inserted node parent children before throwing HierarchyRequestError');
118 });
119 });
120 }, 'HierarchyRequestError is thrown if an inclusive ancestor is inserted after t he node');
121
122 test(function() {
123 var test = this;
124 var parents = [AnimationGroup, AnimationSequence];
125 parents.forEach(function(parentCtor) {
126 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
127 nodes.forEach(function(node1) {
128 var node2 = newAnimation(createDiv(test));
129 var node3 = newAnimation(createDiv(test));
130 var parent1 = new parentCtor([node1, node2]);
131 var parent2 = new parentCtor([parent1]);
132 var parent3 = new parentCtor([parent2]);
133 var parent4 = new parentCtor([parent3]);
134 var parent5 = new ParentCtor([node3]);
135
136 assert_throws('HierarchyRequestError', function() {
137 node1.after(node3, parent3);
138 }, type(node1) + '.after() should throw HierarchyRequestError ' +
139 'if inserting node\'s parent');
140 assert_equals(node1.parent, parent1, type(node1) + '.after() should not change ' +
141 'parent attribute before throwing HierarchyRequestError');
142 assert_array_equals(parent1.children, [node1, node2], type(node1) + '.after() ' +
143 'should not change parent children before throwing HierarchyRequ estError');
144 assert_equals(parent3.parent, parent4, type(node1) + '.after() shoul d not change ' +
145 'parent attribute of inserted node before throwing HierarchyRequ estError');
146 assert_array_equals(parent4.children, [parent3], type(node1) + '.aft er() ' +
147 'should not change inserted node parent children before throwing HierarchyRequestError');
148 assert_equals(node3.parent, parent5, type(node1) + '.after() should not change ' +
149 'parent attribute of inserted node before throwing HierarchyRequ estError');
150 assert_array_equals(parent5.children, [node3], type(node1) + '.after () ' +
151 'should not change inserted node parent children before throwing HierarchyRequestError');
152 });
153 });
154 }, 'HierarchyRequestError is thrown if an inclusive ancestor is inserted after t he node. ' +
155 'Test several arguments in after() call');
156
157 // Test step 3 and 4.
158 // 3. Let reference child be the next sibling of this animation node not in node s.
159 // 4. Insert nodes before reference child.
160 test(function() {
161 var test = this;
162 var parents = [AnimationGroup, AnimationSequence];
163 parents.forEach(function(parentCtor) {
164 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
165 nodes.forEach(function(node1) {
166 var node2 = newAnimation(createDiv(test));
167 var parent = new parentCtor([node1]);
168
169 node1.after(node2);
170
171 assert_equals(node2.previousSibling, node1, type(node1) + '.after() should insert ' +
172 'nodes after this node');
173 assert_equals(node2.parent, parent, 'Node should be inserted into th e tree');
174 assert_equals(node1.nextSibling, node2, 'Node should be inserted int o the tree ' +
175 'after this node');
176 assert_equals(parent.children, [node1, node2], parentCtor.name +
177 '.children should be updated');
178 });
179 });
180 }, 'AnimationNode.after() inserts nodes after this node');
181
182 test(function() {
183 var test = this;
184 var parents = [AnimationGroup, AnimationSequence];
185 parents.forEach(function(parentCtor) {
186 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
187 nodes.forEach(function(node2) {
188 var node1 = newAnimation(createDiv(test));
189 var parent = new parentCtor([node1, node2]);
190
191 node2.after(node1);
192
193 assert_equals(node2.previousSibling, null, type(node2) + '.after() s hould insert ' +
194 'nodes after this node');
195 assert_equals(node2.nextSibling, node1, 'Node should be inserted int o the tree ' +
196 'after this node');
197 assert_equals(node1.previousSibling, node2, type(node2) + '.after() should insert ' +
198 'nodes after this node');
199 assert_equals(node1.nextSibling, null, 'Node should be inserted into the tree ' +
200 'after this node');
201 assert_equals(parent.children, [node2, node1], parentCtor.name +
202 '.children should be updated');
203 });
204 });
205 }, 'AnimationNode.after() inserts nodes after this node. Inserted node is on the same ' +
206 'level in the tree');
207
208 test(function() {
209 var test = this;
210 var parents = [AnimationGroup, AnimationSequence];
211 parents.forEach(function(parentCtor) {
212 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
213 nodes.forEach(function(node1) {
214 var node2 = newAnimation(createDiv(test));
215 var parent = new parentCtor([node1, node2]);
216
217 node1.after(node2);
218
219 assert_equals(node1.nextSibling, node2, type(node1) + '.after() shou ld insert ' +
220 'nodes after this node');
221 assert_equals(node2.previousSibling, node1, 'Node should be inserted into the tree ' +
222 'after this node');
223 assert_equals(parent.children, [node1, node2], parentCtor.name +
224 '.children should not be changed');
225 });
226 });
227 }, 'Test AnimationNode.after() inserts node after this node even if inserted ' +
228 'node is already after this one');
229
230 test(function() {
231 var test = this;
232 var parents = [AnimationGroup, AnimationSequence];
233 parents.forEach(function(parentCtor) {
234 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
235 nodes.forEach(function(node3) {
236 var node1 = newAnimation(createDiv(test));
237 var node2 = newAnimation(createDiv(test));
238 var node4 = newAnimation(createDiv(test));
239 var parent1 = new parentCtor([node1, node2]);
240 var parent2 = new parentCtor([node3, parent1, node4]);
241
242 node3.after(node1);
243
244 assert_equals(node1.nextSibling, parent1, type(node3) + '.after() sh ould insert ' +
245 'nodes after this node');
246 assert_equals(node1.parent, parent2, 'Parent group of the inserted n ode should be changed');
247 assert_equals(node1.previousSibling, node3, 'Node should be inserted into the tree ' +
248 'after this node');
249
250 assert_equals(node3.nextSibling, node1, type(node3) + '.after() shou ld insert ' +
251 'nodes after this node');
252 assert_equals(parent1.previousSibling, node1, type(node3) + '.after( ) should insert ' +
253 'nodes after this node');
254
255 assert_equals(node2.previousSibling, null, 'Inserted node should be removed from its ' +
256 'previous position in the tree');
257 assert_array_equals(parent1.children, [node2], 'Inserted node should be removed from its ' +
258 'previous position in the tree');
259 assert_array_equals(parent2.children, [node1, node3, parent1, node4] , parentCtor.name +
260 '.children should be updated');
261 });
262 });
263 }, 'Test AnimationNode.after() inserts node after this node. The previous positi on ' +
264 'of the inserted node is deeper in the tree than current node');
265
266 test(function() {
267 var test = this;
268 var parents = [AnimationGroup, AnimationSequence];
269 parents.forEach(function(parentCtor) {
270 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
271 nodes.forEach(function(node1) {
272 var node2 = newAnimation(createDiv(test));
273 var node3 = newAnimation(createDiv(test));
274 var node4 = newAnimation(createDiv(test));
275 var parent1 = new parentCtor([node1, node2]);
276 var parent2 = new parentCtor([node3, parent1, node4]);
277
278 node1.after(node4);
279
280 assert_equals(node4.nextSibling, node2, type(node1) + '.after() shou ld insert ' +
281 'nodes after this node');
282 assert_equals(node4.parent, parent1, 'Parent group of the inserted n ode should be changed');
283 assert_equals(node4.previousSibling, node1, type(node1) + '.after() should insert ' +
284 'nodes after this node');
285
286 assert_equals(node1.nextSibling, node4, type(node1) + '.after() shou ld insert ' +
287 'nodes after this node');
288 assert_equals(node2.previousSibling, node4, 'Node should be inserted into the tree ' +
289 'after this node');
290
291 assert_equals(parent1.nextSibling, null, 'Inserted node should be re moved from its ' +
292 'previous position in the tree');
293 assert_array_equals(parent1.children, [node1, node4, node2], parentC tor.name +
294 '.children should be updated');
295 assert_array_equals(parent2.children, [node3, parent1], 'Inserted no de should be ' +
296 'removed from its previous position in the tree');
297 });
298 });
299 }, 'Test AnimationNode.after() inserts node after this node. The previous positi on ' +
300 'of the inserted node is shallower in the tree than current node, but not an cestor');
301
302 test(function() {
303 var test = this;
304 var parents = [AnimationGroup, AnimationSequence];
305 parents.forEach(function(parentCtor) {
306 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
307 nodes.forEach(function(node1) {
308 var node2 = newAnimation(createDiv(test));
309 var node3 = newAnimation(createDiv(test));
310 var node4 = newAnimation(createDiv(test));
311 var parent = new parentCtor([node1, node2]);
312
313 node1.after(node3, node4);
314
315 assert_equals(node1.nextSibling, node3, type(node1) + '.after() shou ld insert ' +
316 'nodes after this node');
317 assert_equals(node3.previousSibling, node1, type(node1) + '.after() should insert ' +
318 'nodes after this node');
319 assert_equals(node3.nextSibling, node4, type(node1) + '.after() shou ld insert ' +
320 'nodes after this node');
321 assert_equals(node3.parent, parent, 'Parent group of the inserted no de should be changed');
322 assert_equals(node4.previousSibling, node3, type(node1) + '.after() should insert ' +
323 'nodes after this node');
324 assert_equals(node4.nextSibling, node2, type(node1) + '.after() shou ld insert ' +
325 'nodes after this node');
326 assert_equals(node4.parent, parent, 'Parent group of the inserted no de should be changed');
327 assert_equals(node2.previousSibling, node4, type(node1) + '.after() should insert ' +
328 'nodes after this node');
329 assert_array_equals(parent.children, [node1, node3, node4, node2], p arentCtor.name +
330 '.children should be updated');
331 });
332 });
333 }, 'Test AnimationNode.after() inserts several nodes after this node');
334
335 test(function() {
336 var test = this;
337 var parents = [AnimationGroup, AnimationSequence];
338 parents.forEach(function(parentCtor) {
339 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
340 nodes.forEach(function(node1) {
341 var node2 = newAnimation(createDiv(test));
342 var node3 = newAnimation(createDiv(test));
343 var node4 = newAnimation(createDiv(test));
344 var parent = new parentCtor([node1, node2]);
345
346 node1.after(node3, node4, node3, node4);
347
348 assert_equals(node1.nextSibling, node3, type(node1) + '.after() shou ld insert ' +
349 'nodes after this node');
350 assert_equals(node3.previousSibling, node1, type(node1) + '.after() should insert ' +
351 'nodes after this node');
352 assert_equals(node3.nextSibling, node4, type(node1) + '.after() shou ld insert ' +
353 'nodes after this node');
354 assert_equals(node3.parent, parent, 'Parent group of the inserted no de should be changed');
355 assert_equals(node4.previousSibling, node3, type(node1) + '.after() should insert ' +
356 'nodes after this node');
357 assert_equals(node4.nextSibling, node2, type(node1) + '.after() shou ld insert ' +
358 'nodes after this node');
359 assert_equals(node4.parent, parent, 'Parent group of the inserted no de should be changed');
360 assert_equals(node2.previousSibling, node4, type(node1) + '.after() should insert ' +
361 'nodes after this node');
362 assert_array_equals(parent.children, [node1, node3, node4, node2], p arentCtor.name +
363 '.children should be updated');
364 });
365 });
366 }, 'Test AnimationNode.after() inserts several nodes after this node, duplicate nodes are ignored');
367
368 test(function() {
369 var test = this;
370 var parents = [AnimationGroup, AnimationSequence];
371 parents.forEach(function(parentCtor) {
372 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
373 nodes.forEach(function(node1) {
374 var node2 = newAnimation(createDiv(test));
375 var node3 = newAnimation(createDiv(test));
376 var node4 = newAnimation(createDiv(test));
377 var parent = new parentCtor([node1, node2]);
378
379 node1.after(node3, node4, node3);
380
381 assert_equals(node1.nextSibling, node4, type(node1) + '.after() shou ld insert ' +
382 'nodes after this node');
383 assert_equals(node4.previousSibling, node1, type(node1) + '.after() should insert ' +
384 'nodes after this node');
385 assert_equals(node4.nextSibling, node3, type(node1) + '.after() shou ld insert ' +
386 'nodes after this node');
387 assert_equals(node4.parent, parent, 'Parent group of the inserted no de should be changed');
388 assert_equals(node3.previousSibling, node4, type(node1) + '.after() should insert ' +
389 'nodes after this node');
390 assert_equals(node3.nextSibling, node2, type(node1) + '.after() shou ld insert ' +
391 'nodes after this node');
392 assert_equals(node3.parent, parent, 'Parent group of the inserted no de should be changed');
393 assert_equals(node2.previousSibling, node3, type(node1) + '.after() should insert ' +
394 'nodes after this node');
395 assert_array_equals(parent.children, [node1, node4, node3, node2], p arentCtor.name +
396 '.children should be updated');
397 });
398 });
399 }, 'Test AnimationNode.after() inserts several nodes after this node, check inse rtion order');
400
401 test(function() {
402 var test = this;
403 var parents = [AnimationGroup, AnimationSequence];
404 parents.forEach(function(parentCtor) {
405 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new AnimationSequence([])];
406 nodes.forEach(function(node2) {
407 var node1 = newAnimation(createDiv(test));
408 var parent = new parentCtor([node1]);
409 var player = document.timeline.play(node2);
410
411 assert_equals(player.source, node2, 'The node should be associated w ith its player');
412 node1.after(node2);
413 assert_equals(player.source, null, 'The node should be disassociated from its player');
414 });
415 });
416 }, 'Test AnimationNode.after() disassociates the inserted node from the player, ' +
417 'if node is directly associated with a player');
418 </script>
419 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698