tor-browser

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

browser_dbg-preview-bucketed-array.js (1553B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 // Test the debugger popup previews with bucketed arrays.
      6 
      7 "use strict";
      8 
      9 add_task(async function () {
     10  const dbg = await initDebugger("doc-preview.html", "preview.js");
     11 
     12  await selectSource(dbg, "preview.js");
     13 
     14  invokeInTab("largeArray");
     15  await waitForPaused(dbg);
     16  const { element: popupEl, tokenEl } = await tryHovering(
     17    dbg,
     18    34,
     19    10,
     20    "previewPopup"
     21  );
     22 
     23  info("Wait for top level node to expand and child nodes to load");
     24  await waitUntil(
     25    () => popupEl.querySelectorAll(".preview-popup .node").length > 1
     26  );
     27 
     28  const oiNodes = Array.from(popupEl.querySelectorAll(".preview-popup .node"));
     29 
     30  const displayedPropertyNames = oiNodes.map(
     31    oiNode => oiNode.querySelector(".object-label")?.textContent
     32  );
     33  Assert.deepEqual(displayedPropertyNames, [
     34    null, // No property name is displayed for the root node
     35    "[0…99]",
     36    "[100…100]",
     37    "length",
     38    "<prototype>",
     39  ]);
     40  const node = oiNodes.find(
     41    oiNode => oiNode.querySelector(".object-label")?.textContent === "length"
     42  );
     43  if (!node) {
     44    ok(false, `The "length" property is not displayed in the popup`);
     45  } else {
     46    is(
     47      node.querySelector(".objectBox").textContent,
     48      "101",
     49      `The "length" property has the expected value`
     50    );
     51  }
     52  await closePreviewForToken(dbg, tokenEl, "popup");
     53 
     54  await resume(dbg);
     55 });