3 <script src=
"../../../resources/js-test.js"></script>
4 <div id=
"parent1">text
</div>
5 <div id=
"parent2">text
</div>
7 function handleInsertion() {
8 document
.removeEventListener('DOMNodeInserted', handleInsertion
);
11 document
.addEventListener('DOMNodeInserted', handleInsertion
);
12 var parent
= document
.getElementById('parent1');
14 window
.getSelection().addRange(r
);
15 r
.setStart(parent
, 0);
17 r
.insertNode(document
.createElement('span'));
20 function handleInsertion2() {
21 if (parent
.childNodes
.length
!= 3)
23 var textNodeCreatedBySplitText
= parent
.lastChild
;
24 parent
.removeChild(textNodeCreatedBySplitText
);
25 document
.removeEventListener('DOMNodeInserted', handleInsertion2
);
27 document
.addEventListener('DOMNodeInserted', handleInsertion2
);
28 parent
= document
.getElementById('parent2');
29 r
.setStart(parent2
.firstChild
, 2);
30 r
.setEnd(parent2
.firstChild
, 2);
31 r
.insertNode(document
.createElement('span'));
33 description('No assertion failures even if a DOM mutation event handler updates nodes in a Range during Range::insertNode.');
34 testPassed('if this did not crash.');