Skip to content

Commit 7339bd8

Browse files
dmosebenvinegar
authored andcommitted
Fix stacks including Firefox resource: URLs (#836)
1 parent 2de41aa commit 7339bd8

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

test/vendor/fixtures/captured-errors.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,15 @@ CapturedExceptions.PHANTOMJS_1_19 = {
340340
" at http://path/to/file.js:4287"
341341
};
342342

343+
CapturedExceptions.FIREFOX_50_RESOURCE_URL= {
344+
stack: 'render@resource://path/data/content/bundle.js:5529:16\n' +
345+
'dispatchEvent@resource://path/data/content/vendor.bundle.js:18:23028\n' +
346+
'wrapped@resource://path/data/content/bundle.js:7270:25',
347+
fileName: 'resource://path/data/content/bundle.js',
348+
lineNumber: 5529,
349+
columnNumber: 16,
350+
message: 'this.props.raw[this.state.dataSource].rows is undefined',
351+
name: 'TypeError'
352+
};
353+
343354
module.exports = CapturedExceptions;

test/vendor/tracekit-parser.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,13 @@ describe('TraceKit', function () {
209209
assert.deepEqual(stackFrames.stack[1], { url: 'http://path/to/file.js', func: 'foo', args: [], line: 4283, column: null });
210210
assert.deepEqual(stackFrames.stack[2], { url: 'http://path/to/file.js', func: '?', args: [], line: 4287, column: null });
211211
});
212+
213+
it('should parse Firefox errors with resource: URLs', function () {
214+
var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.FIREFOX_50_RESOURCE_URL);
215+
assert.ok(stackFrames);
216+
assert.deepEqual(stackFrames.stack.length, 3);
217+
assert.deepEqual(stackFrames.stack[0], { url: 'resource://path/data/content/bundle.js', func: 'render', args: [], line: 5529, column: 16 });
218+
});
219+
212220
});
213221
});

vendor/TraceKit/tracekit.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
'use strict';
22

33
/*
4-
TraceKit - Cross brower stack traces - github.com/occ/TraceKit
4+
TraceKit - Cross brower stack traces
5+
6+
This was originally forked from github.com/occ/TraceKit, but has since been
7+
largely re-written and is now maintained as part of raven-js. Tests for
8+
this are in test/vendor.
9+
510
MIT license
611
*/
712

@@ -381,7 +386,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
381386
if (typeof ex.stack === 'undefined' || !ex.stack) return;
382387

383388
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
384-
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
389+
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
385390
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
386391
lines = ex.stack.split('\n'),
387392
stack = [],

0 commit comments

Comments
 (0)