browser/devtools/netmonitor/test/browser_net_req-resp-bodies.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_req-resp-bodies.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     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 + * Test if request and response body logging stays on after opening the console.
     1.9 + */
    1.10 +
    1.11 +function test() {
    1.12 +  initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => {
    1.13 +    info("Starting test... ");
    1.14 +
    1.15 +    let { L10N, NetMonitorView } = aMonitor.panelWin;
    1.16 +    let { RequestsMenu } = NetMonitorView;
    1.17 +
    1.18 +    RequestsMenu.lazyUpdate = false;
    1.19 +
    1.20 +    function verifyRequest(aOffset) {
    1.21 +      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOffset),
    1.22 +        "GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
    1.23 +          status: 200,
    1.24 +          statusText: "OK",
    1.25 +          type: "json",
    1.26 +          fullMimeType: "text/json; charset=utf-8",
    1.27 +          size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)),
    1.28 +          time: true
    1.29 +        });
    1.30 +    }
    1.31 +
    1.32 +    waitForNetworkEvents(aMonitor, 1).then(() => {
    1.33 +      verifyRequest(0);
    1.34 +
    1.35 +      aMonitor._toolbox.once("webconsole-selected", () => {
    1.36 +        aMonitor._toolbox.once("netmonitor-selected", () => {
    1.37 +
    1.38 +          waitForNetworkEvents(aMonitor, 1).then(() => {
    1.39 +            waitForNetworkEvents(aMonitor, 1).then(() => {
    1.40 +              verifyRequest(1);
    1.41 +              teardown(aMonitor).then(finish);
    1.42 +            });
    1.43 +
    1.44 +            // Perform another batch of requests.
    1.45 +            aDebuggee.performRequests();
    1.46 +          });
    1.47 +
    1.48 +          // Reload debugee.
    1.49 +          aDebuggee.location.reload();
    1.50 +        });
    1.51 +
    1.52 +        // Switch back to the netmonitor.
    1.53 +        aMonitor._toolbox.selectTool("netmonitor");
    1.54 +      });
    1.55 +
    1.56 +      // Switch to the webconsole.
    1.57 +      aMonitor._toolbox.selectTool("webconsole");
    1.58 +    });
    1.59 +
    1.60 +    // Perform first batch of requests.
    1.61 +    aDebuggee.performRequests();
    1.62 +  });
    1.63 +}

mercurial