From c654eb8e270727a90d551221ea38c9969b4ab722 Mon Sep 17 00:00:00 2001 From: Ben Vinegar Date: Wed, 6 Jul 2016 17:13:54 -0700 Subject: [PATCH 1/2] Handle PhantomJS 1.x file:/// urls --- test/vendor/fixtures/captured-errors.js | 7 +++++++ test/vendor/tracekit-parser.test.js | 6 ++++++ vendor/TraceKit/tracekit.js | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/vendor/fixtures/captured-errors.js b/test/vendor/fixtures/captured-errors.js index 7d75669b8fc1..4a6d0b94390c 100644 --- a/test/vendor/fixtures/captured-errors.js +++ b/test/vendor/fixtures/captured-errors.js @@ -333,4 +333,11 @@ CapturedExceptions.CHROME_48_BLOB = { " at n.handle (blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379:7:2863)" }; +CapturedExceptions.PHANTOMJS_1_19 = { + stack: "Error: foo\n" + + " at file:///path/to/file.js:878\n" + + " at foo (http://path/to/file.js:4283)\n" + + " at http://path/to/file.js:4287" +}; + module.exports = CapturedExceptions; diff --git a/test/vendor/tracekit-parser.test.js b/test/vendor/tracekit-parser.test.js index 4c558456d481..3d6da3ff0ee0 100644 --- a/test/vendor/tracekit-parser.test.js +++ b/test/vendor/tracekit-parser.test.js @@ -262,5 +262,11 @@ describe('TraceKit', function () { assert.deepEqual(stackFrames.stack[1], { url: 'http://path/to/file.js', func: 'foo', args: [], line: 52, column: 15 }); assert.deepEqual(stackFrames.stack[2], { url: 'http://path/to/file.js', func: 'bar', args: [], line: 108, column: 168 }); }); + + it('should parse PhantomJS 1.19 error', function () { + var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.PHANTOMJS_1_19); + assert.ok(stackFrames); + assert.deepEqual(stackFrames.stack.length, 3); + }); }); }); diff --git a/vendor/TraceKit/tracekit.js b/vendor/TraceKit/tracekit.js index 81a44507ce36..a3af03a14cea 100644 --- a/vendor/TraceKit/tracekit.js +++ b/vendor/TraceKit/tracekit.js @@ -382,7 +382,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i, - winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, + winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, lines = ex.stack.split('\n'), stack = [], parts, From 564324a25552733bbaccc295dbfa4274563fbc0c Mon Sep 17 00:00:00 2001 From: Ben Vinegar Date: Wed, 6 Jul 2016 18:28:38 -0700 Subject: [PATCH 2/2] Add assertions --- test/vendor/tracekit-parser.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vendor/tracekit-parser.test.js b/test/vendor/tracekit-parser.test.js index 3d6da3ff0ee0..13cde53487e3 100644 --- a/test/vendor/tracekit-parser.test.js +++ b/test/vendor/tracekit-parser.test.js @@ -267,6 +267,9 @@ describe('TraceKit', function () { var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.PHANTOMJS_1_19); assert.ok(stackFrames); assert.deepEqual(stackFrames.stack.length, 3); + assert.deepEqual(stackFrames.stack[0], { url: 'file:///path/to/file.js', func: '?', args: [], line: 878, column: null }); + assert.deepEqual(stackFrames.stack[1], { url: 'http://path/to/file.js', func: 'foo', args: [], line: 4283, column: null }); + assert.deepEqual(stackFrames.stack[2], { url: 'http://path/to/file.js', func: '?', args: [], line: 4287, column: null }); }); }); });