summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_error_with_grouped_stack.js
blob: 94b232279608e43c31c0c0462bdf2002536af198 (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
33
34
35
36
37
38
39
40
41
42
43
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Check if an error with a stack containing grouped frames works as expected.

"use strict";

const MESSAGE = "React Error";
const TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html><script>
  const x = new Error("${MESSAGE}");
  x.stack = "a@http://exampl.com:1:1\\n" +
    "grouped@http://react.js:1:1\\n" +
    "grouped2@http://react.js:1:1";
  console.error(x);
</script>`;

add_task(async function () {
  const hud = await openNewTabAndConsole(TEST_URI);

  info("Wait for the error to be logged");
  const msgNode = await waitFor(() => findConsoleAPIMessage(hud, MESSAGE));
  ok(!msgNode.classList.contains("open"), `Error logged not expanded`);

  const groupNode = await waitFor(() => msgNode.querySelector(".group"));
  ok(groupNode, "The error object is logged as expected");

  const onGroupExpanded = waitFor(() =>
    msgNode.querySelector(".frames-group.expanded")
  );
  groupNode.click();
  await onGroupExpanded;

  ok(true, "The stacktrace group was expanded");
  is(
    msgNode.querySelectorAll(".frame").length,
    3,
    "Expected frames are displayed"
  );
  ok(
    !msgNode.classList.contains("open"),
    `Error message is still not expanded`
  );
});