Bug 1579928 - Reflect proper message order in the console for evaluations during replay r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D49229

--HG--
extra : moz-landing-system : lando
This commit is contained in:
jaril 2019-10-15 20:56:27 +00:00
Родитель 58d9498a00
Коммит 23830a0484
1 изменённых файлов: 48 добавлений и 5 удалений

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

@ -70,6 +70,8 @@ const {
processNetworkUpdates,
} = require("devtools/client/netmonitor/src/utils/request-utils");
const maxNumber = 100000;
const MessageState = overrides =>
Object.freeze(
Object.assign(
@ -1475,23 +1477,51 @@ function ensureExecutionPoint(state, newMessage) {
return;
}
// Add a lastExecutionPoint property which will place this message immediately
// after the last visible one when sorting.
// Add a lastExecutionPoint property which will group messages evaluated during
// the same replay pause point. When applicable, it will place the message immediately
// after the last visible message in the group without an execution point when sorting.
let point = { checkpoint: 0, progress: 0 },
messageCount = 1;
if (state.visibleMessages.length) {
if (state.pausedExecutionPoint) {
point = state.pausedExecutionPoint;
const lastMessage = getLastMessageWithPoint(state, point);
if (lastMessage.lastExecutionPoint) {
messageCount = lastMessage.lastExecutionPoint.messageCount + 1;
}
} else if (state.visibleMessages.length) {
const lastId = state.visibleMessages[state.visibleMessages.length - 1];
const lastMessage = state.messagesById.get(lastId);
if (lastMessage.executionPoint) {
// If the message is evaluated while we are not paused, we want
// to make sure that those messages are placed immediately after the execution
// point's message.
point = lastMessage.executionPoint;
messageCount = maxNumber + 1;
} else {
point = lastMessage.lastExecutionPoint.point;
messageCount = lastMessage.lastExecutionPoint.messageCount + 1;
}
}
newMessage.lastExecutionPoint = { point, messageCount };
}
function getLastMessageWithPoint(state, point) {
// Find all of the messageIds with no real execution point and the same progress
// value as the given point.
const filteredMessageId = state.visibleMessages.filter(function(p) {
const currentMessage = state.messagesById.get(p);
if (currentMessage.executionPoint) {
return false;
}
return point.progress === currentMessage.lastExecutionPoint.point.progress;
});
const lastMessageId = filteredMessageId[filteredMessageId.length - 1];
return state.messagesById.get(lastMessageId) || {};
}
function messageExecutionPoint(state, id) {
const message = state.messagesById.get(id);
return message.executionPoint || message.lastExecutionPoint.point;
@ -1538,8 +1568,21 @@ function maybeSortVisibleMessages(
// When messages have the same execution point, they can still be
// distinguished by the number of messages since the last one which did
// have an execution point.
const countA = messageCountSinceLastExecutionPoint(state, a);
const countB = messageCountSinceLastExecutionPoint(state, b);
let countA = messageCountSinceLastExecutionPoint(state, a);
let countB = messageCountSinceLastExecutionPoint(state, b);
// Messages with real execution points will not have a message count.
// We overwrite that with maxNumber so that we can differentiate A) messages
// from evaluations while replaying a paused point and B) messages from evaluations
// when not replaying a paused point.
if (pointA.progress === pointB.progress) {
if (!countA) {
countA = maxNumber;
} else if (!countB) {
countB = maxNumber;
}
}
return countA > countB;
});
}