Bug 1044365 - Do not force webconsole evaluation result to show up immediately after the input;r=vporof draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 15 Dec 2015 18:34:04 -0800
changeset 315668 447f780cb9655d5d893020a9068f879b39d9793a
parent 315667 93d733169c2151b471eab2a8c24a1ecd67487457
child 512069 339595ce5041400f1a2fcb827c8db51d770db5e2
push id8445
push userbgrinstead@mozilla.com
push dateWed, 16 Dec 2015 02:36:36 +0000
reviewersvporof
bugs1044365
milestone46.0a1
Bug 1044365 - Do not force webconsole evaluation result to show up immediately after the input;r=vporof
devtools/client/webconsole/console-output.js
devtools/client/webconsole/test/browser_webconsole_output_order.js
devtools/client/webconsole/webconsole.js
--- a/devtools/client/webconsole/console-output.js
+++ b/devtools/client/webconsole/console-output.js
@@ -774,17 +774,16 @@ Messages.Simple.prototype = Heritage.ext
    * The raw message displayed by this Message object. This can be a function,
    * DOM node or a string.
    *
    * @private
    * @type mixed
    */
   _message: null,
 
-  _afterMessage: null,
   _objectActors: null,
   _groupDepthCompat: 0,
 
   /**
    * Message timestamp.
    *
    * @type number
    *       Milliseconds elapsed since 1 January 1970 00:00:00 UTC.
@@ -938,21 +937,16 @@ Messages.Simple.prototype = Heritage.ext
     this.element.appendChild(this.document.createTextNode("\n"));
 
     this.element.clipboardText = this.element.textContent;
 
     if (this.private) {
       this.element.setAttribute("private", true);
     }
 
-    if (this._afterMessage) {
-      this.element._outputAfterNode = this._afterMessage.element;
-      this._afterMessage = null;
-    }
-
     // TODO: handle object releasing in a more elegant way once all console
     // messages use the new API - bug 778766.
     this.element._objectActors = this._objectActors;
     this._objectActors = null;
 
     return this;
   },
 
--- a/devtools/client/webconsole/test/browser_webconsole_output_order.js
+++ b/devtools/client/webconsole/test/browser_webconsole_output_order.js
@@ -1,47 +1,47 @@
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-// Tests that any output created from calls to the console API comes after the
+// Tests that any output created from calls to the console API comes before the
 // echoed JavaScript.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/test-console.html";
 
 var test = asyncTest(function*() {
   yield loadTab(TEST_URI);
   let hud = yield openConsole();
 
   let jsterm = hud.jsterm;
 
   jsterm.clearOutput();
   jsterm.execute("console.log('foo', 'bar');");
 
-  let [functionCall, result, consoleMessage] = yield waitForMessages({
+  let [functionCall, consoleMessage, result] = yield waitForMessages({
     webconsole: hud,
     messages: [{
       text: "console.log('foo', 'bar');",
       category: CATEGORY_INPUT,
     },
     {
-      text: "undefined",
-      category: CATEGORY_OUTPUT,
-    },
-    {
       text: "foo bar",
       category: CATEGORY_WEBDEV,
       severity: SEVERITY_LOG,
-    }],
+    },
+    {
+      text: "undefined",
+      category: CATEGORY_OUTPUT,
+    }]
   });
 
   let fncallNode = [...functionCall.matched][0];
+  let consoleMessageNode = [...consoleMessage.matched][0];
   let resultNode = [...result.matched][0];
-  let consoleMessageNode = [...consoleMessage.matched][0];
-  is(fncallNode.nextElementSibling, resultNode,
-     "console.log() is followed by undefined");
-  is(resultNode.nextElementSibling, consoleMessageNode,
-     "undefined is followed by 'foo' 'bar'");
+  is(fncallNode.nextElementSibling, consoleMessageNode,
+     "console.log() is followed by 'foo' 'bar'");
+  is(consoleMessageNode.nextElementSibling, resultNode,
+     "'foo' 'bar' is followed by undefined");
 });
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -2233,29 +2233,23 @@ WebConsoleFrame.prototype = {
 
     let node = typeof methodOrNode == "function" ?
                methodOrNode.apply(this, args || []) :
                methodOrNode;
     if (!node) {
       return null;
     }
 
-    let afterNode = node._outputAfterNode;
-    if (afterNode) {
-      delete node._outputAfterNode;
-    }
-
     let isFiltered = this.filterMessageNode(node);
 
     let isRepeated = this._filterRepeatedMessage(node);
 
     let visible = !isRepeated && !isFiltered;
     if (!isRepeated) {
-      this.outputNode.insertBefore(node,
-                                   afterNode ? afterNode.nextSibling : null);
+      this.outputNode.appendChild(node);
       this._pruneCategoriesQueue[node.category] = true;
 
       let nodeID = node.getAttribute("id");
       Services.obs.notifyObservers(aHudIdSupportsString,
                                    "web-console-message-created", nodeID);
 
     }
 
@@ -3236,27 +3230,24 @@ JSTerm.prototype = {
       inputNode.focus();
     }
   },
 
   /**
    * The JavaScript evaluation response handler.
    *
    * @private
-   * @param object [aAfterMessage]
-   *        Optional message after which the evaluation result will be
-   *        inserted.
    * @param function [aCallback]
    *        Optional function to invoke when the evaluation result is added to
    *        the output.
    * @param object aResponse
    *        The message received from the server.
    */
   _executeResultCallback:
-  function JST__executeResultCallback(aAfterMessage, aCallback, aResponse)
+  function JST__executeResultCallback(aCallback, aResponse)
   {
     if (!this.hud) {
       return;
     }
     if (aResponse.error) {
       Cu.reportError("Evaluation error " + aResponse.error + ": " +
                      aResponse.message);
       return;
@@ -3270,22 +3261,16 @@ JSTerm.prototype = {
       switch (helperResult.type) {
         case "clearOutput":
           this.clearOutput();
           break;
         case "clearHistory":
           this.clearHistory();
           break;
         case "inspectObject":
-          if (aAfterMessage) {
-            if (!aAfterMessage._objectActors) {
-              aAfterMessage._objectActors = new Set();
-            }
-            aAfterMessage._objectActors.add(helperResult.object.actor);
-          }
           this.openVariablesView({
             label: VariablesView.getString(helperResult.object, { concise: true }),
             objectActor: helperResult.object,
           });
           break;
         case "error":
           try {
             errorMessage = l10n.getStr(helperResult.message);
@@ -3323,17 +3308,16 @@ JSTerm.prototype = {
           this.hud._flushCallback = oldFlushCallback;
           return true;
         }
 
         return false;
       };
     }
 
-    msg._afterMessage = aAfterMessage;
     msg._objectActors = new Set();
 
     if (WebConsoleUtils.isActorGrip(aResponse.exception)) {
       msg._objectActors.add(aResponse.exception.actor);
     }
 
     if (WebConsoleUtils.isActorGrip(result)) {
       msg._objectActors.add(result.actor);
@@ -3374,17 +3358,17 @@ JSTerm.prototype = {
       selectedNodeActor = inspectorSelection.nodeFront.actorID;
     }
 
     let message = new Messages.Simple(aExecuteString, {
       category: "input",
       severity: "log",
     });
     this.hud.output.addMessage(message);
-    let onResult = this._executeResultCallback.bind(this, message, callback);
+    let onResult = this._executeResultCallback.bind(this, callback);
 
     let options = {
       frame: this.SELECTED_FRAME,
       selectedNodeActor: selectedNodeActor,
     };
 
     this.requestEvaluation(aExecuteString, options).then(onResult, onResult);