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

"use strict";

/**
 * Tests if the network inspector view is shown when the target navigates
 * away while in the statistics view.
 */

add_task(function* () {
  let { tab, monitor } = yield initNetMonitor(STATISTICS_URL);
  info("Starting test... ");

  let panel = monitor.panelWin;
  let { EVENTS, NetMonitorView } = panel;
  is(NetMonitorView.currentFrontendMode, "network-inspector-view",
      "The initial frontend mode is correct.");

  let onChartDisplayed = Promise.all([
    panel.once(EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
    panel.once(EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
  ]);

  info("Displaying statistics view");
  NetMonitorView.toggleFrontendMode();
  yield onChartDisplayed;
  is(NetMonitorView.currentFrontendMode, "network-statistics-view",
        "The frontend mode is currently in the statistics view.");

  info("Reloading page");
  let onWillNavigate = panel.once(EVENTS.TARGET_WILL_NAVIGATE);
  let onDidNavigate = panel.once(EVENTS.TARGET_DID_NAVIGATE);
  tab.linkedBrowser.reload();
  yield onWillNavigate;
  is(NetMonitorView.currentFrontendMode, "network-inspector-view",
          "The frontend mode switched back to the inspector view.");
  yield onDidNavigate;
  is(NetMonitorView.currentFrontendMode, "network-inspector-view",
            "The frontend mode is still in the inspector view.");
  yield teardown(monitor);
});