summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/NodeList/5725058-crash-scenario-2.html
blob: 147b2df503caa1f6f3fb2574f8e64a3afb1bf8e2 (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
<p>Test for (rdar://problem/5725058). If you see this text, then all is well and no crash has occurred.</p>

<p id="a">paragraph a</p>
<p id="b">paragraph b</p>
<script>
if (window.layoutTestController)
    layoutTestController.dumpAsText();

function triggerGarbageCollection()
{
    if (window.GCController) {
        GCController.collect();
        return;
    }
    for (var i = 0; i < 10000; ++i)
        ({})
}

function setUp()
{
    // This only works if in a function. I'm not sure why.

    // Get node and length from paragraph A into the cache.
    document.getElementById("a").childNodes[0];
    document.getElementById("a").childNodes.length;
}

setUp();

// Get back to "zero node lists".
triggerGarbageCollection();

// Remove the child node of paragraph A. Use innerHTML to avoid getting a reference to the node being removed.
document.getElementById("a").innerHTML = "";

// Get back to "one node list".
var childNodesB = document.getElementById("b").childNodes;

// Now try the original list.
var x = document.getElementById("a").childNodes[0];
x = document.getElementById("a").childNodes.length;
</script>