Skip to content

Commit 879ec45

Browse files
authored
Handle PhantomJS 1.x file:/// urls (#642)
1 parent aeac6ce commit 879ec45

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

test/vendor/fixtures/captured-errors.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,11 @@ CapturedExceptions.CHROME_48_BLOB = {
333333
" at n.handle (blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379:7:2863)"
334334
};
335335

336+
CapturedExceptions.PHANTOMJS_1_19 = {
337+
stack: "Error: foo\n" +
338+
" at file:///path/to/file.js:878\n" +
339+
" at foo (http://path/to/file.js:4283)\n" +
340+
" at http://path/to/file.js:4287"
341+
};
342+
336343
module.exports = CapturedExceptions;

test/vendor/tracekit-parser.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,14 @@ describe('TraceKit', function () {
262262
assert.deepEqual(stackFrames.stack[1], { url: 'http://path/to/file.js', func: 'foo', args: [], line: 52, column: 15 });
263263
assert.deepEqual(stackFrames.stack[2], { url: 'http://path/to/file.js', func: 'bar', args: [], line: 108, column: 168 });
264264
});
265+
266+
it('should parse PhantomJS 1.19 error', function () {
267+
var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.PHANTOMJS_1_19);
268+
assert.ok(stackFrames);
269+
assert.deepEqual(stackFrames.stack.length, 3);
270+
assert.deepEqual(stackFrames.stack[0], { url: 'file:///path/to/file.js', func: '?', args: [], line: 878, column: null });
271+
assert.deepEqual(stackFrames.stack[1], { url: 'http://path/to/file.js', func: 'foo', args: [], line: 4283, column: null });
272+
assert.deepEqual(stackFrames.stack[2], { url: 'http://path/to/file.js', func: '?', args: [], line: 4287, column: null });
273+
});
265274
});
266275
});

vendor/TraceKit/tracekit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
382382

383383
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
384384
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
385-
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
385+
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
386386
lines = ex.stack.split('\n'),
387387
stack = [],
388388
parts,

0 commit comments

Comments
 (0)