Bug 1309483 - fix dispatchMessageAdd failing for BATCH_ACTIONS;r=nchevobbe
MozReview-Commit-ID: KBwxZwhiSK8
--- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
+++ b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
@@ -67,44 +67,50 @@ NewConsoleOutputWrapper.prototype = {
React.DOM.div(
{className: "webconsole-output-wrapper"},
filterBar,
childComponent
));
this.body = ReactDOM.render(provider, this.parentNode);
},
- dispatchMessageAdd: function(message, waitForResponse) {
- let action = actions.messageAdd(message);
- let messageId = action.message.get("id");
- batchedMessageAdd(action);
+
+ dispatchMessageAdd: function (message, waitForResponse) {
+ let action = actions.messageAdd(message);
+ batchedMessageAdd(action);
- // 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.
- if (waitForResponse) {
- return new Promise(resolve => {
- let jsterm = this.jsterm;
- jsterm.hud.on("new-messages", function onThisMessage(e, messages) {
- for (let m of messages) {
- if (m.messageId == messageId) {
- resolve(m.node);
- jsterm.hud.off("new-messages", onThisMessage);
- return;
- }
+ // 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.
+ if (waitForResponse && action.message) {
+ let messageId = action.message.get("id");
+ return new Promise(resolve => {
+ let jsterm = this.jsterm;
+ jsterm.hud.on("new-messages", function onThisMessage(e, messages) {
+ for (let m of messages) {
+ if (m.messageId == messageId) {
+ resolve(m.node);
+ jsterm.hud.off("new-messages", onThisMessage);
+ return;
}
- });
+ }
});
- }
+ });
+ }
+
+ return Promise.resolve();
},
- dispatchMessagesAdd: function(messages) {
+
+ dispatchMessagesAdd: function (messages) {
const batchedActions = messages.map(message => actions.messageAdd(message));
store.dispatch(actions.batchActions(batchedActions));
},
- dispatchMessagesClear: function() {
+
+ dispatchMessagesClear: function () {
store.dispatch(actions.messagesClear());
},
};
function batchedMessageAdd(action) {
queuedActions.push(action);
if (!throttledDispatchTimeout) {
throttledDispatchTimeout = setTimeout(() => {