blob: 88b38c5221f99a681ecbeae2bdc461cbbf168ad2 [file] [log] [blame]
<!DOCTYPE html>
<body>
<script src="../../../resources/js-test-pre.js"></script>
<div id="parent1">text</div>
<div id="parent2">text</div>
<script>
function handleInsertion() {
document.removeEventListener('DOMNodeInserted', handleInsertion);
parent.innerHTML = '';
}
document.addEventListener('DOMNodeInserted', handleInsertion);
var parent = document.getElementById('parent1');
var range = document.createRange();
range.setStart(parent, 0);
range.setEnd(parent, 0);
range.insertNode(document.createElement('span'));
parent.remove();
function handleInsertion2() {
if (parent.childNodes.length != 3)
return;
var textNodeCreatedBySplitText = parent.lastChild;
parent.removeChild(textNodeCreatedBySplitText);
document.removeEventListener('DOMNodeInserted', handleInsertion2);
}
document.addEventListener('DOMNodeInserted', handleInsertion2);
parent = document.getElementById('parent2');
range.setStart(parent2.firstChild, 2);
range.setEnd(parent2.firstChild, 2);
range.insertNode(document.createElement('span'));
description('No assertion failures even if a DOM mutation event handler updates nodes in a Range during Range::insertNode.');
testPassed('if this did not crash.');
parent.remove();
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>