diff --git a/devtools/client/framework/source-map-url-service.js b/devtools/client/framework/source-map-url-service.js index e8df5a86d0b9..89589b4bd920 100644 --- a/devtools/client/framework/source-map-url-service.js +++ b/devtools/client/framework/source-map-url-service.js @@ -83,7 +83,13 @@ SourceMapURLService.prototype.originalPositionFor = async function (url, line, c await this._sourceMapService.getOriginalURLs(urlInfo); const location = { sourceId: urlInfo.id, line, column, sourceUrl: url }; let resolvedLocation = await this._sourceMapService.getOriginalLocation(location); - return resolvedLocation === location ? null : resolvedLocation; + if (!resolvedLocation || + (resolvedLocation.line === location.line && + resolvedLocation.column === location.column && + resolvedLocation.sourceUrl === location.sourceUrl)) { + return null; + } + return resolvedLocation; }; exports.SourceMapURLService = SourceMapURLService; diff --git a/devtools/client/shared/components/stack-trace.js b/devtools/client/shared/components/stack-trace.js index a29d29121728..8adbd3a777e4 100644 --- a/devtools/client/shared/components/stack-trace.js +++ b/devtools/client/shared/components/stack-trace.js @@ -35,13 +35,16 @@ const StackTrace = createClass({ stacktrace: PropTypes.array.isRequired, onViewSourceInDebugger: PropTypes.func.isRequired, onViewSourceInScratchpad: PropTypes.func, + // Service to enable the source map feature. + sourceMapService: PropTypes.object, }, render() { let { stacktrace, onViewSourceInDebugger, - onViewSourceInScratchpad + onViewSourceInScratchpad, + sourceMapService, } = this.props; let frames = []; @@ -67,7 +70,8 @@ const StackTrace = createClass({ showFullSourceUrl: true, onClick: (/^Scratchpad\/\d+$/.test(source)) ? onViewSourceInScratchpad - : onViewSourceInDebugger + : onViewSourceInDebugger, + sourceMapService, }), "\n"); }); diff --git a/devtools/client/shared/components/test/mochitest/chrome.ini b/devtools/client/shared/components/test/mochitest/chrome.ini index bf4908c36171..89a6d7db2dae 100644 --- a/devtools/client/shared/components/test/mochitest/chrome.ini +++ b/devtools/client/shared/components/test/mochitest/chrome.ini @@ -11,6 +11,7 @@ support-files = [test_searchbox-with-autocomplete.html] [test_sidebar_toggle.html] [test_stack-trace.html] +[test_stack-trace-source-maps.html] [test_tabs_accessibility.html] [test_tabs_menu.html] [test_tree_01.html] diff --git a/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html b/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html new file mode 100644 index 000000000000..8becd71d89cc --- /dev/null +++ b/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html @@ -0,0 +1,105 @@ + + + + + + + StackTrace component test + + + + + + + + + diff --git a/devtools/client/webconsole/console-output.js b/devtools/client/webconsole/console-output.js index a3ce9fe88348..353df6be45de 100644 --- a/devtools/client/webconsole/console-output.js +++ b/devtools/client/webconsole/console-output.js @@ -3556,9 +3556,12 @@ Widgets.Stacktrace.prototype = extend(Widgets.BaseWidget.prototype, { result.className = "stacktrace devtools-monospace"; if (this.stacktrace) { + const target = this.message.output.toolboxTarget; + const toolbox = gDevTools.getToolbox(target); this.output.owner.ReactDOM.render(this.output.owner.StackTraceView({ stacktrace: this.stacktrace, - onViewSourceInDebugger: frame => this.output.openLocationInDebugger(frame) + onViewSourceInDebugger: frame => this.output.openLocationInDebugger(frame), + sourceMapService: toolbox ? toolbox.sourceMapURLService : null, }), result); } diff --git a/devtools/client/webconsole/net/components/net-info-body.js b/devtools/client/webconsole/net/components/net-info-body.js index 0e18082f006f..e9f99f352798 100644 --- a/devtools/client/webconsole/net/components/net-info-body.js +++ b/devtools/client/webconsole/net/components/net-info-body.js @@ -38,7 +38,9 @@ var NetInfoBody = React.createClass({ data: PropTypes.shape({ request: PropTypes.object.isRequired, response: PropTypes.object.isRequired - }) + }), + // Service to enable the source map feature. + sourceMapService: PropTypes.object, }, displayName: "NetInfoBody", @@ -76,7 +78,7 @@ var NetInfoBody = React.createClass({ }, getTabPanels() { - let actions = this.props.actions; + let { actions, sourceMapService } = this.props; let data = this.state.data; let {request} = data; @@ -153,7 +155,8 @@ var NetInfoBody = React.createClass({ title: Locale.$STR("netRequest.callstack")}, StackTraceTab({ data: data, - actions: actions + actions: actions, + sourceMapService: sourceMapService, }) ) ); diff --git a/devtools/client/webconsole/net/components/stacktrace-tab.js b/devtools/client/webconsole/net/components/stacktrace-tab.js index 51eb7689baae..367729e66a7a 100644 --- a/devtools/client/webconsole/net/components/stacktrace-tab.js +++ b/devtools/client/webconsole/net/components/stacktrace-tab.js @@ -13,15 +13,17 @@ const StackTraceTab = createClass({ data: PropTypes.object.isRequired, actions: PropTypes.shape({ onViewSourceInDebugger: PropTypes.func.isRequired - }) + }), + // Service to enable the source map feature. + sourceMapService: PropTypes.object, }, render() { let { stacktrace } = this.props.data.cause; - let { actions } = this.props; + let { actions, sourceMapService } = this.props; let onViewSourceInDebugger = actions.onViewSourceInDebugger.bind(actions); - return StackTrace({ stacktrace, onViewSourceInDebugger }); + return StackTrace({ stacktrace, onViewSourceInDebugger, sourceMapService }); } }); diff --git a/devtools/client/webconsole/net/net-request.js b/devtools/client/webconsole/net/net-request.js index a2275467f7db..15879d01bf04 100644 --- a/devtools/client/webconsole/net/net-request.js +++ b/devtools/client/webconsole/net/net-request.js @@ -163,7 +163,8 @@ NetRequest.prototype = { // As soon as Redux is in place state and actions will come from // separate modules. let body = NetInfoBody({ - actions: this + actions: this, + sourceMapService: this.owner.sourceMapURLService, }); // Render net info body! diff --git a/devtools/client/webconsole/new-console-output/components/console-output.js b/devtools/client/webconsole/new-console-output/components/console-output.js index f5240d8328c6..7cbec18b117a 100644 --- a/devtools/client/webconsole/new-console-output/components/console-output.js +++ b/devtools/client/webconsole/new-console-output/components/console-output.js @@ -30,6 +30,7 @@ const ConsoleOutput = createClass({ serviceContainer: PropTypes.shape({ attachRefToHud: PropTypes.func.isRequired, openContextMenu: PropTypes.func.isRequired, + sourceMapService: PropTypes.object, }), autoscroll: PropTypes.bool.isRequired, dispatch: PropTypes.func.isRequired, diff --git a/devtools/client/webconsole/new-console-output/components/message-types/console-command.js b/devtools/client/webconsole/new-console-output/components/message-types/console-command.js index e70b352a680c..fe3fe2bcc13c 100644 --- a/devtools/client/webconsole/new-console-output/components/message-types/console-command.js +++ b/devtools/client/webconsole/new-console-output/components/message-types/console-command.js @@ -20,6 +20,7 @@ ConsoleCommand.propTypes = { autoscroll: PropTypes.bool.isRequired, indent: PropTypes.number.isRequired, timestampsVisible: PropTypes.bool.isRequired, + serviceContainer: PropTypes.object, }; ConsoleCommand.defaultProps = { @@ -35,6 +36,7 @@ function ConsoleCommand(props) { indent, message, timestampsVisible, + serviceContainer, } = props; const { @@ -44,10 +46,6 @@ function ConsoleCommand(props) { messageText: messageBody, } = message; - const { - serviceContainer, - } = props; - return Message({ source, type, diff --git a/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js b/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js index 09c81458d94a..484e667bcd16 100644 --- a/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js +++ b/devtools/client/webconsole/new-console-output/components/message-types/evaluation-result.js @@ -20,6 +20,7 @@ EvaluationResult.propTypes = { message: PropTypes.object.isRequired, indent: PropTypes.number.isRequired, timestampsVisible: PropTypes.bool.isRequired, + serviceContainer: PropTypes.object, }; EvaluationResult.defaultProps = { diff --git a/devtools/client/webconsole/new-console-output/components/message-types/page-error.js b/devtools/client/webconsole/new-console-output/components/message-types/page-error.js index 91006841330b..39089bdec075 100644 --- a/devtools/client/webconsole/new-console-output/components/message-types/page-error.js +++ b/devtools/client/webconsole/new-console-output/components/message-types/page-error.js @@ -20,6 +20,7 @@ PageError.propTypes = { open: PropTypes.bool, indent: PropTypes.number.isRequired, timestampsVisible: PropTypes.bool.isRequired, + serviceContainer: PropTypes.object, }; PageError.defaultProps = { diff --git a/devtools/client/webconsole/new-console-output/components/message.js b/devtools/client/webconsole/new-console-output/components/message.js index cdbc5fb23b15..a0bb793abcad 100644 --- a/devtools/client/webconsole/new-console-output/components/message.js +++ b/devtools/client/webconsole/new-console-output/components/message.js @@ -148,6 +148,7 @@ const Message = createClass({ stacktrace: stacktrace, onViewSourceInDebugger: serviceContainer.onViewSourceInDebugger, onViewSourceInScratchpad: serviceContainer.onViewSourceInScratchpad, + sourceMapService: serviceContainer.sourceMapService, }) ); }