Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / exception-thrown-from-new.html
blob992405107acc918cf251805555e1ebc4a5c61a7c
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>
7 <script>
8 function log(s)
10 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
13 function shouldBe(a, aDescription, b)
15 if (a == b) {
16 log("PASS: " + aDescription + " should be '" + String(b) + "' and is.");
17 return;
20 log ("FAIL: " + aDescription + " should be '" + String(b) + "' but instead is '" + String(a) + "'.");
23 if (window.testRunner)
24 testRunner.dumpAsText();
26 (function () {
27 try {
28 var f;
29 new f;
30 } catch(e1) {
31 shouldBe(e1, "e1", "TypeError: 'undefined' is not a constructor (evaluating 'new f')");
33 })();
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()')");
43 })();
44 </script>