browser/devtools/netmonitor/test/browser_net_statistics-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/netmonitor/test/browser_net_statistics-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests if the network inspector view is shown when the target navigates
     1.9 + * away while in the statistics view.
    1.10 + */
    1.11 +
    1.12 +function test() {
    1.13 +  initNetMonitor(STATISTICS_URL).then(([aTab, aDebuggee, aMonitor]) => {
    1.14 +    info("Starting test... ");
    1.15 +
    1.16 +    let panel = aMonitor.panelWin;
    1.17 +    let { document, EVENTS, NetMonitorView } = panel;
    1.18 +
    1.19 +    is(NetMonitorView.currentFrontendMode, "network-inspector-view",
    1.20 +      "The initial frontend mode is correct.");
    1.21 +
    1.22 +    promise.all([
    1.23 +      waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
    1.24 +      waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
    1.25 +    ]).then(() => {
    1.26 +      is(NetMonitorView.currentFrontendMode, "network-statistics-view",
    1.27 +        "The frontend mode is currently in the statistics view.");
    1.28 +
    1.29 +      waitFor(panel, EVENTS.TARGET_WILL_NAVIGATE).then(() => {
    1.30 +        is(NetMonitorView.currentFrontendMode, "network-inspector-view",
    1.31 +          "The frontend mode switched back to the inspector view.");
    1.32 +
    1.33 +        waitFor(panel, EVENTS.TARGET_DID_NAVIGATE).then(() => {
    1.34 +          is(NetMonitorView.currentFrontendMode, "network-inspector-view",
    1.35 +            "The frontend mode is still in the inspector view.");
    1.36 +
    1.37 +          teardown(aMonitor).then(finish);
    1.38 +        });
    1.39 +      });
    1.40 +
    1.41 +      aDebuggee.location.reload();
    1.42 +    });
    1.43 +
    1.44 +    NetMonitorView.toggleFrontendMode();
    1.45 +  });
    1.46 +}

mercurial