summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/test-console-logs-exceptions-order.html
blob: e51df0b38df734b9aa798927cae18a195d37e986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Webconsole order test test page</title>
  </head>
  <body>
    <button>dispatched event target</button>
    <script>
      "use strict";
      const btn = document.querySelector("button");
      btn.addEventListener("click", () => {
        console.log("First");
        // Don't throw an error as its stacktrace  (whose rendering is delayed)
        // might show up in the console message body and mess with the test.
        // eslint-disable-next-line no-throw-literal
        throw "Second";
      });

      // Use dispatchEvent as the event listener callback will be called directly,
      // before the next lines are executed, which gives us a higher chance of
      // having all the messages being emitted within the same millisecond.
      btn.dispatchEvent(new MouseEvent("click"));

      console.log("Third");
      // Don't throw an error as its stacktrace  (whose rendering is delayed)
      // might show up in the console message body and mess with the test.
      // eslint-disable-next-line no-throw-literal
      throw "Fourth";
    </script>
  </body>
</html>