Bug 1405243 - Migrate browser_webconsole_bug_1006027_message_timestamps_incorrect.js to a server test; r=bgrins.
The test was testing that the 3 messages we display when
evaluating a console.log (text of the input, evaluation result,
consoleAPI message) all had a timestamp in a 2000ms range.
This wasn't really what it should have been about, since the
original bugfix (for
Bug 1405243), was only in Console.cpp (and
the fix is still up there).
So here we only assert that the timestamp in the ConsoleAPI packet
is between the moment the log was requested and the time we receive
the packet.
MozReview-Commit-ID: HikGCJGHXMy
--- a/devtools/shared/webconsole/test/chrome.ini
+++ b/devtools/shared/webconsole/test/chrome.ini
@@ -18,16 +18,17 @@ support-files =
[test_commands_registration.html]
[test_consoleapi.html]
[test_consoleapi_innerID.html]
[test_console_assert.html]
[test_console_group_styling.html]
[test_console_serviceworker.html]
[test_console_serviceworker_cached.html]
[test_console_styling.html]
+[test_console_timestamp.html]
[test_console_worker.html]
[test_file_uri.html]
[test_reflow.html]
[test_jsterm.html]
[test_jsterm_autocomplete.html]
[test_jsterm_cd_iframe.html]
[test_jsterm_last_result.html]
[test_jsterm_queryselector.html]
new file mode 100644
--- /dev/null
+++ b/devtools/shared/webconsole/test/test_console_timestamp.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test for console.group styling with %c</title>
+ <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="common.js"></script>
+ <!-- Any copyright is dedicated to the Public Domain.
+ - http://creativecommons.org/publicdomain/zero/1.0/ -->
+ <script>
+"use strict";
+
+const TEST_URL = "data:text/html,<html>Test ConsoleAPI timestamp correctness";
+
+window.onload = async function () {
+ SimpleTest.waitForExplicitFinish();
+ let state;
+ try {
+ const onAttachConsole = new Promise(resolve => attachConsole(
+ ["ConsoleAPI"],
+ (consoleState, response) => resolve(consoleState)
+ ));
+ state = await onAttachConsole;
+ const debuggerClient = state.dbgClient;
+
+ info("Testing console.log packet timestamp correctness");
+ const clientLogTimestamp = Date.now();
+ const packet = await consoleAPICall(debuggerClient,
+ () => top.console.log("test"));
+ const packetReceivedTimestamp = Date.now();
+
+ const {timeStamp} = packet.message;
+ ok(clientLogTimestamp <= timeStamp && timeStamp <= packetReceivedTimestamp,
+ "console.log message timestamp is between the expected time range " +
+ `(${clientLogTimestamp} <= ${timeStamp} <= ${packetReceivedTimestamp})`
+ );
+ } catch (e) {
+ ok(false, `Error thrown: ${e.message}`);
+ }
+
+ await closeDebugger(state);
+ SimpleTest.finish();
+};
+
+
+function consoleAPICall(debuggerClient, consoleCall) {
+ const onConsoleAPICall = debuggerClient.addOneTimeListener("consoleAPICall");
+ consoleCall();
+ return onConsoleAPICall;
+}
+
+ </script>
+</head>
+<body>
+ <p id="display"></p>
+ <div id="content" style="display: none">
+ </div>
+ <pre id="test">
+ </pre>
+</body>
+</html>
\ No newline at end of file