Bug 587615 - lastTimestamp reset problems in WebConsole; f=pwalton r=sdwilsh approval2.0=beltzner
authorMihai Sucan <msucan@mozilla.com>
Tue, 23 Nov 2010 13:02:00 -0400
changeset 58082 ad189229497fab1e912594e106bb92438bf83713
parent 58081 9ecae0a45ab8fc799eeb7aeba2f86237d0660a57
child 58083 284b8ed69ee3fd16eb0783375f4d5d927416fa40
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerssdwilsh
bugs587615
milestone2.0b8pre
Bug 587615 - lastTimestamp reset problems in WebConsole; f=pwalton r=sdwilsh approval2.0=beltzner
toolkit/components/console/hudservice/HUDService.jsm
toolkit/components/console/hudservice/tests/browser/Makefile.in
toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_587615_lastTimestamp.js
--- a/toolkit/components/console/hudservice/HUDService.jsm
+++ b/toolkit/components/console/hudservice/HUDService.jsm
@@ -1599,17 +1599,17 @@ HUD_SERVICE.prototype =
     }
 
     var outputNode = aHUD.querySelector(".hud-output-node");
 
     while (outputNode.firstChild) {
       outputNode.removeChild(outputNode.firstChild);
     }
 
-    outputNode.lastTimestamp = 0;
+    aHUD.lastTimestamp = 0;
   },
 
   /**
    * get a unique ID from the sequence generator
    *
    * @returns integer
    */
   sequenceId: function HS_sequencerId()
@@ -4425,17 +4425,21 @@ JSTerm.prototype = {
   clearOutput: function JST_clearOutput()
   {
     let outputNode = this.outputNode;
 
     while (outputNode.firstChild) {
       outputNode.removeChild(outputNode.firstChild);
     }
 
-    outputNode.lastTimestamp = 0;
+    let hudBox = outputNode;
+    while (!hudBox.classList.contains("hud-box")) {
+      hudBox = hudBox.parentNode;
+    }
+    hudBox.lastTimestamp = 0;
   },
 
   /**
    * Updates the size of the input field (command line) to fit its contents.
    *
    * @returns void
    */
   resizeInput: function JST_resizeInput()
--- a/toolkit/components/console/hudservice/tests/browser/Makefile.in
+++ b/toolkit/components/console/hudservice/tests/browser/Makefile.in
@@ -101,16 +101,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_webconsole_bug_601352_scroll.js \
 	browser_webconsole_bug_592442_closing_brackets.js \
 	browser_webconsole_bug_593003_iframe_wrong_hud.js \
 	browser_webconsole_bug_601909_remember_height.js \
 	browser_webconsole_bug_613013_console_api_iframe.js \
 	browser_webconsole_bug_597756_reopen_closed_tab.js \
 	browser_webconsole_bug_600183_charset.js \
 	browser_webconsole_bug_601177_log_levels.js \
+	browser_webconsole_bug_587615_lastTimestamp.js \
 	head.js \
 	$(NULL)
 
 _BROWSER_TEST_PAGES = \
 	test-console.html \
 	test-network.html \
 	test-network-request.html \
 	test-mutation.html \
new file mode 100644
--- /dev/null
+++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_587615_lastTimestamp.js
@@ -0,0 +1,45 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ *
+ * Contributor(s):
+ *  Mihai Șucan <mihai.sucan@gmail.com>
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+const TEST_URI = "data:text/html,test for bug 587615";
+
+function tabLoad(aEvent) {
+  browser.removeEventListener(aEvent.type, arguments.callee, true);
+
+  openConsole();
+
+  let hudId = HUDService.getHudIdByWindow(content);
+  let HUD = HUDService.hudReferences[hudId];
+  let HUDBox = HUD.HUDBox;
+
+  content.wrappedJSObject.console.log("hello world!");
+
+  isnot(HUDBox.lastTimestamp, 0, "display.lastTimestamp is not 0");
+
+  HUDService.clearDisplay(hudId);
+
+  is(HUDBox.lastTimestamp, 0, "display.lastTimestamp is 0");
+
+  content.wrappedJSObject.console.log("hello world 2!");
+
+  isnot(HUDBox.lastTimestamp, 0, "display.lastTimestamp is not 0");
+
+  HUD.jsterm.clearOutput();
+
+  is(HUDBox.lastTimestamp, 0, "display.lastTimestamp is 0");
+
+  finishTest();
+}
+
+function test() {
+  addTab(TEST_URI);
+  browser.addEventListener("load", tabLoad, true);
+}
+