| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../js/resources/js-test-pre.js"></script> | 2 <script src="../../js/resources/js-test-pre.js"></script> |
| 3 <script> | 3 <script> |
| 4 description('Inserting DocumentFragments should remove all children of the fragm
ent before inserting the children.'); | 4 description('Inserting DocumentFragments should remove all children of the fragm
ent before inserting the children.'); |
| 5 | 5 |
| 6 window.jsTestIsAsync = true; | 6 window.jsTestIsAsync = true; |
| 7 | 7 |
| 8 function createObservedFragment() { | 8 function createObservedFragment() { |
| 9 var fragment = document.createDocumentFragment(); | 9 var fragment = document.createDocumentFragment(); |
| 10 fragment.appendChild(document.createElement('b')); | 10 fragment.appendChild(document.createElement('b')); |
| 11 fragment.appendChild(document.createElement('i')); | 11 fragment.appendChild(document.createElement('i')); |
| 12 observer.observe(fragment, {childList: true}); | 12 observer.observe(fragment, {childList: true}); |
| 13 return fragment; | 13 return fragment; |
| 14 } | 14 } |
| 15 | 15 |
| 16 function createObservedDiv() { | 16 function createObservedDiv() { |
| 17 return div; | 17 return div; |
| 18 } | 18 } |
| 19 | 19 |
| 20 function callback(mutations) { | 20 function callback(mutations) { |
| 21 window.mutations = mutations; | 21 window.mutations = mutations; |
| 22 } | 22 } |
| 23 var observer = new WebKitMutationObserver(callback); | 23 var observer = new MutationObserver(callback); |
| 24 | 24 |
| 25 function testAppendChild() { | 25 function testAppendChild() { |
| 26 debug('Testing appendChild'); | 26 debug('Testing appendChild'); |
| 27 var div = document.createElement('div'); | 27 var div = document.createElement('div'); |
| 28 observer.observe(div, {childList: true}); | 28 observer.observe(div, {childList: true}); |
| 29 div.appendChild(createObservedFragment()); | 29 div.appendChild(createObservedFragment()); |
| 30 setTimeout(function() { | 30 setTimeout(function() { |
| 31 shouldBe('mutations.length', '2'); | 31 shouldBe('mutations.length', '2'); |
| 32 shouldBe('mutations[0].addedNodes.length', '0'); | 32 shouldBe('mutations[0].addedNodes.length', '0'); |
| 33 shouldBe('mutations[0].removedNodes.length', '2'); | 33 shouldBe('mutations[0].removedNodes.length', '2'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 shouldBe('mutations[1].addedNodes.length', '2'); | 68 shouldBe('mutations[1].addedNodes.length', '2'); |
| 69 shouldBe('mutations[1].removedNodes.length', '1'); | 69 shouldBe('mutations[1].removedNodes.length', '1'); |
| 70 debug(''); | 70 debug(''); |
| 71 finishJSTest(); | 71 finishJSTest(); |
| 72 }, 0); | 72 }, 0); |
| 73 } | 73 } |
| 74 | 74 |
| 75 testAppendChild(); | 75 testAppendChild(); |
| 76 </script> | 76 </script> |
| 77 <script src="../../js/resources/js-test-post.js"></script> | 77 <script src="../../js/resources/js-test-post.js"></script> |
| OLD | NEW |