4a5b32b0eb2cfec6ddfbd22dd25bc1ed94596056
[WebKit-https.git] / LayoutTests / fast / events / mutation-during-replace-child.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div>
8   <div id="target">
9     <b></b><b id="oldChild"></b><b></b>
10   </div>
11   <div id="newChild"></div>
12 </div>
13
14 <script>
15 description("Ensures that replaceChild() throws an exception if mutation even handler does something wrong");
16 var target = document.getElementById('target');
17 var oldChild = document.getElementById('oldChild');
18 var newChild = document.getElementById('newChild');
19
20 function handler(){
21     document.removeEventListener("DOMNodeRemoved", handler, false);
22     newChild.parentNode.removeChild(newChild);
23     target.parentNode.removeChild(target);
24     newChild.appendChild(target);
25 }   
26 document.addEventListener("DOMNodeRemoved", handler, false);
27 shouldThrow("target.replaceChild(newChild, oldChild);",  "'Error: HierarchyRequestError: DOM Exception 3'");
28 </script>
29 <script src="../js/resources/js-test-post.js"></script>
30 </body>
31 </html>
32