tor-browser

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

browser_webconsole_object_inspector_symbols.js (2127B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Check expanding/collapsing object with symbol properties in the console.
      7 const TEST_URI = "data:text/html;charset=utf8,<!DOCTYPE html>";
      8 
      9 add_task(async function () {
     10  const hud = await openNewTabAndConsole(TEST_URI);
     11 
     12  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     13    content.wrappedJSObject.console.log("oi-symbols-test", {
     14      [Symbol()]: "first symbol",
     15      [Symbol()]: "second symbol",
     16      [Symbol()]: 0,
     17      [Symbol()]: null,
     18      [Symbol()]: false,
     19      [Symbol()]: undefined,
     20      [Symbol("named")]: "named symbol",
     21      [Symbol("array")]: [1, 2, 3],
     22    });
     23  });
     24 
     25  const node = await waitFor(() =>
     26    findConsoleAPIMessage(hud, "oi-symbols-test")
     27  );
     28  const objectInspectors = [...node.querySelectorAll(".tree")];
     29  is(
     30    objectInspectors.length,
     31    1,
     32    "There is the expected number of object inspectors"
     33  );
     34 
     35  const [oi] = objectInspectors;
     36 
     37  info("Expanding the Object");
     38  await expandObjectInspectorNode(oi.querySelector(".tree-node"));
     39 
     40  const oiNodes = oi.querySelectorAll(".node");
     41  // The object inspector should look like this:
     42  /*
     43   * ▼ { … }
     44   * |   Symbol(): "first symbol",
     45   * |   Symbol(): "second symbol",
     46   * |   Symbol(): 0,
     47   * |   Symbol(): null,
     48   * |   Symbol(): false,
     49   * |   Symbol(): undefined,
     50   * |   Symbol(named): "named symbol",
     51   * |   Symbol(array): Array(3) [ 1, 2, 3 ],
     52   * | ▶︎ <prototype>
     53   */
     54  is(oiNodes.length, 10, "There is the expected number of nodes in the tree");
     55 
     56  is(oiNodes[1].textContent.trim(), `Symbol(): "first symbol"`);
     57  is(oiNodes[2].textContent.trim(), `Symbol(): "second symbol"`);
     58  is(oiNodes[3].textContent.trim(), `Symbol(): 0`);
     59  is(oiNodes[4].textContent.trim(), `Symbol(): null`);
     60  is(oiNodes[5].textContent.trim(), `Symbol(): false`);
     61  is(oiNodes[6].textContent.trim(), `Symbol(): undefined`);
     62  is(oiNodes[7].textContent.trim(), `Symbol(named): "named symbol"`);
     63  is(oiNodes[8].textContent.trim(), `Symbol(array): Array(3) [ 1, 2, 3 ]`);
     64 });