<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<div id="testDiv">
<p name="toString" id="toStringP"></p>
<p name="length" id="lengthP"></p>
<p name="foo" id="fooP"></p>
<p name="0" id="0P"></p>
</div>
<script>
description("Tests that the behavior of HTMLCollection's [[GetOwnProperty]] conforms to Web IDL");

var testDiv = document.getElementById("testDiv");
var htmlCollection = testDiv.children;

debug("* Named properties should not mask properties on the prototype");
shouldBe("htmlCollection.namedItem('toString')", "document.getElementById('toStringP')");
shouldBe("htmlCollection.toString", "HTMLCollection.prototype.toString");

debug("");
debug("* Named properties should not mask static properties on HTMLCollection");
shouldBe("htmlCollection.namedItem('length')", "document.getElementById('lengthP')");
shouldBe("htmlCollection.length", "4");

debug("");
debug("* Named properties should not mask own properties on HTMLCollection");
evalAndLog("htmlCollection.foo = 'foo'");
shouldBe("htmlCollection.namedItem('foo')", "document.getElementById('fooP')")
shouldBe("htmlCollection.foo", "document.getElementById('fooP')");

debug("");
debug("* Named properties should not mask indexed properties");
shouldBe("htmlCollection.item(0)", "testDiv.firstElementChild");
shouldBe("htmlCollection[0]", "testDiv.firstElementChild");
shouldBe("htmlCollection.namedItem('0')", "document.getElementById('0P')");
shouldBe("htmlCollection['0']", "testDiv.firstElementChild");

debug("");
debug("* Own properties on HTMLCollection should not mask properties on prototype");
oldToString = htmlCollection.toString;
evalAndLog("htmlCollection.toString = 'InstanceToString'");
shouldBe("htmlCollection.toString", "oldToString");

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