blob: a47318fbca01289480004fdf18482074e434fa16 [file] [log] [blame]
<body>
<pre id="error-log"></pre>
<span id="container" style="color: green">
</span>
<div style="display: none">
<span id="1">
1 (black)
</span>
<span id="2">
2 (green)
</span>
<span id="3">
3 (green)
</span>
<span id="4">
4 (black)
</span>
</div>
<span id="status" style="color: red">
FAILURE
</span>
</body>
<script>
// verify all standard cases
document.getElementById("container").insertAdjacentElement("beforeBegin", document.getElementById("1"));
document.getElementById("container").insertAdjacentElement("afterBegin", document.getElementById("2"));
document.getElementById("container").insertAdjacentElement("beforeEnd", document.getElementById("3"));
document.getElementById("container").insertAdjacentElement("afterEnd", document.getElementById("4"));
function assertThrows(func) {
var testPassed = false;
try {
func();
} catch (e) {
document.getElementById("error-log").innerHTML += "Caught expected exception: " + e + "\n";
testPassed = true;
}
return testPassed;
}
// check that exceptions are thrown as required
var passes = true;
passes = passes & assertThrows(function() {
// should throw TYPE_MISMATCH_ERR
document.getElementById("container").insertAdjacentElement("blah", document.getElementById("1"));
});
passes = passes & assertThrows(function() {
// should throw NOT_SUPPORTED_ERR
document.getElementById("container").insertAdjacentElement("beforeEnd", null);
});
var elt = document.createElement("div");
passes = passes & (elt.insertAdjacentElement("beforeBegin", document.createElement("p")) == null);
if (passes) {
document.getElementById("status").style.color = "green";
document.getElementById("status").innerHTML = "PASS";
}
</script>