<html>
<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=13514">bug 13514</a>:
REGRESSION (r20997-21003): Crash in WebCore::Node::Document.</p>
<div id="elem"><p></p></div>

<script>
if (window.testRunner)
  testRunner.dumpAsText();

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("");
    }
}

elem = document.getElementById('elem');

elem.childNodes.length;
elem.childNodes[0].length;
gc();
elem.innerHTML = "";
gc();
elem.childNodes[0];
if (elem.childNodes.length == 0)
  document.write("SUCCESS");
else
  document.write("FAILURE: childNodes.length was cached inappropriately");

</script>
</body>
</html>
