Bug 1283712 - Part 11.1: Show notes in devtools console. r=nchevobbe

This commit is contained in:
Tooru Fujisawa 2017-02-15 23:53:07 +09:00
parent f4e61b592f
commit 917ac773a0
7 changed files with 87 additions and 4 deletions

View File

@ -36,6 +36,7 @@ function EvaluationResult(props) {
frame,
timeStamp,
parameters,
notes,
} = message;
let messageBody;
@ -61,6 +62,7 @@ function EvaluationResult(props) {
frame,
timeStamp,
parameters,
notes,
};
return Message(childProps);
}

View File

@ -45,6 +45,7 @@ function PageError(props) {
frame,
exceptionDocURL,
timeStamp,
notes,
} = message;
const childProps = {
@ -64,6 +65,7 @@ function PageError(props) {
serviceContainer,
exceptionDocURL,
timeStamp,
notes,
};
return Message(childProps);
}

View File

@ -56,6 +56,10 @@ const Message = createClass({
openLink: PropTypes.func.isRequired,
sourceMapService: PropTypes.any,
}),
notes: PropTypes.arrayOf(PropTypes.shape({
messageBody: PropTypes.string.isRequired,
frame: PropTypes.any,
})),
},
getDefaultProps: function () {
@ -112,6 +116,7 @@ const Message = createClass({
dispatch,
exceptionDocURL,
timeStamp = Date.now(),
notes,
} = this.props;
topLevelClasses.push("message", source, type, level);
@ -154,6 +159,29 @@ const Message = createClass({
});
}
let notesNodes;
if (notes) {
notes.map(note => dom.span(
{ className: "message-flex-body error-note" },
dom.span({ className: "message-body devtools-monospace" },
"note: " + note.messageBody
),
dom.span({ className: "message-location devtools-monospace" },
note.frame ? FrameView({
frame: note.frame,
onClick: serviceContainer
? serviceContainer.onViewSourceInDebugger
: undefined,
showEmptyPathAsHost: true,
sourceMapService: serviceContainer
? serviceContainer.sourceMapService
: undefined
}) : null
)));
} else {
notesNodes = [];
}
const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null;
let onFrameClick;
@ -212,7 +240,8 @@ const Message = createClass({
// Add a newline for formatting when copying to the clipboard.
"\n",
// If an attachment is displayed, the final newline is handled by the attachment.
attachment
attachment,
...notesNodes
)
);
}

View File

@ -134,6 +134,15 @@ function matchSearchFilters(message, filters) {
|| (message.parameters !== null
&& message.parameters.join("").toLocaleLowerCase()
.includes(text.toLocaleLowerCase()))
// Look for a match in notes.
|| (Array.isArray(message.notes) && message.notes.some(note =>
// Look for a match in location.
isTextInFrame(text, note.frame)
// Look for a match in messageBody.
|| (note.messageBody !== null
&& note.messageBody.toLocaleLowerCase()
.includes(text.toLocaleLowerCase()))
))
);
}

View File

@ -39,6 +39,7 @@ exports.ConsoleMessage = Immutable.Record({
groupId: null,
exceptionDocURL: null,
userProvidedStyles: null,
notes: null,
});
exports.NetworkEventMessage = Immutable.Record({

View File

@ -170,7 +170,8 @@ function transformPacket(packet) {
stacktrace: pageError.stacktrace ? pageError.stacktrace : null,
frame,
exceptionDocURL: pageError.exceptionDocURL,
timeStamp: pageError.timeStamp
timeStamp: pageError.timeStamp,
notes: pageError.notes,
});
}
@ -195,6 +196,7 @@ function transformPacket(packet) {
frame,
result: parameters,
timestamp: timeStamp,
notes,
} = packet;
const level = messageText ? MESSAGE_LEVEL.ERROR : MESSAGE_LEVEL.LOG;
@ -207,6 +209,7 @@ function transformPacket(packet) {
exceptionDocURL,
frame,
timeStamp,
notes,
});
}
}

View File

@ -899,7 +899,8 @@ WebConsoleActor.prototype =
let evalResult = evalInfo.result;
let helperResult = evalInfo.helperResult;
let result, errorDocURL, errorMessage, errorGrip = null, frame = null;
let result, errorDocURL, errorMessage, errorNotes = null, errorGrip = null,
frame = null;
if (evalResult) {
if ("return" in evalResult) {
result = evalResult.return;
@ -954,6 +955,23 @@ WebConsoleActor.prototype =
};
}
} catch (ex) {}
try {
let notes = error.errorNotes;
if (notes && notes.length) {
errorNotes = [];
for (let note of notes) {
errorNotes.push({
messageBody: this._createStringGrip(note.message),
frame: {
source: note.fileName,
line: note.lineNumber,
column: note.columnNumber,
}
});
}
}
} catch (ex) {}
}
}
@ -978,6 +996,7 @@ WebConsoleActor.prototype =
exceptionDocURL: errorDocURL,
frame,
helperResult: helperResult,
notes: errorNotes,
};
},
@ -1511,6 +1530,23 @@ WebConsoleActor.prototype =
lineText = lineText.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
}
let notesArray = null;
let notes = aPageError.notes;
if (notes && notes.length) {
notesArray = [];
for (let i = 0, len = notes.length; i < len; i++) {
let note = notes.queryElementAt(i, Ci.nsIScriptErrorNote);
notesArray.push({
messageBody: this._createStringGrip(note.errorMessage),
frame: {
source: note.sourceName,
line: note.lineNumber,
column: note.columnNumber,
}
});
}
}
return {
errorMessage: this._createStringGrip(aPageError.errorMessage),
errorMessageName: aPageError.errorMessageName,
@ -1527,7 +1563,8 @@ WebConsoleActor.prototype =
strict: !!(aPageError.flags & aPageError.strictFlag),
info: !!(aPageError.flags & aPageError.infoFlag),
private: aPageError.isFromPrivateWindow,
stacktrace: stack
stacktrace: stack,
notes: notesArray,
};
},