2 <pre id=
"error-log"></pre>
3 <span id=
"container" style=
"color: green">
5 <div style=
"display: none">
19 <span id=
"status" style=
"color: red">
24 if (window
.testRunner
)
25 testRunner
.dumpAsText();
27 // verify all standard cases
28 document
.getElementById("container").insertAdjacentElement("beforeBegin", document
.getElementById("1"));
29 document
.getElementById("container").insertAdjacentElement("afterBegin", document
.getElementById("2"));
30 document
.getElementById("container").insertAdjacentElement("beforeEnd", document
.getElementById("3"));
31 document
.getElementById("container").insertAdjacentElement("afterEnd", document
.getElementById("4"));
33 function assertThrows(func
) {
34 var testPassed
= false;
37 document
.getElementById("error-log").textContent
+= "Expected exception missing.\n";
39 document
.getElementById("error-log").textContent
+= "Caught expected exception: " + e
+ "\n";
45 // check that exceptions are thrown as required
47 passes
= assertThrows(function() {
48 // should throw SyntaxError
49 document
.getElementById("container").insertAdjacentElement("blah", document
.getElementById("1"));
51 passes
= assertThrows(function() {
52 // should throw TypeError
53 document
.getElementById("container").insertAdjacentElement("beforeEnd", null);
55 passes
= assertThrows(function() {
56 // should throw TypeError
57 document
.getElementById("container").insertAdjacentElement("beforeEnd");
59 passes
= assertThrows(function() {
60 // should throw TypeError
61 document
.getElementById("container").insertAdjacentElement();
64 var elt
= document
.createElement("div");
65 passes
= passes
&& (elt
.insertAdjacentElement("beforeBegin", document
.createElement("p")) == null);
67 document
.getElementById("status").style
.color
= "green";
68 document
.getElementById("status").innerHTML
= "<br><br>PASS";