blob: a8b9ab60127c3341210e38c1ec3891bbe73e32ff [file] [log] [blame]
<body>
<pre id="error-log"></pre>
<span id="container" style="color: green">
</span>
<span id="status" style="color: red">
FAILURE
</span>
</body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
// verify all standard cases
document.getElementById("container").insertAdjacentText("beforeBegin", " 1 (black)");
document.getElementById("container").insertAdjacentText("afterBegin", " 2 (green)");
document.getElementById("container").insertAdjacentText("beforeEnd", " 3 (green)");
document.getElementById("container").insertAdjacentText("afterEnd", " 4 (black)");
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").insertAdjacentText("blah", "text");
});
if (passes) {
document.getElementById("status").style.color = "green";
document.getElementById("status").innerHTML = "<br><br>PASS";
}
</script>