Bug 1006027 - ConsoleAPI uses timestamps in msecs, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 12 May 2014 18:03:55 +0100
changeset 182717 583b5740128526b024fc405c309d03332702516d
parent 182716 4b87a842bc7f9c1c16c423582c573236b421933f
child 182718 5892d2b327dd756ab18ceefe9db66db8731555ad
push id26768
push userryanvm@gmail.com
push dateMon, 12 May 2014 20:32:58 +0000
treeherdermozilla-central@4b6d63b05a0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1006027
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1006027 - ConsoleAPI uses timestamps in msecs, r=bz
browser/devtools/webconsole/test/browser.ini
browser/devtools/webconsole/test/browser_webconsole_bug_1006027_message_timestamps_incorrect.js
dom/base/Console.cpp
old mode 100644
new mode 100755
--- a/browser/devtools/webconsole/test/browser.ini
+++ b/browser/devtools/webconsole/test/browser.ini
@@ -229,16 +229,17 @@ run-if = os == "win"
 [browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js]
 [browser_webconsole_bug_804845_ctrl_key_nav.js]
 run-if = os == "mac"
 [browser_webconsole_bug_817834_add_edited_input_to_history.js]
 [browser_webconsole_bug_821877_csp_errors.js]
 [browser_webconsole_bug_837351_securityerrors.js]
 [browser_webconsole_bug_846918_hsts_invalid-headers.js]
 [browser_webconsole_bug_915141_toggle_response_logging_with_keyboard.js]
+[browser_webconsole_bug_1006027_message_timestamps_incorrect.js]
 [browser_webconsole_cached_autocomplete.js]
 [browser_webconsole_change_font_size.js]
 [browser_webconsole_chrome.js]
 [browser_webconsole_closure_inspection.js]
 [browser_webconsole_completion.js]
 [browser_webconsole_console_extras.js]
 [browser_webconsole_console_logging_api.js]
 [browser_webconsole_count.js]
new file mode 100755
--- /dev/null
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_1006027_message_timestamps_incorrect.js
@@ -0,0 +1,40 @@
+/* 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/. */
+
+function test() {
+  Task.spawn(runner).then(finishTest);
+
+  function* runner() {
+    const {tab} = yield loadTab("data:text/html;charset=utf8,<title>Test for Bug 1006027");
+
+    const target = TargetFactory.forTab(tab);
+    const hud = yield openConsole(tab);
+
+    hud.jsterm.execute("console.log('bug1006027')");
+
+    yield waitForMessages({
+      webconsole: hud,
+      messages: [{
+        name: "console.log",
+        text: "bug1006027",
+        category: CATEGORY_WEBDEV,
+        severity: SEVERITY_LOG,
+      }],
+    });
+
+    info('hud.outputNode.textContent:\n'+hud.outputNode.textContent);
+    let timestampNodes = hud.outputNode.querySelectorAll('span.timestamp');
+    let aTimestampMilliseconds = Array.prototype.map.call(timestampNodes,
+      function (value) {
+         // We are parsing timestamps as local time, relative to the begin of the epoch.
+         // This is not the correct value of the timestamp, but good enough for comparison.
+         return Date.parse('T'+String.trim(value.textContent));
+      });
+
+    let minTimestamp = Math.min.apply(null, aTimestampMilliseconds);
+    let maxTimestamp = Math.max.apply(null, aTimestampMilliseconds);
+    ok(Math.abs(maxTimestamp - minTimestamp) < 1000, "console.log message timestamp spread < 1000ms confirmed");
+  }
+}
+
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -136,17 +136,17 @@ JSStructuredCloneCallbacks gConsoleCallb
 };
 
 class ConsoleCallData MOZ_FINAL : public LinkedListElement<ConsoleCallData>
 {
 public:
   ConsoleCallData()
     : mMethodName(Console::MethodLog)
     , mPrivate(false)
-    , mTimeStamp(JS_Now())
+    , mTimeStamp(JS_Now() / PR_USEC_PER_MSEC)
     , mMonotonicTimer(0)
   {
     MOZ_COUNT_CTOR(ConsoleCallData);
   }
 
   ~ConsoleCallData()
   {
     MOZ_COUNT_DTOR(ConsoleCallData);