summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_response_node-expanded.js
blob: 734b84d3bcc9acb84a4599589ec0ad0e8a55492e (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests if the node that was expanded is still expanded when we are filtering
 * in the Response Panel.
 */

add_task(async function () {
  const { tab, monitor } = await initNetMonitor(JSON_LONG_URL, {
    requestCount: 1,
  });
  info("Starting test... ");

  const { document, store, windowRequire } = monitor.panelWin;
  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");

  store.dispatch(Actions.batchEnable(false));

  await performRequests(monitor, tab, 1);

  info("selecting first request");
  const firstRequestItem = document.querySelectorAll(".request-list-item")[0];
  EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequestItem);

  info("switching to response panel");
  const waitForRespPanel = waitForDOM(
    document,
    "#response-panel .properties-view"
  );
  const respPanelButton = document.querySelector("#response-tab");
  respPanelButton.click();
  await waitForRespPanel;

  const firstRow = document.querySelector(
    "#response-panel tr.treeRow.objectRow"
  );
  const waitOpenNode = waitForDOM(document, "tr#\\/0\\/greeting");
  const toggleButton = firstRow.querySelector("td span.treeIcon");

  toggleButton.click();
  await waitOpenNode;

  is(firstRow.classList.contains("opened"), true, "the node is open");

  document.querySelector("#response-panel .devtools-filterinput").focus();
  EventUtils.sendString("greeting");

  // Wait till there are 2048 resources rendered in the results.
  await waitForDOMIfNeeded(document, "#response-panel tr.treeRow", 2048);

  is(firstRow.classList.contains("opened"), true, "the node remains open");

  await teardown(monitor);
});