<!DOCTYPE html>
<html>
<body>
<p>This is an integration test for childNodes. You should see 1 through 5 below.</p>
<pre></pre>
<div id="console"></div>
<script src="../../../resources/js-test-pre.js"></script>
<script>

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

var node = document.querySelector('pre');
var failed = false;
for (var j = 0; j < 5; ++j) {
    var child = document.createElement('div');
    child.innerHTML = j + 1;
    node.appendChild(child);
    for (var i = node.childNodes.length - 1; i >= 0; --i) {
        var actual = node.childNodes[i] ? node.childNodes[i].innerHTML : undefined;
        if (actual != i + 1) {
            testFailed('Got ' + actual + ' on ' + (i + 1) + 'st/nd/th child after adding ' + (j + 1) + 'st/nd/th child.');
            failed  = true;
        }
    }
}

shouldBe("node.innerText", "'1\\n2\\n3\\n4\\n5\\n'");

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