summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/text-node-append-data-remove-crash.html
blob: bbaa082926a6abc1d179151cdcfb1c1de0481627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<body onload="runTest()">
<script>
var count = 0;
if (window.testRunner)
{
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function runTest()
{   
    try {
       divBlock.addEventListener("DOMCharacterDataModified", eventListener, false);
       pBlock.outerText = "text";
       divBlock.innerHTML = "PASS, didn't crash.";
    }
    catch (exception) {
       divBlock.innerHTML = "Threw an exception - " + exception;
    }
    if (window.testRunner)
        testRunner.notifyDone();
}

function eventListener()
{
    try {
      var range = document.createRange();
      range.setStart(divBlock, 0);
      range.setEnd(divBlock, divBlock.childNodes.length - 1);
      range.deleteContents();
      gc();
  } catch(e) { }
}

function gc()
{
    if (window.GCController)
        return GCController.collect();

    for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
        var s = new String("");
    }
}
</script>
<div id="divBlock">
<br/>textnode1<p id="pBlock"></p>textnode2<br/>
</div>
</body>
</html>