<!DOCTYPE html>
<html>
<body>
<object id="someName" name="someName"></object>
<script src="../../../resources/js-test-pre.js"></script>
<script>

description("Test that the document's name getter returns an object element with id and name attributes set to the same value.");

evalAndLog('objectElement = document.querySelector("object#someName");');
shouldBe('objectElement.getAttribute("name")', '"someName"');
shouldBe('document.someName', 'objectElement');
shouldBe('objectElement.removeAttribute("id"); document.someName', 'objectElement');
shouldBeUndefined('objectElement.setAttribute("name", "otherName"); document.someName');
shouldBe('document.otherName', 'objectElement');
shouldBe('objectElement.setAttribute("id", "otherName"); document.otherName', 'objectElement');
shouldBeUndefined('objectElement.parentNode.removeChild(objectElement); document.otherName');
shouldBe('document.body.appendChild(objectElement); document.otherName', 'objectElement');
shouldBe('objectElement.setAttribute("id", "anotherName"); document.anotherName', 'objectElement');
shouldBe('document.otherName', 'objectElement');
shouldBeUndefined('objectElement.setAttribute("name", "anotherName"); document.otherName');
shouldBe('document.anotherName', 'objectElement');
evalAndLog('imageElement = document.createElement("img"); document.body.appendChild(imageElement); imageElement.setAttribute("name", "anotherName");');
shouldBeUndefined('objectElement.parentNode.removeChild(objectElement); document.otherName');
shouldBe('document.anotherName', 'imageElement');

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