blob: e472454b43f69e24b3dd2320129b122ab9cc33b3 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../../resources/js-test-pre.js"></script>
<script>
description("Tests that HTMLTableElement.caption / tHead / tFoot are nullable and behave according to specification.");
var table = document.createElement("table");
shouldBe("table.__proto__", "HTMLTableElement.prototype");
var caption = document.createElement("caption");
shouldBe("caption.__proto__", "HTMLTableCaptionElement.prototype");
var thead = document.createElement("thead");
shouldBe("thead.__proto__", "HTMLTableSectionElement.prototype");
var tfoot = document.createElement("tFoot");
shouldBe("tfoot.__proto__", "HTMLTableSectionElement.prototype");
debug("");
debug("* HTMLTableElement.caption");
shouldBeNull("table.caption");
evalAndLog("table.caption = caption");
shouldBe("table.caption", "caption");
shouldThrow("table.caption = document.body", "'TypeError: The HTMLTableElement.caption attribute must be an instance of HTMLTableCaptionElement'");
shouldBe("table.caption", "caption");
evalAndLog("table.caption = null");
shouldBeNull("table.caption");
evalAndLog("table.caption = caption");
shouldBe("table.caption", "caption");
evalAndLog("table.caption = undefined"); // undefined is converted to null for nullable attributes.
shouldBeNull("table.caption");
debug("");
debug("* HTMLTableElement.tHead");
shouldBeNull("table.tHead");
evalAndLog("table.tHead = thead");
shouldBe("table.tHead", "thead");
shouldThrow("table.tHead = document.body", "'TypeError: The HTMLTableElement.tHead attribute must be an instance of HTMLTableSectionElement'");
shouldBe("table.tHead", "thead");
shouldThrowErrorName("table.tHead = tfoot", "HierarchyRequestError");
shouldBe("table.tHead", "thead");
evalAndLog("table.tHead = null");
shouldBeNull("table.tHead");
evalAndLog("table.tHead = thead");
shouldBe("table.tHead", "thead");
evalAndLog("table.tHead = undefined"); // undefined is converted to null for nullable attributes.
shouldBeNull("table.tHead");
debug("");
debug("* HTMLTableElement.tFoot");
shouldBeNull("table.tFoot");
evalAndLog("table.tFoot = tfoot");
shouldBe("table.tFoot", "tfoot");
shouldThrow("table.tFoot = document.body", "'TypeError: The HTMLTableElement.tFoot attribute must be an instance of HTMLTableSectionElement'");
shouldBe("table.tFoot", "tfoot");
shouldThrowErrorName("table.tFoot = thead", "HierarchyRequestError");
shouldBe("table.tFoot", "tfoot");
evalAndLog("table.tFoot = null");
shouldBeNull("table.tFoot");
evalAndLog("table.tFoot = tfoot");
shouldBe("table.tFoot", "tfoot");
evalAndLog("table.tFoot = undefined"); // undefined is converted to null for nullable attributes.
shouldBeNull("table.tFoot");
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>