chromium/third_party/blink/web_tests/fast/dom/gc-2.html

<html>
<head>
<script>
function doit()
{
    var B = document.getElementById("span-B");
    B.customProperty = "B";
    B.parentNode.customProperty = "A";
    B.firstChild.customProperty = "C";

    document.getElementById("div").innerHTML = "<span>replacement content</span>";

    gc();

    var output= document.getElementById("output");

    output.innerHTML += B.customProperty + "<BR>";
    if (B.parentNode) {
        output.innerHTML += B.parentNode.customProperty + "<BR>";
    }
    if (B.firstChild) {
        output.innerHTML += B.firstChild.customProperty + "<BR>";
    }
}

if (window.testRunner) {
    testRunner.dumpAsText();
}

</script>
</head>

<body onload="doit()">
<div style="border: 1px solid red">
<p>
This test verifies that JavaScript wrappers for DOM nodes are
protected against garbage collection for node trees that are outside
the document, so long as there's a reference to at least one node in
the tree.
</p>
<p>
The output should be the following pieces of text on lines by themselves: "replacement content", "B", "A", "C".
</p>
</div>
<div id="div">
<span id="span-A"><span id="span-B"><span id="span-C">original span</span></span></span>
</div>
<div id="output">
</div>
</body>
</html>