Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / MutationObserver / added-out-of-order.html
blobaa289668327538d546084ff82d37108207a2d085
1 <!DOCTYPE html>
2 <div id="sandbox" style="display:none"><span></span></div>
3 <script src="../../../resources/js-test.js"></script>
4 <script>
5 description("Test MutationEvents interfering with MutationObservers: adding nodes 'out of order'");
6 var sandbox = document.getElementById('sandbox');
7 var inserted = false;
8 sandbox.addEventListener('DOMNodeRemoved', function() {
9 if (!inserted) {
10 sandbox.appendChild(document.createElement('div'));
11 inserted = true;
13 });
14 var observer = new MutationObserver(function(){});
15 observer.observe(sandbox, {childList: true});
16 sandbox.textContent = 'hello world';
18 var mutations = observer.takeRecords();
19 shouldBe("mutations.length", "3");
20 shouldBe("mutations[0].addedNodes.length", "0");
21 shouldBe("mutations[0].removedNodes.length", "1");
22 shouldBe("mutations[0].removedNodes[0].tagName", "'SPAN'");
23 shouldBe("mutations[1].addedNodes.length", "1");
24 shouldBe("mutations[1].removedNodes.length", "0");
25 shouldBe("mutations[1].addedNodes[0].tagName", "'DIV'");
26 shouldBe("mutations[2].addedNodes.length", "1");
27 shouldBe("mutations[2].removedNodes.length", "0");
28 shouldBe("mutations[2].addedNodes[0].nodeValue", "'hello world'");
29 </script>