Bug 1361270 - Search also within net logs; r=nchevobbe

MozReview-Commit-ID: FTs2tJicTXC

--HG--
extra : rebase_source : de14051242a9ed44b763e653d1b9a15b69a8c79a
This commit is contained in:
Jan Odvarko 2017-05-02 17:27:15 +02:00
Родитель f6b441fd4b
Коммит 46d58cb8f8
1 изменённых файлов: 68 добавлений и 28 удалений

Просмотреть файл

@ -113,36 +113,14 @@ function matchSearchFilters(message, filters) {
|| isTextInParameters(text, message.parameters) || isTextInParameters(text, message.parameters)
// Look for a match in location. // Look for a match in location.
|| isTextInFrame(text, message.frame) || isTextInFrame(text, message.frame)
// Look for a match in stacktrace. // Look for a match in net events.
|| ( || isTextInNetEvent(text, message.request)
Array.isArray(message.stacktrace) && // Look for a match in stack-trace.
message.stacktrace.some(frame => isTextInFrame(text, || isTextInStackTrace(text, message.stacktrace)
// isTextInFrame expect the properties of the frame object to be in the same
// order they are rendered in the Frame component.
{
functionName: frame.functionName ||
l10n.getStr("stacktrace.anonymousFunction"),
filename: frame.filename,
lineNumber: frame.lineNumber,
columnNumber: frame.columnNumber
}))
)
// Look for a match in messageText. // Look for a match in messageText.
|| (message.messageText && || isTextInMessageText(text, message.messageText)
message.messageText.toLocaleLowerCase().includes(text.toLocaleLowerCase()))
// Look for a match in parameters. Currently only checks value grips.
|| (message.parameters &&
message.parameters.join("").toLocaleLowerCase()
.includes(text.toLocaleLowerCase()))
// Look for a match in notes. // Look for a match in notes.
|| (Array.isArray(message.notes) && message.notes.some(note => || isTextInNotes(text, message.notes)
// Look for a match in location.
isTextInFrame(text, note.frame)
// Look for a match in messageBody.
|| (note.messageBody &&
note.messageBody.toLocaleLowerCase()
.includes(text.toLocaleLowerCase()))
))
); );
} }
@ -173,6 +151,68 @@ function isTextInParameters(text, parameters) {
); );
} }
/**
* Returns true if given text is included in provided net event grip.
*/
function isTextInNetEvent(text, request) {
if (!request) {
return false;
}
text = text.toLocaleLowerCase();
let method = request.method.toLocaleLowerCase();
let url = request.url.toLocaleLowerCase();
return method.includes(text) || url.includes(text);
}
/**
* Returns true if given text is included in provided stack trace.
*/
function isTextInStackTrace(text, stacktrace) {
if (!Array.isArray(stacktrace)) {
return false;
}
// isTextInFrame expect the properties of the frame object to be in the same
// order they are rendered in the Frame component.
return stacktrace.some(frame => isTextInFrame(text, {
functionName: frame.functionName || l10n.getStr("stacktrace.anonymousFunction"),
filename: frame.filename,
lineNumber: frame.lineNumber,
columnNumber: frame.columnNumber
}));
}
/**
* Returns true if given text is included in `messageText` field.
*/
function isTextInMessageText(text, messageText) {
if (!messageText) {
return false;
}
return messageText.toLocaleLowerCase().includes(text.toLocaleLowerCase());
}
/**
* Returns true if given text is included in notes.
*/
function isTextInNotes(text, notes) {
if (!Array.isArray(notes)) {
return false;
}
return notes.some(note =>
// Look for a match in location.
isTextInFrame(text, note.frame) ||
// Look for a match in messageBody.
(note.messageBody &&
note.messageBody.toLocaleLowerCase()
.includes(text.toLocaleLowerCase()))
);
}
/** /**
* Get a flat array of all the grips and their properties. * Get a flat array of all the grips and their properties.
* *