Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dynamic / insertAdjacentHTML.html
blob96496ff6e5e33fb4034b8261ff9805cb9177c81b
1 <body>
2 <pre id="error-log"></pre>
3 <span id="container" style="color: green">
4 </span>
5 <span id="status" style="color: red">
6 FAILURE
7 </span>
8 </body>
9 <script>
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;
21 try {
22 func();
23 document.getElementById("error-log").textContent += "Expected exception missing.\n";
24 } catch (e) {
25 document.getElementById("error-log").textContent += "Caught expected exception: " + e + "\n";
26 testPassed = true;
28 return testPassed;
31 // check that exceptions are thrown as required
32 var passes = true;
33 passes = assertThrows(function() {
34 // should throw SyntaxError
35 document.getElementById("container").insertAdjacentHTML("blah", "<span>html</span>");
36 }) && passes;
37 passes = assertThrows(function() {
38 // Should throw NoModificationAllowedError
39 document.createElement('div').insertAdjacentHTML("afterEnd", "<span>html</span>");
40 }) && passes;
41 passes = assertThrows(function() {
42 // Should throw TypeError
43 document.getElementById("container").insertAdjacentHTML();
44 }) && passes;
45 passes = assertThrows(function() {
46 // Should throw TypeError
47 document.getElementById("container").insertAdjacentHTML("beforeBegin");
48 }) && passes;
50 if (passes) {
51 document.getElementById("status").style.color = "green";
52 document.getElementById("status").innerHTML = "<br><br>PASS";
54 </script>