blob: 91850ea50205dfa47226610ef24a3bec90d4b5bd [file] [log] [blame]
<!DOCTYPE html>
<div id="sandbox" style="display:none"></div>
<script src="../../../resources/js-test-pre.js"></script>
<script>
description("Test MutationEvents interfering with MutationObservers: removing nodes 'out of order'");
var sandbox = document.getElementById('sandbox');
var removed = false;
sandbox.addEventListener('DOMNodeInserted', function() {
if (!removed) {
sandbox.removeChild(sandbox.firstChild);
removed = true;
}
});
var observer = new MutationObserver(function(){});
observer.observe(sandbox, {childList: true});
sandbox.innerHTML = '<b></b><i></i>';
var mutations = observer.takeRecords();
shouldBe("mutations.length", "2");
shouldBe("mutations[0].addedNodes.length", "1");
shouldBe("mutations[0].removedNodes.length", "0");
shouldBe("mutations[0].addedNodes[0].tagName", "'B'");
shouldBe("mutations[1].addedNodes.length", "1");
shouldBe("mutations[1].removedNodes.length", "1");
shouldBe("mutations[1].removedNodes[0].tagName", "'B'");
shouldBe("mutations[1].addedNodes[0].tagName", "'I'");
</script>
</script>
<script src="../../../resources/js-test-post.js"></script>