diff --git a/devtools/server/actors/script.js b/devtools/server/actors/script.js index 9fa09912fbbd..650684a6f2b2 100644 --- a/devtools/server/actors/script.js +++ b/devtools/server/actors/script.js @@ -1260,7 +1260,6 @@ ThreadActor.prototype = { // Return request.count frames, or all remaining // frames if count is not defined. - let frames = []; let promises = []; for (; frame && (!count || i < (start + count)); i++, frame=frame.older) { let form = this._createFrameActor(frame).form(); @@ -1271,22 +1270,25 @@ ThreadActor.prototype = { form.where.line, form.where.column )).then((originalLocation) => { - if (originalLocation.originalSourceActor) { - let sourceForm = originalLocation.originalSourceActor.form(); - form.where = { - source: sourceForm, - line: originalLocation.originalLine, - column: originalLocation.originalColumn - }; - form.source = sourceForm; - frames.push(form); + if (!originalLocation.originalSourceActor) { + return null; } + + let sourceForm = originalLocation.originalSourceActor.form(); + form.where = { + source: sourceForm, + line: originalLocation.originalLine, + column: originalLocation.originalColumn + }; + form.source = sourceForm; + return form; }); promises.push(promise); } - return all(promises).then(function () { - return { frames: frames }; + return all(promises).then(function (frames) { + // Filter null values because sourcemapping may have failed. + return { frames: frames.filter(x => !!x) }; }); }, diff --git a/devtools/server/tests/unit/test_sourcemaps-17.js b/devtools/server/tests/unit/test_sourcemaps-17.js index d94bd38b5205..6fbc3df605c6 100644 --- a/devtools/server/tests/unit/test_sourcemaps-17.js +++ b/devtools/server/tests/unit/test_sourcemaps-17.js @@ -27,11 +27,13 @@ function run_test() { function test_source_map() { // Set up debuggee code. - const a = new SourceNode(1, 1, "foo.js", "function a() { b(); }"); + const a = new SourceNode(1, 1, "a.js", "function a() { b(); }"); const b = new SourceNode(null, null, null, "function b() { c(); }"); - const c = new SourceNode(2, 1, "foo.js", "function c() { debugger; }"); - const { map, code } = (new SourceNode(null, null, null, [a,b,c])).toStringWithSourceMap({ - file: "bar.js", + const c = new SourceNode(1, 1, "c.js", "function c() { d(); }"); + const d = new SourceNode(null, null, null, "function d() { e(); }"); + const e = new SourceNode(1, 1, "e.js", "function e() { debugger; }"); + const { map, code } = (new SourceNode(null, null, null, [a,b,c,d,e])).toStringWithSourceMap({ + file: "root.js", sourceRoot: "root", }); Components.utils.evalInSandbox( @@ -43,8 +45,15 @@ function test_source_map() { ); gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.fillFrames(50, function(res) { - do_check_true(!res.error, "Should not get an error: " + res.error); + gThreadClient.getFrames(0, 50, function({ error, frames }) { + do_check_true(!error); + do_check_eq(frames.length, 4); + // b.js should be skipped + do_check_eq(frames[0].where.source.url, "http://example.com/www/root/e.js"); + do_check_eq(frames[1].where.source.url, "http://example.com/www/root/c.js"); + do_check_eq(frames[2].where.source.url, "http://example.com/www/root/a.js"); + do_check_eq(frames[3].where.source.url, null); + finishClient(gClient); }) });