tor-browser

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

browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js (2215B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /* import-globals-from helper-collapsibilities.js */
      7 Services.scriptloader.loadSubScript(
      8  CHROME_URL_ROOT + "helper-collapsibilities.js",
      9  this
     10 );
     11 
     12 /**
     13 * Test that collapsibilities of DebugTargetPane on RuntimePage by mouse clicking.
     14 */
     15 
     16 add_task(async function () {
     17  prepareCollapsibilitiesTest();
     18 
     19  const { document, tab, window } = await openAboutDebugging();
     20  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     21 
     22  for (const { title } of TARGET_PANES) {
     23    info("Check whether this pane is collapsed after clicking the title");
     24    await toggleCollapsibility(getDebugTargetPane(title, document));
     25    assertDebugTargetCollapsed(getDebugTargetPane(title, document), title);
     26 
     27    info("Check whether this pane is expanded after clicking the title again");
     28    await toggleCollapsibility(getDebugTargetPane(title, document));
     29    await assertDebugTargetExpanded(getDebugTargetPane(title, document), title);
     30  }
     31 
     32  await removeTab(tab);
     33 });
     34 
     35 async function assertDebugTargetCollapsed(paneEl, title) {
     36  info("Check debug target is collapsed");
     37 
     38  // check list height
     39  const targetEl = paneEl.querySelector(".qa-debug-target-pane__collapsable");
     40  is(targetEl.clientHeight, 0, "Height of list element is zero");
     41  // check title
     42  const titleEl = paneEl.querySelector(".qa-debug-target-pane-title");
     43  const expectedTitle = `${title} (${
     44    targetEl.querySelectorAll(".qa-debug-target-item").length
     45  })`;
     46  is(titleEl.textContent, expectedTitle, "Collapsed title is correct");
     47 }
     48 
     49 async function assertDebugTargetExpanded(paneEl, title) {
     50  info("Check debug target is expanded");
     51 
     52  // check list height
     53  const targetEl = paneEl.querySelector(".qa-debug-target-pane__collapsable");
     54  await waitUntil(() => targetEl.clientHeight > 0);
     55  ok(true, "Height of list element is greater than zero");
     56  // check title
     57  const titleEl = paneEl.querySelector(".qa-debug-target-pane-title");
     58  const expectedTitle = `${title} (${
     59    targetEl.querySelectorAll(".qa-debug-target-item").length
     60  })`;
     61  is(titleEl.textContent, expectedTitle, "Expanded title is correct");
     62 }