browser/devtools/netmonitor/test/browser_net_simple-init.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Simple check if the network monitor starts up and shuts down properly.
     6  */
     8 function test() {
     9   initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    10     info("Starting test... ");
    12     is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL,
    13       "The current tab's location is the correct one.");
    14     is(aDebuggee.location, SIMPLE_URL,
    15       "The current debuggee's location is the correct one.");
    17     function checkIfInitialized(aTag) {
    18       info("Checking if initialization is ok (" + aTag + ").");
    20       ok(aMonitor._view,
    21         "The network monitor view object exists (" + aTag + ").");
    22       ok(aMonitor._controller,
    23         "The network monitor controller object exists (" + aTag + ").");
    24       ok(aMonitor._controller._startup,
    25         "The network monitor controller object exists and is initialized (" + aTag + ").");
    27       ok(aMonitor.isReady,
    28         "The network monitor panel appears to be ready (" + aTag + ").");
    30       ok(aMonitor._controller.client,
    31         "There should be a client available at this point (" + aTag + ").");
    32       ok(aMonitor._controller.tabClient,
    33         "There should be a tabClient available at this point (" + aTag + ").");
    34       ok(aMonitor._controller.webConsoleClient,
    35         "There should be a webConsoleClient available at this point (" + aTag + ").");
    36     }
    38     function checkIfDestroyed(aTag) {
    39       info("Checking if destruction is ok.");
    41       ok(aMonitor._view,
    42         "The network monitor view object still exists (" + aTag + ").");
    43       ok(aMonitor._controller,
    44         "The network monitor controller object still exists (" + aTag + ").");
    45       ok(aMonitor._controller._shutdown,
    46         "The network monitor controller object still exists and is destroyed (" + aTag + ").");
    48       ok(!aMonitor._controller.client,
    49         "There shouldn't be a client available after destruction (" + aTag + ").");
    50       ok(!aMonitor._controller.tabClient,
    51         "There shouldn't be a tabClient available after destruction (" + aTag + ").");
    52       ok(!aMonitor._controller.webConsoleClient,
    53         "There shouldn't be a webConsoleClient available after destruction (" + aTag + ").");
    54     }
    56     executeSoon(() => {
    57       checkIfInitialized(1);
    59       aMonitor._controller.startupNetMonitor()
    60         .then(() => {
    61           info("Starting up again shouldn't do anything special.");
    62           checkIfInitialized(2);
    63           return aMonitor._controller.connect();
    64         })
    65         .then(() => {
    66           info("Connecting again shouldn't do anything special.");
    67           checkIfInitialized(3);
    68           return teardown(aMonitor);
    69         })
    70         .then(finish);
    71     });
    73     registerCleanupFunction(() => {
    74       checkIfDestroyed(1);
    76       aMonitor._controller.shutdownNetMonitor()
    77         .then(() => {
    78           info("Shutting down again shouldn't do anything special.");
    79           checkIfDestroyed(2);
    80           return aMonitor._controller.disconnect();
    81         })
    82         .then(() => {
    83           info("Disconnecting again shouldn't do anything special.");
    84           checkIfDestroyed(3);
    85         });
    86     });
    87   });
    88 }

mercurial