Skip to content

Commit 944d9f5

Browse files
committed
Merge pull request #294 from juriejan/chrome-regex-for-anon
Cover both reported Chrome anonymous function stacktrace lines
2 parents cfdb220 + 831b1f0 commit 944d9f5

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

test/raven.test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,23 @@ describe('TraceKit', function(){
5656
// named functions and anonymous functions
5757
var stack_str = "" +
5858
" 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]
59+
" at new <anonymous> (http://example.com/js/test.js:63)\n" + // stack[0]
60+
" at namedFunc0 (http://example.com/js/script.js:10)\n" + // stack[1]
61+
" at http://example.com/js/test.js:65\n" + // stack[2]
62+
" at namedFunc2 (http://example.com/js/script.js:20)\n" + // stack[3]
63+
" at http://example.com/js/test.js:67\n" + // stack[4]
64+
" at namedFunc4 (http://example.com/js/script.js:100001)"; // stack[5]
6465
var mock_err = { stack: stack_str };
6566
var trace = TraceKit.computeStackTrace.computeStackTraceFromStackProp(mock_err);
6667

6768
// Make sure TraceKit didn't remove the anonymous functions
6869
// 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');
70+
assert.equal(trace.stack[0].func, 'new <anonymous>');
71+
assert.equal(trace.stack[1].func, 'namedFunc0');
72+
assert.equal(trace.stack[2].func, '?');
73+
assert.equal(trace.stack[3].func, 'namedFunc2');
74+
assert.equal(trace.stack[4].func, '?');
75+
assert.equal(trace.stack[5].func, 'namedFunc4');
7476
});
7577
});
7678
describe('error notifications', function(){

vendor/TraceKit/tracekit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
631631
return null;
632632
}
633633

634-
var chrome = /^\s*at (\S*) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
634+
var chrome = /^\s*at (.*?) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
635635
gecko = /^\s*(.*?)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,
636636
lines = ex.stack.split('\n'),
637637
stack = [],

0 commit comments

Comments
 (0)