@@ -50,6 +50,29 @@ function now() {
50
50
}
51
51
52
52
describe ( 'TraceKit' , function ( ) {
53
+ describe ( 'stacktrace info' , function ( ) {
54
+ it ( 'should not remove anonymous functions from the stack' , function ( ) {
55
+ // mock up an error object with a stack trace that includes both
56
+ // named functions and anonymous functions
57
+ var stack_str = "" +
58
+ " Error: \n" +
59
+ " at namedFunc0 (http://example.com/js/script.js:10)\n" + // stack[0]
60
+ " at http://example.com/js/test.js:65\n" + // stack[1]
61
+ " at namedFunc2 (http://example.com/js/script.js:20)\n" + // stack[2]
62
+ " at http://example.com/js/test.js:67\n" + // stack[3]
63
+ " at namedFunc4 (http://example.com/js/script.js:100001)" ; // stack[4]
64
+ var mock_err = { stack : stack_str } ;
65
+ var trace = TraceKit . computeStackTrace . computeStackTraceFromStackProp ( mock_err ) ;
66
+
67
+ // Make sure TraceKit didn't remove the anonymous functions
68
+ // from the stack like it used to :)
69
+ assert . equal ( trace . stack [ 0 ] . func , 'namedFunc0' ) ;
70
+ assert . equal ( trace . stack [ 1 ] . func , '?' ) ;
71
+ assert . equal ( trace . stack [ 2 ] . func , 'namedFunc2' ) ;
72
+ assert . equal ( trace . stack [ 3 ] . func , '?' ) ;
73
+ assert . equal ( trace . stack [ 4 ] . func , 'namedFunc4' ) ;
74
+ } ) ;
75
+ } ) ;
53
76
describe ( 'error notifications' , function ( ) {
54
77
var testMessage = "__mocha_ignore__" ;
55
78
var subscriptionHandler ;
0 commit comments