summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/script-tests/method-check.js
blob: c1ca3bd728e8513e2d2ea5a19bcff2835a373d4a (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
48
49
50
51
52
53
54
55
56
57
58
description(
"Test method-check related bugs"
);

function func2() { }

// This test yields PASS, if malloc does not reuse the memory address for the structure of String prototype
function func()
{
    String.prototype.a = function() { }
    String.prototype.b = function() { }

    if (window.GCController)
        GCController.collect();
    else {
        // The following 3 lines cause gc() flush on a Debian
        // Linux machine, but there is no garantee, it works on
        // any other computer. (Not even another Debian Linux)
        // If func2() is not called or a much bigger or lower
        // value than 5000 is chosen, the crash won't happen
        func2()
        for (var i = 0; i < 5000; ++i)
            new Boolean()
    }

    var str = ""
    for (var i = 0; i < 5; ++i)
        str.a()
}

func()
func()

// Test that method caching correctly invalidates (doesn't incorrectly continue to call a previously cached function).
var total = 0;
function addOne()
{
    ++total;
}
function addOneHundred()
{
    total+=100;
}
var totalizer = {
    makeCall: function(callback)
    {
        this.callback = callback;
        this.callback();
    }
};
for (var i=0; i<100; ++i)
    totalizer.makeCall(addOne);
totalizer.makeCall(addOneHundred);
shouldBe('total', '200');

// Check that we don't assert when method_check is applied to a non-JSFunction
for (var i = 0; i < 10000; i++)
    Array.constructor(1);