test-console-logs-exceptions-order.html (1163B)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <title>Webconsole order test test page</title> 6 </head> 7 <body> 8 <button>dispatched event target</button> 9 <script> 10 "use strict"; 11 const btn = document.querySelector("button"); 12 btn.addEventListener("click", () => { 13 console.log("First"); 14 // Don't throw an error as its stacktrace (whose rendering is delayed) 15 // might show up in the console message body and mess with the test. 16 // eslint-disable-next-line no-throw-literal 17 throw "Second"; 18 }); 19 20 // Use dispatchEvent as the event listener callback will be called directly, 21 // before the next lines are executed, which gives us a higher chance of 22 // having all the messages being emitted within the same millisecond. 23 btn.dispatchEvent(new MouseEvent("click")); 24 25 console.log("Third"); 26 // Don't throw an error as its stacktrace (whose rendering is delayed) 27 // might show up in the console message body and mess with the test. 28 // eslint-disable-next-line no-throw-literal 29 throw "Fourth"; 30 </script> 31 </body> 32 </html>