summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_expand-collapse.js
blob: 3b1dcb6b242e72deff7e2ee4f1e8fb9a3b53121c (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
63
64
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that context menu items exapnd all and collapse are shown properly.

const TEST_URL = "data:text/html;charset=utf-8," +
                 "<div id='parent-node'><div id='child-node'></div></div>";

add_task(function* () {
  // Test is often exceeding time-out threshold, similar to Bug 1137765
  requestLongerTimeout(2);

  let {inspector} = yield openInspectorForURL(TEST_URL);

  info("Selecting the parent node");

  let front = yield getNodeFrontForSelector("#parent-node", inspector);

  yield selectNode(front, inspector);

  info("Simulating context menu click on the selected node container.");
  let allMenuItems = openContextMenuAndGetAllItems(inspector, {
    target: getContainerForNodeFront(front, inspector).tagLine,
  });
  let nodeMenuCollapseElement =
    allMenuItems.find(item => item.id === "node-menu-collapse");
  let nodeMenuExpandElement =
    allMenuItems.find(item => item.id === "node-menu-expand");

  ok(nodeMenuCollapseElement.disabled, "Collapse option is disabled");
  ok(!nodeMenuExpandElement.disabled, "ExpandAll option is enabled");

  info("Testing whether expansion works properly");
  nodeMenuExpandElement.click();

  info("Waiting for expansion to occur");
  yield waitForMultipleChildrenUpdates(inspector);
  let markUpContainer = getContainerForNodeFront(front, inspector);
  ok(markUpContainer.expanded, "node has been successfully expanded");

  // reselecting node after expansion
  yield selectNode(front, inspector);

  info("Testing whether collapse works properly");
  info("Simulating context menu click on the selected node container.");
  allMenuItems = openContextMenuAndGetAllItems(inspector, {
    target: getContainerForNodeFront(front, inspector).tagLine,
  });
  nodeMenuCollapseElement =
    allMenuItems.find(item => item.id === "node-menu-collapse");
  nodeMenuExpandElement =
    allMenuItems.find(item => item.id === "node-menu-expand");

  ok(!nodeMenuCollapseElement.disabled, "Collapse option is enabled");
  ok(!nodeMenuExpandElement.disabled, "ExpandAll option is enabled");
  nodeMenuCollapseElement.click();

  info("Waiting for collapse to occur");
  yield waitForMultipleChildrenUpdates(inspector);
  ok(!markUpContainer.expanded, "node has been successfully collapsed");
});