Bug 1430770 - Fix batchMessageAdd for test-perf.html; r=bgrins.
MozReview-Commit-ID: Doyj3Dznvnl
--- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
+++ b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
@@ -216,41 +216,45 @@ NewConsoleOutputWrapper.prototype = {
sideBar
));
this.body = ReactDOM.render(provider, this.parentNode);
this.jsterm.focus();
});
},
- dispatchMessageAdd: function (message, waitForResponse) {
+ dispatchMessageAdd: function (packet, waitForResponse) {
// Wait for the message to render to resolve with the DOM node.
// This is just for backwards compatibility with old tests, and should
// be removed once it's not needed anymore.
// Can only wait for response if the action contains a valid message.
let promise;
// Also, do not expect any update while the panel is in background.
if (waitForResponse && document.visibilityState === "visible") {
+ const timeStampToMatch = packet.message
+ ? packet.message.timeStamp
+ : packet.timestamp;
+
promise = new Promise(resolve => {
let jsterm = this.jsterm;
jsterm.hud.on("new-messages", function onThisMessage(e, messages) {
for (let m of messages) {
- if (m.timeStamp === message.timestamp) {
+ if (m.timeStamp === timeStampToMatch) {
resolve(m.node);
jsterm.hud.off("new-messages", onThisMessage);
return;
}
}
});
});
} else {
promise = Promise.resolve();
}
- this.batchedMessagesAdd(message);
+ this.batchedMessagesAdd(packet);
return promise;
},
dispatchMessagesAdd: function (messages) {
store.dispatch(actions.messagesAdd(messages));
},
dispatchMessagesClear: function () {