OLD | NEW |
(Empty) | |
| 1 function testAppend(node, parent, type) { |
| 2 test(function() { |
| 3 assert_true("append" in parent); |
| 4 assert_equals(typeof parent.append, "function"); |
| 5 assert_equals(parent.append.length, 0); |
| 6 }, type + " should support append()"); |
| 7 test(function() { |
| 8 var x, y; |
| 9 if (type == 'element' || type == 'document-fragment') { |
| 10 x = document.createElement('x'); |
| 11 y = document.createElement('y'); |
| 12 } |
| 13 if (type == 'comment') { |
| 14 x = document.createComment('x'); |
| 15 y = document.createComment('y'); |
| 16 } |
| 17 if (type == 'text') { |
| 18 x = document.createTextNode('x'); |
| 19 y = document.createTextNode('y'); |
| 20 } |
| 21 parent.appendChild(node); |
| 22 assert_equals(node.parentNode, parent, "Appended node should have a parent"); |
| 23 parent.append(x, y, 'z'); |
| 24 assert_equals(parent.childNodes.length, 4, "Parent should have 4 children"); |
| 25 assert_equals(parent.firstChild, node, "Parent's first child should be node"); |
| 26 assert_equals(parent.childNodes[1], x, "Parent's second child should be x"); |
| 27 assert_equals(parent.lastChild.data, 'z', "Parent's last child's data should be
z"); |
| 28 }, "append() should work for " + type); |
| 29 } |
OLD | NEW |