summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js
blob: 7b25e02a9baf10e4203e7cf9c7120c3cc70f148f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* import-globals-from helper-collapsibilities.js */
Services.scriptloader.loadSubScript(
  CHROME_URL_ROOT + "helper-collapsibilities.js",
  this
);

/**
 * Test that collapsibilities of DebugTargetPane on RuntimePage by mouse clicking.
 */

add_task(async function () {
  prepareCollapsibilitiesTest();

  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);

  for (const { title } of TARGET_PANES) {
    info("Check whether this pane is collapsed after clicking the title");
    await toggleCollapsibility(getDebugTargetPane(title, document));
    assertDebugTargetCollapsed(getDebugTargetPane(title, document), title);

    info("Check whether this pane is expanded after clicking the title again");
    await toggleCollapsibility(getDebugTargetPane(title, document));
    await assertDebugTargetExpanded(getDebugTargetPane(title, document), title);
  }

  await removeTab(tab);
});

async function assertDebugTargetCollapsed(paneEl, title) {
  info("Check debug target is collapsed");

  // check list height
  const targetEl = paneEl.querySelector(".qa-debug-target-pane__collapsable");
  is(targetEl.clientHeight, 0, "Height of list element is zero");
  // check title
  const titleEl = paneEl.querySelector(".qa-debug-target-pane-title");
  const expectedTitle = `${title} (${
    targetEl.querySelectorAll(".qa-debug-target-item").length
  })`;
  is(titleEl.textContent, expectedTitle, "Collapsed title is correct");
}

async function assertDebugTargetExpanded(paneEl, title) {
  info("Check debug target is expanded");

  // check list height
  const targetEl = paneEl.querySelector(".qa-debug-target-pane__collapsable");
  await waitUntil(() => targetEl.clientHeight > 0);
  ok(true, "Height of list element is greater than zero");
  // check title
  const titleEl = paneEl.querySelector(".qa-debug-target-pane-title");
  const expectedTitle = `${title} (${
    targetEl.querySelectorAll(".qa-debug-target-item").length
  })`;
  is(titleEl.textContent, expectedTitle, "Expanded title is correct");
}