OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 |
| 6 test(function() { |
| 7 var node = document.createComment('node'); |
| 8 assert_true('before' in node); |
| 9 assert_equals(typeof node.after, 'function'); |
| 10 assert_equals(node.before.length, 0); |
| 11 }, "Comment should support before()"); |
| 12 |
| 13 test(function() { |
| 14 var node = document.createElement('node'); |
| 15 assert_true('before' in node); |
| 16 assert_equals(typeof node.after, 'function'); |
| 17 assert_equals(node.before.length, 0); |
| 18 }, "Element should support before()"); |
| 19 |
| 20 test(function() { |
| 21 var node = document.createTextNode('node'); |
| 22 assert_true('before' in node); |
| 23 assert_equals(typeof node.after, 'function'); |
| 24 assert_equals(node.before.length, 0); |
| 25 }, "Text should support before()"); |
| 26 |
| 27 test(function() { |
| 28 var parent = document.createElement('div'); |
| 29 var test = document.createComment('test'); |
| 30 parent.appendChild(test); |
| 31 var x = document.createComment('x'); |
| 32 var z = document.createComment('z'); |
| 33 |
| 34 test.before(x, 'y', z); |
| 35 |
| 36 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); |
| 37 assert_equals(parent.firstChild, x, 'parent\'s first child should be x'); |
| 38 assert_equals(parent.childNodes[1].data, 'y', 'parent\'s second child should b
e "y"'); |
| 39 assert_equals(parent.childNodes[2], z, 'parent\'s third child should be z'); |
| 40 assert_equals(parent.lastChild, test, 'parent\'s last child should be test'); |
| 41 |
| 42 x.before('a'); |
| 43 assert_equals(parent.firstChild.data, 'a', 'parent\'s first child should be "a
"'); |
| 44 }, "before() should work for Comment"); |
| 45 |
| 46 test(function() { |
| 47 var parent = document.createElement('div'); |
| 48 var test = document.createComment('test'); |
| 49 parent.appendChild(test); |
| 50 var x = document.createElement('x'); |
| 51 var z = document.createElement('z'); |
| 52 |
| 53 test.before(x, 'y', z); |
| 54 |
| 55 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); |
| 56 assert_equals(parent.firstChild, x, 'parent\'s first child should be x'); |
| 57 assert_equals(parent.childNodes[1].data, 'y', 'parent\'s second child should b
e "y"'); |
| 58 assert_equals(parent.childNodes[2], z, 'parent\'s third child should be z'); |
| 59 assert_equals(parent.lastChild, test, 'parent\'s last child should be test'); |
| 60 |
| 61 x.before('a'); |
| 62 assert_equals(parent.firstChild.data, 'a', 'parent\'s first child should be "a
"'); |
| 63 }, "before() should work for Element"); |
| 64 |
| 65 test(function() { |
| 66 var parent = document.createElement('div'); |
| 67 var test = document.createComment('test'); |
| 68 parent.appendChild(test); |
| 69 var x = document.createTextNode('x'); |
| 70 var z = document.createTextNode('z'); |
| 71 |
| 72 test.before(x, 'y', z); |
| 73 |
| 74 assert_equals(parent.childNodes.length, 4, 'parent should have 4 children'); |
| 75 assert_equals(parent.firstChild, x, 'parent\'s first child should be x'); |
| 76 assert_equals(parent.childNodes[1].data, 'y', 'parent\'s second child should b
e "y"'); |
| 77 assert_equals(parent.childNodes[2], z, 'parent\'s third child should be z'); |
| 78 assert_equals(parent.lastChild, test, 'parent\'s last child should be test'); |
| 79 |
| 80 x.before('a'); |
| 81 assert_equals(parent.firstChild.data, 'a', 'parent\'s first child should be "a
"'); |
| 82 }, "before() should work for Text"); |
| 83 |
| 84 </script> |
| 85 </html> |
OLD | NEW |