OLD | NEW |
1 <body> | 1 <body> |
2 <pre id="error-log"></pre> | 2 <pre id="error-log"></pre> |
3 <span id="container" style="color: green"> | 3 <span id="container" style="color: green"> |
4 </span> | 4 </span> |
5 <span id="status" style="color: red"> | 5 <span id="status" style="color: red"> |
6 FAILURE | 6 FAILURE |
7 </span> | 7 </span> |
8 </body> | 8 </body> |
9 <script> | 9 <script> |
10 if (window.testRunner) | 10 if (window.testRunner) |
11 testRunner.dumpAsText(); | 11 testRunner.dumpAsText(); |
12 | 12 |
13 // verify all standard cases | 13 // verify all standard cases |
14 document.getElementById("container").insertAdjacentHTML("beforeBegin", "<span
id='1''> 1 (black)</span>"); | 14 document.getElementById("container").insertAdjacentHTML("beforeBegin", "<span
id='1''> 1 (black)</span>"); |
15 document.getElementById("container").insertAdjacentHTML("afterBegin", "<span
id='2''> 2 (green)</span>"); | 15 document.getElementById("container").insertAdjacentHTML("afterBegin", "<span
id='2''> 2 (green)</span>"); |
16 document.getElementById("container").insertAdjacentHTML("beforeEnd", "<span i
d='3''> 3 (green)</span>"); | 16 document.getElementById("container").insertAdjacentHTML("beforeEnd", "<span i
d='3''> 3 (green)</span>"); |
17 document.getElementById("container").insertAdjacentHTML("afterEnd", "<span id
='4''> 4 (black)</span>"); | 17 document.getElementById("container").insertAdjacentHTML("afterEnd", "<span id
='4''> 4 (black)</span>"); |
18 | 18 |
19 function assertThrows(func) { | 19 function assertThrows(func) { |
20 var testPassed = false; | 20 var testPassed = false; |
21 try { | 21 try { |
22 func(); | 22 func(); |
23 document.getElementById("error-log").innerHTML += "Expected exception m
issing.\n"; | 23 document.getElementById("error-log").textContent += "Expected exception
missing.\n"; |
24 } catch (e) { | 24 } catch (e) { |
25 document.getElementById("error-log").innerHTML += "Caught expected exce
ption: " + e + "\n"; | 25 document.getElementById("error-log").textContent += "Caught expected ex
ception: " + e + "\n"; |
26 testPassed = true; | 26 testPassed = true; |
27 } | 27 } |
28 return testPassed; | 28 return testPassed; |
29 } | 29 } |
30 | 30 |
31 // check that exceptions are thrown as required | 31 // check that exceptions are thrown as required |
32 var passes = true; | 32 var passes = true; |
33 passes = assertThrows(function() { | 33 passes = assertThrows(function() { |
34 // should throw TYPE_MISMATCH_ERR | 34 // should throw SyntaxError |
35 document.getElementById("container").insertAdjacentHTML("blah", "<span>htm
l</span>"); | 35 document.getElementById("container").insertAdjacentHTML("blah", "<span>htm
l</span>"); |
36 }) && passes; | 36 }) && passes; |
37 | |
38 passes = assertThrows(function() { | 37 passes = assertThrows(function() { |
39 // Should throw NoModificationAllowedError. | 38 // Should throw NoModificationAllowedError |
40 document.createElement('div').insertAdjacentHTML("afterEnd", "<span>html</
span>"); | 39 document.createElement('div').insertAdjacentHTML("afterEnd", "<span>html</
span>"); |
41 }) && passes; | 40 }) && passes; |
42 | |
43 passes = assertThrows(function() { | 41 passes = assertThrows(function() { |
44 document.getElementById("container").insertAdjacentHTML(); | 42 // Should throw TypeError |
| 43 document.getElementById("container").insertAdjacentHTML(); |
45 }) && passes; | 44 }) && passes; |
46 | |
47 passes = assertThrows(function() { | 45 passes = assertThrows(function() { |
48 document.getElementById("container").insertAdjacentHTML("beforeBegin"); | 46 // Should throw TypeError |
| 47 document.getElementById("container").insertAdjacentHTML("beforeBegin"); |
49 }) && passes; | 48 }) && passes; |
50 | 49 |
51 if (passes) { | 50 if (passes) { |
52 document.getElementById("status").style.color = "green"; | 51 document.getElementById("status").style.color = "green"; |
53 document.getElementById("status").innerHTML = "<br><br>PASS"; | 52 document.getElementById("status").innerHTML = "<br><br>PASS"; |
54 } | 53 } |
55 </script> | 54 </script> |
OLD | NEW |