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
This commit is contained in:
Brian Grinstead 2016-09-28 14:28:58 -07:00
parent 58f88e168b
commit 35d8cd2b13
3 changed files with 11 additions and 9 deletions

View File

@ -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",

View File

@ -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

View File

@ -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(),
}]));
},