summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/script-tests/duplicate-param-gc-crash.js
blob: c11806a153cf5c1d71dd2d39e811c1fb6f5040d1 (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
45
46
47
description(
'Tests to ensure that activations are built correctly in the face of duplicate parameter names and do not cause crashes.'
);

function gc()
{
    if (this.GCController)
        GCController.collect();
    else
        for (var i = 0; i < 10000; ++i) // Allocate a sufficient number of objects to force a GC.
            ({});
}

function eatRegisters(param)
{
    if (param > 10)
        return;
    eatRegisters(param + 1);
}

function test1(a, b, b, b, b, b, b) {
    return function() {
        return a[0];
    }
}

var test1Closure = test1(["success"]);

var extra = test1("success");
eatRegisters(0);
gc();

shouldBe('test1Closure()', '"success"');

function test2(a, a, a, a, a, a, b) {
    return function() {
        return b[0];
    }
}

var test2Closure = test2("success", "success", "success", "success", "success", "success", ["success"]);
extra =  test2("success", "success", "success", "success", "success", "success", ["success"]);

eatRegisters(0);
gc();

shouldBe('test2Closure()', '"success"');