OLD | NEW |
(Empty) | |
| 1 function testPrepend(node, parent, type) { |
| 2 test(function() { |
| 3 assert_true("prepend" in parent); |
| 4 assert_equals(typeof parent.prepend, "function"); |
| 5 assert_equals(parent.prepend.length, 0); |
| 6 }, type + " should support prepend()"); |
| 7 test(function() { |
| 8 var x, y; |
| 9 if (type == 'element' || type == 'document-fragment' || type == 'document') { |
| 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.prepend(x, y, 'z'); |
| 24 assert_equals(parent.childNodes.length, 4, "Parent should have 4 children"); |
| 25 assert_equals(parent.firstChild, x, "Parent's first child should be x"); |
| 26 assert_equals(parent.childNodes[2].data, 'z', "Parent's third child's data shoul
d be z"); |
| 27 assert_equals(parent.lastChild, node, "Parent's last child should be node"); |
| 28 }, "prepend() should work for " + type); |
| 29 } |
OLD | NEW |