Editing tests should use testRunner instead of layoutTestController
[WebKit-https.git] / LayoutTests / editing / execCommand / insertHTML-mutation-crash.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script type="text/javascript">
5         function log(msg)
6         {
7             document.body.appendChild(document.createTextNode(msg + '\n'));
8         }
9
10         function runTests()
11         {
12             if (window.testRunner)
13                 testRunner.dumpAsText();
14
15             var listener = function(e) {
16                 var el = document.getElementById('cont');
17                 if (el.firstElementChild && el.lastElementChild != el.firstElementChild) {
18                     el.lastElementChild.appendChild(el.firstElementChild);
19                     el.lastElementChild && el.removeChild(el.lastElementChild);
20                 }
21                 if (e.target.firstChild && e.target.firstChild.className == 'Apple-style-span')
22                     e.target.firstChild.innerHTML = e.target.firstChild.innerHTML.split(' ')[0];
23             };
24             document.addEventListener("DOMSubtreeModified", listener);
25
26             var el = document.getElementById('cont');
27             window.getSelection().setBaseAndExtent(document.getElementById('start'), 0, document.getElementById('end'), 0);
28             var str = '<span class="Apple-style-span" style="color: red;"><span>styled</span> <span>content</span></span>';
29             document.execCommand("InsertHTML", false, str);
30
31             document.removeEventListener("DOMSubtreeModified", listener);
32
33             log('PASS: No crash.');
34         }
35
36     </script>
37 </head>
38 <body onload="runTests();">
39     <div id="cont" contenteditable="true">
40         <span>This <span id="start">tests</span></span>
41         <span>that we don't crash when <code id="end">mutating</code> the dom</span>
42         <span>during execution of an InsertHTML command.</span>
43     </div>
44 </body>
45 </html>