diff --git a/devtools/client/shared/components/frame.js b/devtools/client/shared/components/frame.js index f80014004f2f..5abe5f057976 100644 --- a/devtools/client/shared/components/frame.js +++ b/devtools/client/shared/components/frame.js @@ -147,14 +147,8 @@ module.exports = createClass({ let tooltip = long; - // If the source is linkable and line > 0 - const shouldDisplayLine = isLinkable && line; - - // Exclude all falsy values, including `0`, as even - // a number 0 for line doesn't make sense, and should not be displayed. - // If source isn't linkable, don't attempt to append line and column - // info, as this probably doesn't make sense. - if (shouldDisplayLine) { + // Exclude all falsy values, including `0`, as line numbers start with 1. + if (line) { tooltip += `:${line}`; // Intentionally exclude 0 if (column) { @@ -193,8 +187,8 @@ module.exports = createClass({ className: "frame-link-filename", }, displaySource)); - // If source is linkable, and we have a line number > 0 - if (shouldDisplayLine) { + // If we have a line number > 0. + if (line) { let lineInfo = `:${line}`; // Add `data-line` attribute for testing attributes["data-line"] = line; 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 641254500d56..992dc62cfd9b 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 @@ -33,6 +33,7 @@ function EvaluationResult(props) { level, id: messageId, exceptionDocURL, + frame, } = message; let messageBody; @@ -55,6 +56,7 @@ function EvaluationResult(props) { scrollToMessage: props.autoscroll, serviceContainer, exceptionDocURL, + frame, }; return Message(childProps); } diff --git a/devtools/client/webconsole/new-console-output/components/message.js b/devtools/client/webconsole/new-console-output/components/message.js index 752b0e91e8d8..f36bff7e4a26 100644 --- a/devtools/client/webconsole/new-console-output/components/message.js +++ b/devtools/client/webconsole/new-console-output/components/message.js @@ -130,13 +130,12 @@ const Message = createClass({ const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null; // Configure the location. - const shouldRenderFrame = frame && frame.source !== "debugger eval code"; const location = dom.span({ className: "message-location devtools-monospace" }, - shouldRenderFrame ? FrameView({ + frame ? FrameView({ frame, - onClick: serviceContainer.onViewSourceInDebugger, + onClick: serviceContainer ? serviceContainer.onViewSourceInDebugger : undefined, showEmptyPathAsHost: true, - sourceMapService: serviceContainer.sourceMapService + sourceMapService: serviceContainer ? serviceContainer.sourceMapService : undefined }) : null ); diff --git a/devtools/client/webconsole/new-console-output/utils/messages.js b/devtools/client/webconsole/new-console-output/utils/messages.js index aacd5eb527ad..f91209e9d2cf 100644 --- a/devtools/client/webconsole/new-console-output/utils/messages.js +++ b/devtools/client/webconsole/new-console-output/utils/messages.js @@ -184,6 +184,7 @@ function transformPacket(packet) { let { exceptionMessage: messageText, exceptionDocURL, + frame, result: parameters } = packet; @@ -195,6 +196,7 @@ function transformPacket(packet) { messageText, parameters, exceptionDocURL, + frame, }); } } diff --git a/devtools/server/actors/webconsole.js b/devtools/server/actors/webconsole.js index 7f7c3f567839..9712ff32d831 100644 --- a/devtools/server/actors/webconsole.js +++ b/devtools/server/actors/webconsole.js @@ -888,7 +888,7 @@ WebConsoleActor.prototype = let evalResult = evalInfo.result; let helperResult = evalInfo.helperResult; - let result, errorDocURL, errorMessage, errorGrip = null; + let result, errorDocURL, errorMessage, errorGrip = null, frame = null; if (evalResult) { if ("return" in evalResult) { result = evalResult.return; @@ -929,6 +929,20 @@ WebConsoleActor.prototype = try { errorDocURL = ErrorDocs.GetURL(error); } catch (ex) {} + + try { + let line = error.errorLineNumber; + let column = error.errorColumnNumber; + + if (typeof line === "number" && typeof column === "number") { + // Set frame only if we have line/column numbers. + frame = { + source: "debugger eval code", + line, + column + }; + } + } catch (ex) {} } } @@ -951,6 +965,7 @@ WebConsoleActor.prototype = exception: errorGrip, exceptionMessage: this._createStringGrip(errorMessage), exceptionDocURL: errorDocURL, + frame, helperResult: helperResult, }; }, @@ -1203,6 +1218,8 @@ WebConsoleActor.prototype = * in the Inspector (or null, if there is no selection). This is used * for helper functions that make reference to the currently selected * node, like $0. + * - url: the url to evaluate the script as. Defaults to + * "debugger eval code". * @return object * An object that holds the following properties: * - dbg: the debugger where the string was evaluated. @@ -1212,8 +1229,6 @@ WebConsoleActor.prototype = * - result: the result of the evaluation. * - helperResult: any result coming from a Web Console commands * function. - * - url: the url to evaluate the script as. Defaults to - * "debugger eval code". */ evalWithDebugger: function WCA_evalWithDebugger(aString, aOptions = {}) {