| OLD | NEW |
| (Empty) |
| 1 <p> | |
| 2 This page tests exceptions thrown from 'new' expressions. If the test passes, | |
| 3 you'll see a series of PASS messages below. | |
| 4 </p> | |
| 5 <pre id="console"></pre> | |
| 6 | |
| 7 <script> | |
| 8 function log(s) | |
| 9 { | |
| 10 document.getElementById("console").appendChild(document.createTextNode(s + "
\n")); | |
| 11 } | |
| 12 | |
| 13 function shouldBe(a, aDescription, b) | |
| 14 { | |
| 15 if (a == b) { | |
| 16 log("PASS: " + aDescription + " should be '" + String(b) + "' and is."); | |
| 17 return; | |
| 18 } | |
| 19 | |
| 20 log ("FAIL: " + aDescription + " should be '" + String(b) + "' but instead i
s '" + String(a) + "'."); | |
| 21 } | |
| 22 | |
| 23 if (window.testRunner) | |
| 24 testRunner.dumpAsText(); | |
| 25 | |
| 26 (function () { | |
| 27 try { | |
| 28 var f; | |
| 29 new f; | |
| 30 } catch(e1) { | |
| 31 shouldBe(e1, "e1", "TypeError: 'undefined' is not a constructor (evaluat
ing 'new f')"); | |
| 32 } | |
| 33 })(); | |
| 34 | |
| 35 (function () { | |
| 36 try { | |
| 37 var f; | |
| 38 var g; | |
| 39 new f(g()); | |
| 40 } catch(e2) { | |
| 41 shouldBe(e2, "e2", "TypeError: 'undefined' is not a function (evaluating
'g()')"); | |
| 42 } | |
| 43 })(); | |
| 44 </script> | |
| OLD | NEW |