From 27656e7f527b50a985be653f87c1cfb4dff6e678 Mon Sep 17 00:00:00 2001 From: Ben Vinegar Date: Mon, 21 Mar 2016 15:05:11 -0700 Subject: [PATCH] Handle stacks from internal exceptions sometimes thrown by Firefox --- test/vendor/fixtures/captured-errors.js | 18 ++++++++++++++++++ test/vendor/tracekit-parser.test.js | 10 ++++++++++ vendor/TraceKit/tracekit.js | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/test/vendor/fixtures/captured-errors.js b/test/vendor/fixtures/captured-errors.js index 70bf05c4c786..932b6eaa95f1 100644 --- a/test/vendor/fixtures/captured-errors.js +++ b/test/vendor/fixtures/captured-errors.js @@ -223,6 +223,24 @@ CapturedExceptions.FIREFOX_31 = { columnNumber: 12 }; +// Internal errors sometimes thrown by Firefox +// More here: https://developer.mozilla.org/en-US/docs/Mozilla/Errors +// +// Note that such errors are instanceof "Exception", not "Error" +CapturedExceptions.FIREFOX_44_NS_EXCEPTION = { + message: "", + name: "NS_ERROR_FAILURE", + stack: "[2] tag + "", + fileName: "http://path/to/file.js", + columnNumber: 0, + lineNumber: 703, + result: 2147500037 +}; + CapturedExceptions.SAFARI_6 = { message: "'null' is not an object (evaluating 'x.undef')", stack: "@http://path/to/file.js:48\n" + diff --git a/test/vendor/tracekit-parser.test.js b/test/vendor/tracekit-parser.test.js index 514f9adab7e5..786f9eb135f1 100644 --- a/test/vendor/tracekit-parser.test.js +++ b/test/vendor/tracekit-parser.test.js @@ -108,6 +108,16 @@ describe('TraceKit', function () { expect(stackFrames.stack[2]).toEqual({ url: 'http://path/to/file.js', func: '.plugin/e.fn[c]/<', args: [], line: 1, column: 1, context: null }); }); + it('should parse Firefox 44 ns exceptions', function () { + var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.FIREFOX_44_NS_EXCEPTION); + expect(stackFrames).toBeTruthy(); + expect(stackFrames.stack.length).toBe(4); + expect(stackFrames.stack[0]).toEqual({ url: 'http://path/to/file.js', func: '[2]).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, - gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[).*?)(?::(\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, lines = ex.stack.split('\n'), stack = [],