tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_webconsole_console_dir_uninspectable.js (1439B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Make sure that the Web Console output does not break after we try to call
      5 // console.dir() for objects that are not inspectable.
      6 
      7 "use strict";
      8 
      9 const TEST_URI =
     10  "data:text/html;charset=utf8,<!DOCTYPE html>test console.dir on uninspectable object";
     11 const FIRST_LOG_MESSAGE = "fooBug773466a";
     12 const SECOND_LOG_MESSAGE = "fooBug773466b";
     13 
     14 add_task(async function () {
     15  const hud = await openNewTabAndConsole(TEST_URI);
     16 
     17  info("Logging a first message to make sure everything is working");
     18  await executeAndWaitForMessageByType(
     19    hud,
     20    `console.log("${FIRST_LOG_MESSAGE}")`,
     21    FIRST_LOG_MESSAGE,
     22    ".console-api"
     23  );
     24 
     25  info("console.dir on an uninspectable object");
     26  await executeAndWaitForMessageByType(
     27    hud,
     28    "console.dir(Object.create(null))",
     29    "Object {  }",
     30    ".console-api"
     31  );
     32 
     33  info("Logging a second message to make sure the console is not broken");
     34  const onLogMessage = waitForMessageByType(
     35    hud,
     36    SECOND_LOG_MESSAGE,
     37    ".console-api"
     38  );
     39  // Logging from content to make sure the console API is working.
     40  SpecialPowers.spawn(
     41    gBrowser.selectedBrowser,
     42    [SECOND_LOG_MESSAGE],
     43    string => {
     44      content.console.log(string);
     45    }
     46  );
     47  await onLogMessage;
     48 
     49  ok(
     50    true,
     51    "The console.dir call on an uninspectable object did not break the console"
     52  );
     53 });