Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / mutation-during-replace-child-2.html
blob4847a87328c56e583bb99077ce343ebf9dd0dfb8
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.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>
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');
20 var numCalled = 0;
22 function handler(){
23 numCalled++;
24 if (numCalled < 2)
25 return;
26 document.removeEventListener("DOMNodeRemoved", handler, false);
27 target.parentNode.removeChild(target);
28 newChild.appendChild(target);
30 document.addEventListener("DOMNodeRemoved", handler, false);
31 shouldThrow("target.replaceChild(newChild, oldChild);", '"HierarchyRequestError: Failed to execute \'replaceChild\' on \'Node\': The new child element contains the parent."');
32 </script>
33 </body>
34 </html>