diff --git a/index.js b/index.js index aabcf75..dd8785f 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ Retrace.prototype.mapFrame = function(f) { Retrace.prototype.register = function(uri, sourceMap) { return this.consumers[uri] = Promise.resolve(sourceMap).then(function(sm) { if (typeof sm == 'string') sm = JSON.parse(sm); - if (!sm) sm = identity; + if (!sm) return identity; return new SourceMapConsumer(sm); }); } diff --git a/test/fixture/map-missing.html b/test/fixture/map-missing.html new file mode 100644 index 0000000..796046c --- /dev/null +++ b/test/fixture/map-missing.html @@ -0,0 +1,10 @@ + + + + map-missing.js + + + + ... + + diff --git a/test/fixture/map-missing.js b/test/fixture/map-missing.js new file mode 100644 index 0000000..8fb5235 --- /dev/null +++ b/test/fixture/map-missing.js @@ -0,0 +1,2 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o'+stack+""});var error=require("./error");setTimeout(function(){error("boo")},1)},{"../../client/xhr":2,"./error":3}]},{},[4]); +//# sourceMappingURL=map-missing.js.map \ No newline at end of file diff --git a/test/index.js b/test/index.js index 8ac8227..87853c1 100644 --- a/test/index.js +++ b/test/index.js @@ -56,6 +56,7 @@ function testBrowser(browserConfig) { ['bundle', 'bundle.min' , 'bundle.inline'].forEach(function(s) { t.test(s, testScript(s)); }); + t.test('map-missing', testMissing('map-missing')) t.end(); }); }); @@ -67,9 +68,26 @@ function testScript(name) { t.error(err, 'stack added to page'); el.text(function(err, text) { t.error(err, 'text retrieved'); - t.match(text, 'error.js:2:0', 'stack cointains location 1'); - t.match(text, 'error.js:6:0', 'stack cointains location 2'); - t.match(text, 'main:8:0', 'stack cointains location 3'); + t.match(text, 'error.js:2:0', 'stack contains location 1'); + t.match(text, 'error.js:6:0', 'stack contains location 2'); + t.match(text, 'main:8:0', 'stack contains location 3'); + browser.sauceJobStatus(t.passing()); + t.end(); + }); + }); + }); + }; +} +function testMissing(name) { + return function(t) { + browser.get('http://localhost:8001/' + name + '.html', function() { + browser.waitForElementByCss('.stack' , 10000, function(err, el) { + t.error(err, 'stack added to page'); + el.text(function(err, text) { + t.error(err, 'text retrieved'); + t.match(text, 'map-missing.js', 'stack contains location 1'); + t.match(text, 'map-missing.js', 'stack contains location 2'); + t.match(text, 'map-missing.js', 'stack contains location 3'); browser.sauceJobStatus(t.passing()); t.end(); });