]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | // Test that the ClonedArguments created by the Function.arguments will properly |
2 | // keep its callee alive. This test should not crash and should not print any error | |
3 | // messages. | |
4 | ||
5 | var cachedArguments = []; | |
6 | var numberOfEntries = 1000; | |
7 | ||
8 | function makeTransientFunction(i) { | |
9 | function transientFunc() { | |
10 | cachedArguments[i] = transientFunc.arguments; | |
11 | } | |
12 | return transientFunc; | |
13 | } | |
14 | ||
15 | for (i = 0; i < numberOfEntries; i++) { | |
16 | var transientFunc = makeTransientFunction(i); | |
17 | transientFunc(); | |
18 | // At this point, the only reference to the transient function is from | |
19 | // cachedArguments[i].callee. | |
20 | } | |
21 | ||
22 | gc(); | |
23 | ||
24 | // Allocate a bunch of memory to stomp over the transient functions that may have been | |
25 | // erroneously collected. webkit.org/b/145709 | |
26 | for (i = 0; i < numberOfEntries; i++) { | |
27 | new Object(); | |
28 | } | |
29 | ||
30 | for (i = 0; i < numberOfEntries; i++) { | |
31 | var callee = cachedArguments[i].callee; | |
32 | if (typeof callee != "function") | |
33 | print("ERROR: callee is " + callee); | |
34 | } |