<head>
<script>

function frameLoaded()
{
    // create lots of objects to force a garbage collection
    var i = 0;
    var s;
    while (i < 5000) {
        i = i+1.11;
        s = s + " ";
    }

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

    output.innerHTML += spanB.customProperty + "<BR>";
    output.innerHTML += spanB + "<BR>";
    output.innerHTML += spanB.parentNode + "<BR>";
    output.innerHTML += spanB.ownerDocument + "<BR>";
    
    if (window.testRunner)
        testRunner.notifyDone();    
}

function doit()
{
    var frame = document.getElementById("frame");
    frameDoc = frame.contentDocument;
    spanB = frame.contentDocument.getElementById("span-B");
    spanB.customProperty = "B";
    frame.onload = frameLoaded;
    frame.src = 'about:blank'
}

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

</script>
</head>

<body onload="doit()">
<div style="border: 1px solid red">
<p>
This test verifies that objects are protected against garbage
collection as long as the document is alive (for contrast with test
6).
</p>
<p>
The output should be the following pieces of text on lines by
themselves: "B", "[object HTMLElement]", "[object HTMLElement]", "[object HTMLDocument]".
</p>
</div>

<div id="output">
</div>

<iframe id="frame" src='data:text/html,<div id="div"><span id="span-A"><span id="span-B"><span id="span-C">original span</span></span></span></div>'>
</body>
