tor-browser

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

browser_markup_toggle_02.js (2022B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test toggling (expand/collapse) elements by dbl-clicking on tag lines
      7 
      8 const TEST_URL = URL_ROOT + "doc_markup_toggle.html";
      9 
     10 add_task(async function () {
     11  const { inspector } = await openInspectorForURL(TEST_URL);
     12 
     13  info("Getting the container for the UL parent element");
     14  const container = await getContainerForSelector("ul", inspector);
     15 
     16  info("Dbl-clicking on the UL parent expander, and waiting for children");
     17  const onChildren = waitForChildrenUpdated(inspector);
     18  const onUpdated = inspector.once("inspector-updated");
     19  EventUtils.synthesizeMouseAtCenter(
     20    container.tagLine,
     21    { clickCount: 2 },
     22    inspector.markup.doc.defaultView
     23  );
     24  await onChildren;
     25  await onUpdated;
     26 
     27  info("Checking that child LI elements have been created");
     28  let numLi = await getNumberOfMatchingElementsInContentPage("li");
     29  for (let i = 0; i < numLi; i++) {
     30    const liContainer = await getContainerForSelector(
     31      "li:nth-child(" + (i + 1) + ")",
     32      inspector
     33    );
     34    ok(liContainer, "A container for the child LI element was created");
     35  }
     36  ok(container.expanded, "Parent UL container is expanded");
     37 
     38  info("Dbl-clicking again on the UL expander");
     39  // No need to wait, this is a local, synchronous operation where nodes are
     40  // only hidden from the view, not destroyed
     41  EventUtils.synthesizeMouseAtCenter(
     42    container.tagLine,
     43    { clickCount: 2 },
     44    inspector.markup.doc.defaultView
     45  );
     46 
     47  info("Checking that child LI elements have been hidden");
     48  numLi = await getNumberOfMatchingElementsInContentPage("li");
     49  for (let i = 0; i < numLi; i++) {
     50    const liContainer = await getContainerForSelector(
     51      "li:nth-child(" + (i + 1) + ")",
     52      inspector
     53    );
     54    is(
     55      liContainer.elt.getClientRects().length,
     56      0,
     57      "The container for the child LI element was hidden"
     58    );
     59  }
     60  ok(!container.expanded, "Parent UL container is collapsed");
     61 });