Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / method-check.js
blobc1ca3bd728e8513e2d2ea5a19bcff2835a373d4a
1 description(
2 "Test method-check related bugs"
3 );
5 function func2() { }
7 // This test yields PASS, if malloc does not reuse the memory address for the structure of String prototype
8 function func()
10 String.prototype.a = function() { }
11 String.prototype.b = function() { }
13 if (window.GCController)
14 GCController.collect();
15 else {
16 // The following 3 lines cause gc() flush on a Debian
17 // Linux machine, but there is no garantee, it works on
18 // any other computer. (Not even another Debian Linux)
19 // If func2() is not called or a much bigger or lower
20 // value than 5000 is chosen, the crash won't happen
21 func2()
22 for (var i = 0; i < 5000; ++i)
23 new Boolean()
26 var str = ""
27 for (var i = 0; i < 5; ++i)
28 str.a()
31 func()
32 func()
34 // Test that method caching correctly invalidates (doesn't incorrectly continue to call a previously cached function).
35 var total = 0;
36 function addOne()
38 ++total;
40 function addOneHundred()
42 total+=100;
44 var totalizer = {
45 makeCall: function(callback)
47 this.callback = callback;
48 this.callback();
51 for (var i=0; i<100; ++i)
52 totalizer.makeCall(addOne);
53 totalizer.makeCall(addOneHundred);
54 shouldBe('total', '200');
56 // Check that we don't assert when method_check is applied to a non-JSFunction
57 for (var i = 0; i < 10000; i++)
58 Array.constructor(1);