summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_console_dir_uninspectable.js
blob: 255d9638be7173e9333c6f1a0dbaf27772f5c665 (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
44
45
46
47
48
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Make sure that the Web Console output does not break after we try to call
// console.dir() for objects that are not inspectable.

"use strict";

const TEST_URI =
  "data:text/html;charset=utf8,test console.dir on uninspectable object";
const FIRST_LOG_MESSAGE = "fooBug773466a";
const SECOND_LOG_MESSAGE = "fooBug773466b";

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

  info("Logging a first message to make sure everything is working");
  await executeAndWaitForMessage(
    hud,
    `console.log("${FIRST_LOG_MESSAGE}")`,
    FIRST_LOG_MESSAGE,
    ".message.log"
  );

  info("console.dir on an uninspectable object");
  await executeAndWaitForMessage(
    hud,
    "console.dir(Object.create(null))",
    "Object {  }"
  );

  info("Logging a second message to make sure the console is not broken");
  const onLogMessage = waitForMessage(hud, SECOND_LOG_MESSAGE);
  // Logging from content to make sure the console API is working.
  SpecialPowers.spawn(
    gBrowser.selectedBrowser,
    [SECOND_LOG_MESSAGE],
    string => {
      content.console.log(string);
    }
  );
  await onLogMessage;

  ok(
    true,
    "The console.dir call on an uninspectable object did not break the console"
  );
});