summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/exception-thrown-from-function-with-lazy-activation.html
blob: 3717d8cf1762534340808f513334be16d28d9fc7 (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
<p>This page tests whether an exception thrown from a function that has lazily
constructed an activation properly tears off the function's activation.
</p>
<p>If the test passes, you'll see a PASS message below.
</p>
<pre id="console"></pre>

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

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

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

try {
    // Lazily create an activation for a function that otherwise wouldn't need one, then throw.
    (function f(x) {
        throw f.arguments;
    }(1));
} catch(args) {
    // Call another function to overwrite the stack.
    (function (a, b, c, d, e, f, g, h, i, j, k, l) { })();
    
    // Test whether args's activation was properly torn off. If it wasn't, the
    // previous call should have clobbered its data.
    shouldBe("args[0]", args[0], 1);
}

</script>