<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="test" style="display:none">
<div><span></span></div>
<div><span></span></div>
<div><span></span></div>
<div><span></span></div>
<div><span></span></div>
</div>
<script>

description("Test traversing children using HTMLCollection while mutating DOM");

try {
var test = document.getElementById("test");
for (var i = 0; i < test.children.length; i++)
    test.children[i].firstChild.innerHTML = "child " + i;
} catch(e) {}

var child = test.firstElementChild;
for (var i = 0; i < 5; i++) {
    shouldBeEqualToString("child.firstChild.innerText", "child " + i);
    child = child.nextElementSibling;
}
shouldBeNull("child");

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
