browser/devtools/netmonitor/test/browser_net_simple-init.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_simple-init.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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 + * Simple check if the network monitor starts up and shuts down properly.
     1.9 + */
    1.10 +
    1.11 +function test() {
    1.12 +  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    1.13 +    info("Starting test... ");
    1.14 +
    1.15 +    is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL,
    1.16 +      "The current tab's location is the correct one.");
    1.17 +    is(aDebuggee.location, SIMPLE_URL,
    1.18 +      "The current debuggee's location is the correct one.");
    1.19 +
    1.20 +    function checkIfInitialized(aTag) {
    1.21 +      info("Checking if initialization is ok (" + aTag + ").");
    1.22 +
    1.23 +      ok(aMonitor._view,
    1.24 +        "The network monitor view object exists (" + aTag + ").");
    1.25 +      ok(aMonitor._controller,
    1.26 +        "The network monitor controller object exists (" + aTag + ").");
    1.27 +      ok(aMonitor._controller._startup,
    1.28 +        "The network monitor controller object exists and is initialized (" + aTag + ").");
    1.29 +
    1.30 +      ok(aMonitor.isReady,
    1.31 +        "The network monitor panel appears to be ready (" + aTag + ").");
    1.32 +
    1.33 +      ok(aMonitor._controller.client,
    1.34 +        "There should be a client available at this point (" + aTag + ").");
    1.35 +      ok(aMonitor._controller.tabClient,
    1.36 +        "There should be a tabClient available at this point (" + aTag + ").");
    1.37 +      ok(aMonitor._controller.webConsoleClient,
    1.38 +        "There should be a webConsoleClient available at this point (" + aTag + ").");
    1.39 +    }
    1.40 +
    1.41 +    function checkIfDestroyed(aTag) {
    1.42 +      info("Checking if destruction is ok.");
    1.43 +
    1.44 +      ok(aMonitor._view,
    1.45 +        "The network monitor view object still exists (" + aTag + ").");
    1.46 +      ok(aMonitor._controller,
    1.47 +        "The network monitor controller object still exists (" + aTag + ").");
    1.48 +      ok(aMonitor._controller._shutdown,
    1.49 +        "The network monitor controller object still exists and is destroyed (" + aTag + ").");
    1.50 +
    1.51 +      ok(!aMonitor._controller.client,
    1.52 +        "There shouldn't be a client available after destruction (" + aTag + ").");
    1.53 +      ok(!aMonitor._controller.tabClient,
    1.54 +        "There shouldn't be a tabClient available after destruction (" + aTag + ").");
    1.55 +      ok(!aMonitor._controller.webConsoleClient,
    1.56 +        "There shouldn't be a webConsoleClient available after destruction (" + aTag + ").");
    1.57 +    }
    1.58 +
    1.59 +    executeSoon(() => {
    1.60 +      checkIfInitialized(1);
    1.61 +
    1.62 +      aMonitor._controller.startupNetMonitor()
    1.63 +        .then(() => {
    1.64 +          info("Starting up again shouldn't do anything special.");
    1.65 +          checkIfInitialized(2);
    1.66 +          return aMonitor._controller.connect();
    1.67 +        })
    1.68 +        .then(() => {
    1.69 +          info("Connecting again shouldn't do anything special.");
    1.70 +          checkIfInitialized(3);
    1.71 +          return teardown(aMonitor);
    1.72 +        })
    1.73 +        .then(finish);
    1.74 +    });
    1.75 +
    1.76 +    registerCleanupFunction(() => {
    1.77 +      checkIfDestroyed(1);
    1.78 +
    1.79 +      aMonitor._controller.shutdownNetMonitor()
    1.80 +        .then(() => {
    1.81 +          info("Shutting down again shouldn't do anything special.");
    1.82 +          checkIfDestroyed(2);
    1.83 +          return aMonitor._controller.disconnect();
    1.84 +        })
    1.85 +        .then(() => {
    1.86 +          info("Disconnecting again shouldn't do anything special.");
    1.87 +          checkIfDestroyed(3);
    1.88 +        });
    1.89 +    });
    1.90 +  });
    1.91 +}

mercurial