From 35d8cd2b13be419eff9be91168ebb8c349bc1fa0 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Wed, 28 Sep 2016 14:28:58 -0700 Subject: [PATCH] Bug 1306124 - Consistently emit the last rendered message in dom for jsterm.execute and with new-messages event;r=linclark MozReview-Commit-ID: 5100HMmdTr2 --HG-- extra : rebase_source : 5afa6e769bca55d55306b05bd4b65c3c2dc73668 --- devtools/client/webconsole/jsterm.js | 7 +++---- .../new-console-output/new-console-output-wrapper.js | 7 +++++++ devtools/client/webconsole/webconsole.js | 6 +----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/devtools/client/webconsole/jsterm.js b/devtools/client/webconsole/jsterm.js index d0b7f4188545..802a1b56703c 100644 --- a/devtools/client/webconsole/jsterm.js +++ b/devtools/client/webconsole/jsterm.js @@ -377,8 +377,7 @@ JSTerm.prototype = { if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) { this.hud.newConsoleOutput.dispatchMessageAdd(response); - // @TODO figure out what to do about the callback. - callback && callback(); + callback && callback(this.hud.newConsoleOutput.getLastMessage()); return; } let msg = new Messages.JavaScriptEvalOutput(response, @@ -426,7 +425,7 @@ JSTerm.prototype = { let deferred = promise.defer(); let resultCallback; if (this.hud.NEW_CONSOLE_OUTPUT_ENABLED) { - resultCallback = () => deferred.resolve(); + resultCallback = (msg) => deferred.resolve(msg); } else { resultCallback = (msg) => { deferred.resolve(msg); @@ -453,7 +452,7 @@ JSTerm.prototype = { let message = new ConsoleCommand({ messageText: executeString, }); - this.hud.newConsoleOutput.dispatchMessageAdd(message); + this.hud.proxy.dispatchMessageAdd(message); } else { let message = new Messages.Simple(executeString, { category: "input", diff --git a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js index 8f0fa218d589..aeddf6167389 100644 --- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js +++ b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js @@ -17,6 +17,7 @@ const FilterBar = React.createFactory(require("devtools/client/webconsole/new-co const store = configureStore(); function NewConsoleOutputWrapper(parentNode, jsterm, toolbox, owner) { + this.parentNode = parentNode; this.parentNode = parentNode; this.jsterm = jsterm; this.toolbox = toolbox; @@ -68,6 +69,12 @@ NewConsoleOutputWrapper.prototype = { dispatchMessagesClear: () => { store.dispatch(actions.messagesClear()); }, + getLastMessage: function() { + // Return the last message in the DOM as the message that was just dispatched. This may not + // always be correct in the case of filtered messages, but it's close enough for our tests. + let messageNodes = this.parentNode.querySelectorAll(".message"); + return messageNodes[messageNodes.length - 1] + }, }; // Exports from this module diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js index 1f5ed9f347ae..9964ca12f5fa 100644 --- a/devtools/client/webconsole/webconsole.js +++ b/devtools/client/webconsole/webconsole.js @@ -3266,13 +3266,9 @@ WebConsoleConnectionProxy.prototype = { */ dispatchMessageAdd: function(packet) { this.webConsoleFrame.newConsoleOutput.dispatchMessageAdd(packet); - - // Return the last message in the DOM as the message that was just dispatched. This may not - // always be true in the case of filtered messages, but it's close enough for our tests. - let messageNodes = this.webConsoleFrame.experimentalOutputNode.querySelectorAll(".message"); this.webConsoleFrame.emit("new-messages", new Set([{ response: packet, - node: messageNodes[messageNodes.length - 1], + node: this.webConsoleFrame.newConsoleOutput.getLastMessage(), }])); },