| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>AnimationNode remove() method tests</title> | |
| 4 <meta name="assert" content="Removes this animation node from its parent animati
on group or player"> | |
| 5 <link rel="help" href="http://w3c.github.io/web-animations/#dom-animationnode-re
move"> | |
| 6 <link rel="help" href="http://w3c.github.io/web-animations/#remove-an-animation-
node"> | |
| 7 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> | |
| 8 <link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"
> | |
| 9 <script src="../../../../resources/testharness.js"></script> | |
| 10 <script src="../../../../resources/testharnessreport.js"></script> | |
| 11 <script src="../testcommon.js"></script> | |
| 12 <body> | |
| 13 <div id="log"></div> | |
| 14 <script> | |
| 15 test(function() { | |
| 16 var nodes = [newAnimation(createDiv(this)), new AnimationGroup([]), new Anim
ationSequence([])]; | |
| 17 nodes.forEach(function(node) { | |
| 18 node.remove(); | |
| 19 | |
| 20 assert_equals(node.parent, null, type(node) + ' node parent attribute sh
ould be null'); | |
| 21 }); | |
| 22 }, 'AnimationNode.remove() does nothing for standalone node'); | |
| 23 | |
| 24 test(function() { | |
| 25 var test = this; | |
| 26 var parents = [AnimationGroup, AnimationSequence]; | |
| 27 parents.forEach(function(parentCtor) { | |
| 28 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new
AnimationSequence([])]; | |
| 29 nodes.forEach(function(node) { | |
| 30 var parent = new parentCtor([node]); | |
| 31 node.remove(); | |
| 32 | |
| 33 assert_array_equals(parent.children, [], type(node) + | |
| 34 ' node should be removed from the parent ' + parentCtor.name); | |
| 35 assert_equals(node.parent, null, type(node) + | |
| 36 ' node parent attribute should be updated'); | |
| 37 }); | |
| 38 }); | |
| 39 }, 'AnimationNode.remove() removes node from the parent animation group. ' + | |
| 40 'Removed node is the only node in the tree'); | |
| 41 | |
| 42 test(function() { | |
| 43 var test = this; | |
| 44 var parents = [AnimationGroup, AnimationSequence]; | |
| 45 parents.forEach(function(parentCtor) { | |
| 46 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new
AnimationSequence([])]; | |
| 47 nodes.forEach(function(node1) { | |
| 48 var node2 = newAnimation(createDiv(test)); | |
| 49 var parent = new parentCtor([node1, node2]); | |
| 50 | |
| 51 node1.remove(); | |
| 52 | |
| 53 assert_array_equals(parent.children, [node2], type(node1) + | |
| 54 ' node should be removed from the parent ' + parentCtor.name); | |
| 55 assert_equals(parent.firstChild, node2, 'Parent ' + parentCtor.name
+ | |
| 56 ' firstChild attribute should be updated'); | |
| 57 assert_equals(node1.parent, null, 'Removed ' + type(node1) + | |
| 58 ' node parent attribute should be updated'); | |
| 59 assert_equals(node1.nextSibling, null, 'Removed ' + type(node1) + | |
| 60 ' node nextSibling attribute should be updated'); | |
| 61 assert_equals(node2.previousSibling, null, | |
| 62 'Remaining node previousSibling attribute should be updated'); | |
| 63 }); | |
| 64 }); | |
| 65 }, 'AnimationNode.remove() removes node from the parent animation group. ' + | |
| 66 'Remove the first node in the group'); | |
| 67 | |
| 68 test(function() { | |
| 69 var test = this; | |
| 70 var parents = [AnimationGroup, AnimationSequence]; | |
| 71 parents.forEach(function(parentCtor) { | |
| 72 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new
AnimationSequence([])]; | |
| 73 nodes.forEach(function(node2) { | |
| 74 var node1 = newAnimation(createDiv(test)); | |
| 75 var parent = new parentCtor([node1, node2]); | |
| 76 | |
| 77 node2.remove(); | |
| 78 | |
| 79 assert_array_equals(parent.children, [node1], type(node2) + | |
| 80 ' node should be removed from the parent ' + parentCtor.name); | |
| 81 assert_equals(parent.lastChild, node1, 'Parent ' + parentCtor.name + | |
| 82 ' lastChild attribute should be updated'); | |
| 83 assert_equals(node2.parent, null, 'Removed ' + type(node2) + | |
| 84 ' node parent attribute should be updated'); | |
| 85 assert_equals(node1.nextSibling, null, | |
| 86 'Remaining node nextSibling attribute should be updated'); | |
| 87 assert_equals(node2.previousSibling, null, 'Removed ' + type(node2)
+ | |
| 88 ' node previousSibling attribute should be updated'); | |
| 89 }); | |
| 90 }); | |
| 91 }, 'AnimationNode.remove() removes node from the parent animation group. ' + | |
| 92 'Remove the last node in the group'); | |
| 93 | |
| 94 test(function() { | |
| 95 var test = this; | |
| 96 var parents = [AnimationGroup, AnimationSequence]; | |
| 97 parents.forEach(function(parentCtor) { | |
| 98 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new
AnimationSequence([])]; | |
| 99 nodes.forEach(function(node2) { | |
| 100 var node1 = newAnimation(createDiv(test)); | |
| 101 var node3 = newAnimation(createDiv(test)); | |
| 102 var parent = new parentCtor([node1, node2, node3]); | |
| 103 | |
| 104 node2.remove(); | |
| 105 | |
| 106 assert_array_equals(parent.children, [node1, node3], type(node2) + | |
| 107 ' node should be removed from the parent ' + parentCtor.name); | |
| 108 assert_equals(node2.parent, null, 'Removed ' + type(node2) + | |
| 109 ' node parent attribute should be updated'); | |
| 110 assert_equals(node2.nextSibling, null, 'Removed ' + type(node2) + | |
| 111 ' node nextSibling attribute should be updated'); | |
| 112 assert_equals(node2.previousSibling, null, 'Removed ' + type(node2)
+ | |
| 113 ' node previousSibling attribute should be updated'); | |
| 114 assert_equals(node1.nextSibling, node3, | |
| 115 'Remaining node nextSibling attribute should be updated'); | |
| 116 assert_equals(node3.previousSibling, node1, | |
| 117 'Remaining node previousSibling attribute should be updated'); | |
| 118 }); | |
| 119 }); | |
| 120 }, 'AnimationNode.remove() removes node from the parent animation group. ' + | |
| 121 'Remove node from the middle of the group'); | |
| 122 | |
| 123 test(function() { | |
| 124 var test = this; | |
| 125 var parents = [AnimationGroup, AnimationSequence]; | |
| 126 parents.forEach(function(parentCtor) { | |
| 127 parents.forEach(function(nodeCtor) { | |
| 128 var node1 = newAnimation(createDiv(test)); | |
| 129 var node2 = newAnimation(createDiv(test)); | |
| 130 var node3 = newAnimation(createDiv(test)); | |
| 131 var node4 = new nodeCtor([node1, node2]); | |
| 132 var node5 = newAnimation(createDiv(test)); | |
| 133 var parent = new parentCtor([node3, node4, node5]); | |
| 134 | |
| 135 node4.remove(); | |
| 136 | |
| 137 assert_array_equals(node4.children, [node1, node2], 'Removed ' + | |
| 138 type(node4) + ' node children should not be changed'); | |
| 139 assert_array_equals(parent.children, [node3, node5], type(node4) + | |
| 140 ' node should be removed from the parent ' + parentCtor.name); | |
| 141 assert_equals(node4.parent, null, 'Removed ' + type(node2) + | |
| 142 ' node parent attribute should be updated'); | |
| 143 assert_equals(node4.nextSibling, null, 'Removed ' + type(node2) + | |
| 144 ' node nextSibling attribute should be updated'); | |
| 145 assert_equals(node4.previousSibling, null, 'Removed ' + type(node2)
+ | |
| 146 ' node previousSibling attribute should be updated'); | |
| 147 assert_equals(node3.nextSibling, node5, | |
| 148 'Remaining node nextSibling attribute should be updated'); | |
| 149 assert_equals(node5.previousSibling, node3, | |
| 150 'Remaining node previousSibling attribute should be updated'); | |
| 151 }); | |
| 152 }); | |
| 153 }, 'Test removing a node that has children'); | |
| 154 | |
| 155 test(function() { | |
| 156 var nodes = [newAnimation(createDiv(this)), new AnimationGroup([]), new Anim
ationSequence([])]; | |
| 157 nodes.forEach(function(node) { | |
| 158 var player = document.timeline.play(node); | |
| 159 node.remove(); | |
| 160 | |
| 161 assert_equals(player.source, null, type(node) + | |
| 162 ' node should be disassociated from the player'); | |
| 163 }); | |
| 164 }, 'AnimationNode.remove() disassociates the node from player, ' + | |
| 165 'if node is directly associated with a player'); | |
| 166 | |
| 167 test(function() { | |
| 168 var test = this; | |
| 169 var parents = [AnimationGroup, AnimationSequence]; | |
| 170 parents.forEach(function(parentCtor) { | |
| 171 var nodes = [newAnimation(createDiv(test)), new AnimationGroup([]), new
AnimationSequence([])]; | |
| 172 nodes.forEach(function(node2) { | |
| 173 var node1 = newAnimation(createDiv(test)); | |
| 174 var node3 = newAnimation(createDiv(test)); | |
| 175 var parent = new parentCtor([node1, node2, node3]); | |
| 176 var player = document.timeline.play(parent); | |
| 177 | |
| 178 node2.remove(); | |
| 179 | |
| 180 assert_equals(player.source, parent, type(node2) + | |
| 181 ' parent node should remain associated with the player'); | |
| 182 }); | |
| 183 }); | |
| 184 }, 'AnimationNode.remove() keeps parent direct association with the player'); | |
| 185 | |
| 186 test(function() { | |
| 187 var test = this; | |
| 188 var parents = [AnimationGroup, AnimationSequence]; | |
| 189 parents.forEach(function(parentCtor) { | |
| 190 parents.forEach(function(nodeCtor) { | |
| 191 var node1 = newAnimation(createDiv(test)); | |
| 192 var node2 = newAnimation(createDiv(test)); | |
| 193 var node3 = newAnimation(createDiv(test)); | |
| 194 var node4 = newAnimation(createDiv(test)); | |
| 195 var node5 = new parentCtor([node4]); | |
| 196 var group1 = new AnimationGroup([node3, node5]); | |
| 197 var node6 = newAnimation(createDiv(test)); | |
| 198 var node7 = new parentCtor([node6]); | |
| 199 var node8 = newAnimation(createDiv(test)); | |
| 200 var sequence1 = new AnimationSequence([node7,node8]); | |
| 201 var node9 = new nodeCtor([node1, group1, node2, sequence1]); | |
| 202 var node10 = newAnimation(createDiv(test)); | |
| 203 var parent = new parentCtor([node9, node10]); | |
| 204 | |
| 205 node9.remove(); | |
| 206 | |
| 207 assert_equals(node9.parent, null, 'Removed ' + type(node9) + | |
| 208 ' node parent attribute should be updated'); | |
| 209 assert_array_equals(node9.children, [node1, group1, node2, sequence1
], | |
| 210 'Removed ' + type(node9) + ' node children should not be changed
'); | |
| 211 for (var i = 0; i < node9.children.length; i++) { | |
| 212 assert_equals(node9.children[i].parent, node9, 'Removed ' + type
(node9) + | |
| 213 ' node children parent attribute should not be changed for c
hild ' + i); | |
| 214 } | |
| 215 assert_array_equals(group1.children, [node3, node5], | |
| 216 'Removed ' + type(node9) + ' node grand children should not be c
hanged'); | |
| 217 for (var i = 0; i < group1.children.length; i++) { | |
| 218 assert_equals(group1.children[i].parent, group1, 'Removed ' + ty
pe(node9) + | |
| 219 ' node grand children parent attribute should not be changed
for child ' + i); | |
| 220 } | |
| 221 assert_array_equals(sequence1.children, [node7,node8], | |
| 222 'Removed ' + type(node9) + ' node grand children should not be c
hanged'); | |
| 223 for (var i = 0; i < sequence1.children.length; i++) { | |
| 224 assert_equals(sequence1.children[i].parent, sequence1, 'Removed
' + type(node9) + | |
| 225 ' node grand children parent attribute should not be changed
for child ' + i); | |
| 226 } | |
| 227 assert_array_equals(node5.children, [node4], | |
| 228 'Removed ' + type(node9) + ' node grand children should not be c
hanged'); | |
| 229 assert_equals(node4.parent, node5, 'Removed ' + type(node9) + | |
| 230 ' node grand children parent attribute should not be changed'); | |
| 231 assert_array_equals(node7.children, [node6], | |
| 232 'Removed ' + type(node9) + ' node grand children should not be c
hanged'); | |
| 233 assert_equals(node6.parent, node7, 'Removed ' + type(node9) + | |
| 234 ' node grand children parent attribute should not be changed'); | |
| 235 }); | |
| 236 }); | |
| 237 }, 'AnimationNode.remove() on the root of a non-trivial tree does not change chi
ld structure'); | |
| 238 </script> | |
| 239 </body> | |
| OLD | NEW |