summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_console_error_expand_object.js
blob: 56a797115d9dfa8b922093412d57f7dfa3daf4a9 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Check console.error calls with expandable object.
const TEST_URI =
  "data:text/html;charset=utf8,<!DOCTYPE html><h1>test console.error with objects</h1>";

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

  const onMessagesLogged = waitForMessageByType(
    hud,
    "myError",
    ".console-api.error"
  );
  SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
    content.wrappedJSObject.console.error("myError", { a: "a", b: "b" });
  });
  const { node } = await onMessagesLogged;

  const objectInspectors = [...node.querySelectorAll(".tree")];
  is(
    objectInspectors.length,
    1,
    "There is the expected number of object inspectors"
  );
  const [oi] = objectInspectors;
  oi.querySelector(".node .arrow").click();
  await waitFor(() => oi.querySelectorAll(".node").length > 1);
  ok(true, "The object can be expanded");
});