test_console_timestamp.html (1392B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test for console.group styling with %c</title> 6 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 7 <script type="text/javascript" src="common.js"></script> 8 <!-- Any copyright is dedicated to the Public Domain. 9 - http://creativecommons.org/publicdomain/zero/1.0/ --> 10 <script> 11 "use strict"; 12 13 window.onload = async function () { 14 SimpleTest.waitForExplicitFinish(); 15 let state; 16 try { 17 state = (await attachConsole(["ConsoleAPI"])).state; 18 const consoleFront = state.webConsoleFront; 19 20 info("Testing console.log packet timestamp correctness"); 21 const clientLogTimestamp = Date.now(); 22 const packet = await consoleAPICall(consoleFront, 23 () => top.console.log("test")); 24 const packetReceivedTimestamp = Date.now(); 25 26 const {timeStamp} = packet.message; 27 ok(clientLogTimestamp <= timeStamp && timeStamp <= packetReceivedTimestamp, 28 "console.log message timestamp is between the expected time range " + 29 `(${clientLogTimestamp} <= ${timeStamp} <= ${packetReceivedTimestamp})` 30 ); 31 } catch (e) { 32 ok(false, `Error thrown: ${e.message}`); 33 } 34 35 await closeDebugger(state); 36 SimpleTest.finish(); 37 }; 38 39 </script> 40 </head> 41 <body> 42 <p id="display"></p> 43 <div id="content" style="display: none"> 44 </div> 45 <pre id="test"> 46 </pre> 47 </body> 48 </html>