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 <div style="display: none"> | 5 <div style="display: none"> |
6 <span id="1"> | 6 <span id="1"> |
7 1 (black) | 7 1 (black) |
8 </span> | 8 </span> |
9 <span id="2"> | 9 <span id="2"> |
10 2 (green) | 10 2 (green) |
(...skipping 16 matching lines...) Expand all Loading... |
27 // verify all standard cases | 27 // verify all standard cases |
28 document.getElementById("container").insertAdjacentElement("beforeBegin", doc
ument.getElementById("1")); | 28 document.getElementById("container").insertAdjacentElement("beforeBegin", doc
ument.getElementById("1")); |
29 document.getElementById("container").insertAdjacentElement("afterBegin", docu
ment.getElementById("2")); | 29 document.getElementById("container").insertAdjacentElement("afterBegin", docu
ment.getElementById("2")); |
30 document.getElementById("container").insertAdjacentElement("beforeEnd", docum
ent.getElementById("3")); | 30 document.getElementById("container").insertAdjacentElement("beforeEnd", docum
ent.getElementById("3")); |
31 document.getElementById("container").insertAdjacentElement("afterEnd", docume
nt.getElementById("4")); | 31 document.getElementById("container").insertAdjacentElement("afterEnd", docume
nt.getElementById("4")); |
32 | 32 |
33 function assertThrows(func) { | 33 function assertThrows(func) { |
34 var testPassed = false; | 34 var testPassed = false; |
35 try { | 35 try { |
36 func(); | 36 func(); |
| 37 document.getElementById("error-log").textContent += "Expected exception
missing.\n"; |
37 } catch (e) { | 38 } catch (e) { |
38 document.getElementById("error-log").innerHTML += "Caught expected exce
ption: " + e + "\n"; | 39 document.getElementById("error-log").textContent += "Caught expected ex
ception: " + e + "\n"; |
39 testPassed = true; | 40 testPassed = true; |
40 } | 41 } |
41 return testPassed; | 42 return testPassed; |
42 } | 43 } |
43 | 44 |
44 // check that exceptions are thrown as required | 45 // check that exceptions are thrown as required |
45 var passes = true; | 46 var passes = true; |
46 passes = passes & assertThrows(function() { | 47 passes = assertThrows(function() { |
47 // should throw TYPE_MISMATCH_ERR | 48 // should throw SyntaxError |
48 document.getElementById("container").insertAdjacentElement("blah", documen
t.getElementById("1")); | 49 document.getElementById("container").insertAdjacentElement("blah", documen
t.getElementById("1")); |
49 }); | 50 }) && passes; |
50 passes = passes & assertThrows(function() { | 51 passes = assertThrows(function() { |
51 // should throw NOT_SUPPORTED_ERR | 52 // should throw TypeError |
52 document.getElementById("container").insertAdjacentElement("beforeEnd", nu
ll); | 53 document.getElementById("container").insertAdjacentElement("beforeEnd", nu
ll); |
53 }); | 54 }) && passes; |
| 55 passes = assertThrows(function() { |
| 56 // should throw TypeError |
| 57 document.getElementById("container").insertAdjacentElement("beforeEnd"); |
| 58 }) && passes; |
| 59 passes = assertThrows(function() { |
| 60 // should throw TypeError |
| 61 document.getElementById("container").insertAdjacentElement(); |
| 62 }) && passes; |
54 | 63 |
55 var elt = document.createElement("div"); | 64 var elt = document.createElement("div"); |
56 passes = passes & (elt.insertAdjacentElement("beforeBegin", document.createEl
ement("p")) == null); | 65 passes = passes && (elt.insertAdjacentElement("beforeBegin", document.createE
lement("p")) == null); |
57 if (passes) { | 66 if (passes) { |
58 document.getElementById("status").style.color = "green"; | 67 document.getElementById("status").style.color = "green"; |
59 document.getElementById("status").innerHTML = "<br><br>PASS"; | 68 document.getElementById("status").innerHTML = "<br><br>PASS"; |
60 } | 69 } |
61 </script> | 70 </script> |
OLD | NEW |