7 'This test checks stack trace corectness in special cases.'
10 function printStack(stackTrace
) {
11 debug("--> Stack Trace:")
12 stackTrace
= stackTrace
.split("\n");
13 var length
= Math
.min(stackTrace
.length
, 100);
14 for (var i
= 0; i
< length
; i
++) {
15 var indexOfAt
= stackTrace
[i
].indexOf('@')
16 var indexOfLastSlash
= stackTrace
[i
].lastIndexOf('/');
17 if (indexOfLastSlash
== -1)
18 indexOfLastSlash
= indexOfAt
19 var functionName
= stackTrace
[i
].substring(0, indexOfAt
);
20 var fileName
= stackTrace
[i
].substring(indexOfLastSlash
+ 1);
21 debug(" " + i
+ " " + functionName
+ " at " + fileName
);
25 function hostThrower() { Element
.prototype.appendChild
.call({ }, [{ }]); }
26 function callbacker(f
) { [0].map(f
); }
27 function outer(errorName
) { inner(errorName
); }
28 function inner(errorName
) { throw new Error("Error in " + errorName
); }
29 function evaler(code
) { eval(code
); }
30 function normalOuter() { normalInner(); }
31 function normalInner() { if(thisVarDoesntExist
) failIfTrue("shouldFailBeforeThis") };
32 function scripterInner() { htmlInner(); }
33 function scripterOuter() { htmlOuter(); }
34 // Expected functions in stack trace
36 try { normalOuter() } catch (e
) { printStack(e
.stack
) } // normalOuter -> normalInner
39 try { evaler("inner('inner eval');"); } catch (e
) { printStack(e
.stack
) } // evaler -> eval -> inner
40 try { evaler("outer('outer eval');"); } catch (e
) { printStack(e
.stack
) } // evaler -> eval -> outer -> inner
42 // Function Callback Case
43 try { callbacker(inner('inner map')); } catch (e
) { printStack(e
.stack
); } // callbacker -> map -> inner
44 try { callbacker(outer('outer map')); } catch (e
) { printStack(e
.stack
); } // callbacker -> map -> outer -> inner
47 try { hostThrower(); } catch (e
) { printStack(e
.stack
); } // hostThrower
49 try { scripterInner(); } catch (e
) { printStack(e
.stack
) } // program -> scripter -> inner
50 try { scripterOuter(); } catch (e
) { printStack(e
.stack
) } // program -> scripter -> outer -> inner
52 function selfRecursive1() { selfRecursive1();
56 try { selfRecursive1(); } catch (e
) { printStack(e
.stack
) } // selfRecursive1 -> selfRecursive1 -> selfRecursive1 -> selfRecursive1 ...
58 function selfRecursive2() {
59 // A little work to make the DFG kick in
60 for (var i
= 0; i
< 10; i
++) {
66 try { selfRecursive2(); } catch (e
) { printStack(e
.stack
) } // selfRecursive2 -> selfRecursive2 -> selfRecursive2 -> selfRecursive2 ...
68 function selfRecursive3() {
69 eval("selfRecursive3()");
72 try { selfRecursive3(); } catch (e
) { printStack(e
.stack
) } // selfRecursive3 -> eval -> selfRecursive3 -> eval ...
76 function throwError() {
100 valueOf: function () {
104 if (callCount
== 9998)
106 if (callCount
== 9999)
109 nonInlineable : function () {
110 if (0) return [arguments
, function(){}];
112 if (callCount
== 1) {
114 } else if (callCount
== 2) {
120 inlineable : function () {
121 this.nonInlineable();
125 function yetAnotherInlinedCall(o
) {
129 function makeInlinableCall(o
) {
130 for (var i
= 0; i
< 10000; i
++) {
131 new yetAnotherInlinedCall(o
);
134 for (var k
= 0; k
< 4; k
++) {
138 for (var i
= 0; i
< 1000; i
++) {
140 makeInlinableCall(object
);
150 if (callCount
++ == 1000)
152 if (callCount
> 1000) {
153 [].map
.apply(undefined, throwError
);
157 function mapTest(a
) {
161 function mapTestDriver() {
163 for (var i
= 0; i
< 2000; i
++)
180 var dfgFunctionShouldThrow
= false;
181 function dfgFunction() {
182 if (dfgFunctionShouldThrow
) {
183 dfgFunctionShouldThrow
= false;
188 for (var k
= 0; k
< 1000; k
++)
192 dfgFunctionShouldThrow
= true;
193 [1,2,3,4].map(dfgFunction
);
200 o
.__defineGetter__("g", dfgFunction
);
204 for (var k
= 0; k
< 1000; k
++)
207 dfgFunctionShouldThrow
= true;
214 var someValue
= null;
216 function callNonCallable() {
220 for (var i
= 0; i
< 100; i
++) {
227 successfullyParsed
= true;