summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_statistics-02.js
blob: ccc25a387d649b11e5ffbbc651cd330313c0ffdc (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
65
66
67
68
69
70
71
72
73
74
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Test if the correct filtering predicates are used when filtering from
 * the performance analysis view.
 */

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

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

  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".requests-list-filter-html-button")
  );
  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".requests-list-filter-css-button")
  );
  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".requests-list-filter-js-button")
  );
  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".requests-list-filter-ws-button")
  );
  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".requests-list-filter-other-button")
  );
  testFilterButtonsCustom(monitor, [0, 1, 1, 1, 0, 0, 0, 0, 1, 1]);
  info(
    "The correct filtering predicates are used before entering perf. analysis mode."
  );

  store.dispatch(Actions.openStatistics(connector, true));

  ok(
    document.querySelector(".statistics-panel"),
    "The main panel is switched to the statistics panel."
  );

  await waitUntil(
    () =>
      document.querySelectorAll(".pie-chart-container:not([placeholder=true])")
        .length == 2
  );
  ok(true, "Two real pie charts appear to be rendered correctly.");

  EventUtils.sendMouseEvent(
    { type: "click" },
    document.querySelector(".pie-chart-slice-container")
  );

  ok(
    document.querySelector(".monitor-panel"),
    "The main panel is switched back to the monitor panel."
  );

  testFilterButtons(monitor, "html");
  info(
    "The correct filtering predicate is used when exiting perf. analysis mode."
  );

  await teardown(monitor);
});