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, frame,
timeStamp, timeStamp,
parameters, parameters,
notes,
} = message; } = message;
let messageBody; let messageBody;
@ -61,6 +62,7 @@ function EvaluationResult(props) {
frame, frame,
timeStamp, timeStamp,
parameters, parameters,
notes,
}; };
return Message(childProps); return Message(childProps);
} }

View File

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

View File

@ -56,6 +56,10 @@ const Message = createClass({
openLink: PropTypes.func.isRequired, openLink: PropTypes.func.isRequired,
sourceMapService: PropTypes.any, sourceMapService: PropTypes.any,
}), }),
notes: PropTypes.arrayOf(PropTypes.shape({
messageBody: PropTypes.string.isRequired,
frame: PropTypes.any,
})),
}, },
getDefaultProps: function () { getDefaultProps: function () {
@ -112,6 +116,7 @@ const Message = createClass({
dispatch, dispatch,
exceptionDocURL, exceptionDocURL,
timeStamp = Date.now(), timeStamp = Date.now(),
notes,
} = this.props; } = this.props;
topLevelClasses.push("message", source, type, level); 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; const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null;
let onFrameClick; let onFrameClick;
@ -212,7 +240,8 @@ const Message = createClass({
// Add a newline for formatting when copying to the clipboard. // Add a newline for formatting when copying to the clipboard.
"\n", "\n",
// If an attachment is displayed, the final newline is handled by the attachment. // 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 !== null
&& message.parameters.join("").toLocaleLowerCase() && message.parameters.join("").toLocaleLowerCase()
.includes(text.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, groupId: null,
exceptionDocURL: null, exceptionDocURL: null,
userProvidedStyles: null, userProvidedStyles: null,
notes: null,
}); });
exports.NetworkEventMessage = Immutable.Record({ exports.NetworkEventMessage = Immutable.Record({

View File

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

View File

@ -899,7 +899,8 @@ WebConsoleActor.prototype =
let evalResult = evalInfo.result; let evalResult = evalInfo.result;
let helperResult = evalInfo.helperResult; 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 (evalResult) {
if ("return" in evalResult) { if ("return" in evalResult) {
result = evalResult.return; result = evalResult.return;
@ -954,6 +955,23 @@ WebConsoleActor.prototype =
}; };
} }
} catch (ex) {} } 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, exceptionDocURL: errorDocURL,
frame, frame,
helperResult: helperResult, helperResult: helperResult,
notes: errorNotes,
}; };
}, },
@ -1511,6 +1530,23 @@ WebConsoleActor.prototype =
lineText = lineText.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); 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 { return {
errorMessage: this._createStringGrip(aPageError.errorMessage), errorMessage: this._createStringGrip(aPageError.errorMessage),
errorMessageName: aPageError.errorMessageName, errorMessageName: aPageError.errorMessageName,
@ -1527,7 +1563,8 @@ WebConsoleActor.prototype =
strict: !!(aPageError.flags & aPageError.strictFlag), strict: !!(aPageError.flags & aPageError.strictFlag),
info: !!(aPageError.flags & aPageError.infoFlag), info: !!(aPageError.flags & aPageError.infoFlag),
private: aPageError.isFromPrivateWindow, private: aPageError.isFromPrivateWindow,
stacktrace: stack stacktrace: stack,
notes: notesArray,
}; };
}, },