tor-browser

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

browser_inspector_expand-collapse.js (2395B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that context menu items exapnd all and collapse are shown properly.
      7 
      8 const TEST_URL =
      9  "data:text/html;charset=utf-8," +
     10  "<div id='parent-node'><div id='child-node'></div></div>";
     11 
     12 add_task(async function () {
     13  // Test is often exceeding time-out threshold, similar to Bug 1137765
     14  requestLongerTimeout(2);
     15 
     16  const { inspector } = await openInspectorForURL(TEST_URL);
     17 
     18  info("Selecting the parent node");
     19 
     20  const front = await getNodeFrontForSelector("#parent-node", inspector);
     21 
     22  await selectNode(front, inspector);
     23 
     24  info("Simulating context menu click on the selected node container.");
     25  let allMenuItems = openContextMenuAndGetAllItems(inspector, {
     26    target: getContainerForNodeFront(front, inspector).tagLine,
     27  });
     28  let nodeMenuCollapseElement = allMenuItems.find(
     29    item => item.id === "node-menu-collapse"
     30  );
     31  let nodeMenuExpandElement = allMenuItems.find(
     32    item => item.id === "node-menu-expand"
     33  );
     34 
     35  ok(nodeMenuCollapseElement.disabled, "Collapse option is disabled");
     36  ok(!nodeMenuExpandElement.disabled, "ExpandAll option is enabled");
     37 
     38  info("Testing whether expansion works properly");
     39  nodeMenuExpandElement.click();
     40 
     41  info("Waiting for expansion to occur");
     42  await waitForMultipleChildrenUpdates(inspector);
     43  const markUpContainer = getContainerForNodeFront(front, inspector);
     44  ok(markUpContainer.expanded, "node has been successfully expanded");
     45 
     46  // reselecting node after expansion
     47  await selectNode(front, inspector);
     48 
     49  info("Testing whether collapse works properly");
     50  info("Simulating context menu click on the selected node container.");
     51  allMenuItems = openContextMenuAndGetAllItems(inspector, {
     52    target: getContainerForNodeFront(front, inspector).tagLine,
     53  });
     54  nodeMenuCollapseElement = allMenuItems.find(
     55    item => item.id === "node-menu-collapse"
     56  );
     57  nodeMenuExpandElement = allMenuItems.find(
     58    item => item.id === "node-menu-expand"
     59  );
     60 
     61  ok(!nodeMenuCollapseElement.disabled, "Collapse option is enabled");
     62  ok(!nodeMenuExpandElement.disabled, "ExpandAll option is enabled");
     63  nodeMenuCollapseElement.click();
     64 
     65  info("Waiting for collapse to occur");
     66  await waitForMultipleChildrenUpdates(inspector);
     67  ok(!markUpContainer.expanded, "node has been successfully collapsed");
     68 });