3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
8 // It is essential that we calculate timezone for this particular moment of time
9 // otherwise the time zone offset could be different because of DST.
10 var baseDate = Date.parse("2014-05-13T16:53:20.123Z");
11 var tzOffset = new Date(baseDate).getTimezoneOffset() * 60 * 1000;
12 var baseTimestamp = 1400000000000 + tzOffset;
14 function addMessageWithFixedTimestamp(messageText, timestamp)
16 var message = new WebInspector.ConsoleMessage(
17 WebInspector.consoleModel.target(),
18 WebInspector.ConsoleMessage.MessageSource.Other, // source
19 WebInspector.ConsoleMessage.MessageLevel.Log, // level
25 undefined, // requestId
26 undefined, // parameters
27 undefined, // stackTrace
28 timestamp || baseTimestamp + 123, // timestamp: 2014-05-13T16:53:20.123Z
30 WebInspector.consoleModel.addMessage(message, true); // allowGrouping
33 InspectorTest.addResult("Console messages with timestamps disabled:");
34 addMessageWithFixedTimestamp("<Before>");
35 addMessageWithFixedTimestamp("<Before>", baseTimestamp + 456);
36 addMessageWithFixedTimestamp("<Before>");
38 InspectorTest.dumpConsoleMessages();
40 InspectorTest.addResult("Console messages with timestamps enabled:");
41 WebInspector.settings.consoleTimestampsEnabled.set(true);
43 addMessageWithFixedTimestamp("<After>", baseTimestamp + 1000);
44 addMessageWithFixedTimestamp("<After>", baseTimestamp + 1000);
45 addMessageWithFixedTimestamp("<After>", baseTimestamp + 1456);
47 WebInspector.settings.consoleTimestampsEnabled.set(false);
48 WebInspector.settings.consoleTimestampsEnabled.set(true);
50 InspectorTest.dumpConsoleMessages();
51 InspectorTest.completeTest();
55 <body onload="runTest()">
57 Tests the console timestamp setting.