@@ -10,23 +10,46 @@ describe('TraceKit', function(){
1010 // named functions and anonymous functions
1111 var stack_str = "" +
1212 " Error: \n" +
13- " at new <anonymous> (http://example.com/js/test.js:63)\n" + // stack[0]
14- " at namedFunc0 (http://example.com/js/script.js:10)\n" + // stack[1]
15- " at http://example.com/js/test.js:65\n" + // stack[2]
16- " at namedFunc2 (http://example.com/js/script.js:20)\n" + // stack[3]
17- " at http://example.com/js/test.js:67\n" + // stack[4]
18- " at namedFunc4 (http://example.com/js/script.js:100001)" ; // stack[5]
13+ " at new <anonymous> (http://example.com/js/test.js:63:1 )\n" + // stack[0]
14+ " at namedFunc0 (http://example.com/js/script.js:10:2 )\n" + // stack[1]
15+ " at http://example.com/js/test.js:65:10 \n" + // stack[2]
16+ " at namedFunc2 (http://example.com/js/script.js:20:5 )\n" + // stack[3]
17+ " at http://example.com/js/test.js:67:5 \n" + // stack[4]
18+ " at namedFunc4 (http://example.com/js/script.js:100001:10002 )" ; // stack[5]
1919 var mock_err = { stack : stack_str } ;
2020 var trace = TraceKit . computeStackTrace . computeStackTraceFromStackProp ( mock_err ) ;
2121
2222 // Make sure TraceKit didn't remove the anonymous functions
2323 // from the stack like it used to :)
2424 assert . equal ( trace . stack [ 0 ] . func , 'new <anonymous>' ) ;
25+ assert . equal ( trace . stack [ 0 ] . url , 'http://example.com/js/test.js' ) ;
26+ assert . equal ( trace . stack [ 0 ] . line , 63 ) ;
27+ assert . equal ( trace . stack [ 0 ] . column , 1 ) ;
28+
2529 assert . equal ( trace . stack [ 1 ] . func , 'namedFunc0' ) ;
30+ assert . equal ( trace . stack [ 1 ] . url , 'http://example.com/js/script.js' ) ;
31+ assert . equal ( trace . stack [ 1 ] . line , 10 ) ;
32+ assert . equal ( trace . stack [ 1 ] . column , 2 ) ;
33+
2634 assert . equal ( trace . stack [ 2 ] . func , '?' ) ;
35+ assert . equal ( trace . stack [ 2 ] . url , 'http://example.com/js/test.js' ) ;
36+ assert . equal ( trace . stack [ 2 ] . line , 65 ) ;
37+ assert . equal ( trace . stack [ 2 ] . column , 10 ) ;
38+
2739 assert . equal ( trace . stack [ 3 ] . func , 'namedFunc2' ) ;
40+ assert . equal ( trace . stack [ 3 ] . url , 'http://example.com/js/script.js' ) ;
41+ assert . equal ( trace . stack [ 3 ] . line , 20 ) ;
42+ assert . equal ( trace . stack [ 3 ] . column , 5 ) ;
43+
2844 assert . equal ( trace . stack [ 4 ] . func , '?' ) ;
45+ assert . equal ( trace . stack [ 4 ] . url , 'http://example.com/js/test.js' ) ;
46+ assert . equal ( trace . stack [ 4 ] . line , 67 ) ;
47+ assert . equal ( trace . stack [ 4 ] . column , 5 ) ;
48+
2949 assert . equal ( trace . stack [ 5 ] . func , 'namedFunc4' ) ;
50+ assert . equal ( trace . stack [ 5 ] . url , 'http://example.com/js/script.js' ) ;
51+ assert . equal ( trace . stack [ 5 ] . line , 100001 ) ;
52+ assert . equal ( trace . stack [ 5 ] . column , 10002 ) ;
3053 } ) ;
3154
3255 it ( 'should handle eval/anonymous strings in Chrome 46' , function ( ) {
@@ -39,8 +62,20 @@ describe('TraceKit', function(){
3962 var mock_err = { stack : stack_str } ;
4063 var trace = TraceKit . computeStackTrace . computeStackTraceFromStackProp ( mock_err ) ;
4164 assert . equal ( trace . stack [ 0 ] . func , 'bar' ) ;
65+ assert . equal ( trace . stack [ 0 ] . url , 'http://example.com/js/test.js' ) ;
66+ assert . equal ( trace . stack [ 0 ] . line , 19 ) ;
67+ assert . equal ( trace . stack [ 0 ] . column , 7 ) ;
68+
4269 assert . equal ( trace . stack [ 1 ] . func , 'foo' ) ;
70+ assert . equal ( trace . stack [ 1 ] . url , 'http://example.com/js/test.js' ) ;
71+ assert . equal ( trace . stack [ 1 ] . line , 23 ) ;
72+ assert . equal ( trace . stack [ 1 ] . column , 7 ) ;
73+
4374 assert . equal ( trace . stack [ 2 ] . func , 'eval' ) ;
75+ // TODO: fix nested evals
76+ assert . equal ( trace . stack [ 2 ] . url , 'eval at <anonymous> (http://example.com/js/test.js:26:5), <anonymous>' ) ;
77+ assert . equal ( trace . stack [ 2 ] . line , 1 ) ; // second set of line/column numbers used
78+ assert . equal ( trace . stack [ 2 ] . column , 26 ) ;
4479 } ) ;
4580 } ) ;
4681
0 commit comments