2 <pre id=
"error-log"></pre>
3 <span id=
"container" style=
"color: green">
5 <span id=
"status" style=
"color: red">
10 if (window
.testRunner
)
11 testRunner
.dumpAsText();
13 // verify all standard cases
14 document
.getElementById("container").insertAdjacentHTML("beforeBegin", "<span id='1''> 1 (black)</span>");
15 document
.getElementById("container").insertAdjacentHTML("afterBegin", "<span id='2''> 2 (green)</span>");
16 document
.getElementById("container").insertAdjacentHTML("beforeEnd", "<span id='3''> 3 (green)</span>");
17 document
.getElementById("container").insertAdjacentHTML("afterEnd", "<span id='4''> 4 (black)</span>");
19 function assertThrows(func
) {
20 var testPassed
= false;
23 document
.getElementById("error-log").textContent
+= "Expected exception missing.\n";
25 document
.getElementById("error-log").textContent
+= "Caught expected exception: " + e
+ "\n";
31 // check that exceptions are thrown as required
33 passes
= assertThrows(function() {
34 // should throw SyntaxError
35 document
.getElementById("container").insertAdjacentHTML("blah", "<span>html</span>");
37 passes
= assertThrows(function() {
38 // Should throw NoModificationAllowedError
39 document
.createElement('div').insertAdjacentHTML("afterEnd", "<span>html</span>");
41 passes
= assertThrows(function() {
42 // Should throw TypeError
43 document
.getElementById("container").insertAdjacentHTML();
45 passes
= assertThrows(function() {
46 // Should throw TypeError
47 document
.getElementById("container").insertAdjacentHTML("beforeBegin");
51 document
.getElementById("status").style
.color
= "green";
52 document
.getElementById("status").innerHTML
= "<br><br>PASS";