summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/exception-thrown-from-new.html
blob: 88ac6b8d4426606e9406240cd2cf7801b2c9463d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<p>
This page tests exceptions thrown from 'new' expressions. If the test passes,
you'll see a series of PASS messages below.
</p>
<pre id="console"></pre>

<script>
function log(s)
{
    document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}

function shouldBe(a, aDescription, b)
{
    if (a == b) {
        log("PASS: " + aDescription + " should be '" + String(b) + "' and is.");
        return;
    }
    
    log ("FAIL: " + aDescription + " should be '" + String(b) + "' but instead is '" + String(a) + "'.");
}

if (window.layoutTestController)
    layoutTestController.dumpAsText();

(function () {
    try {
        var f;
        new f;
    } catch(e1) {
        shouldBe(e1, "e1", "TypeError: 'undefined' is not a constructor (evaluating 'new f')");
    }
})();

(function () {
    try {
        var f;
        var g;
        new f(g());
    } catch(e2) {
        shouldBe(e2, "e2", "TypeError: 'undefined' is not a function (evaluating 'g()')");
    }
})();
</script>