michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Simple check if the network monitor starts up and shuts down properly. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL, michael@0: "The current tab's location is the correct one."); michael@0: is(aDebuggee.location, SIMPLE_URL, michael@0: "The current debuggee's location is the correct one."); michael@0: michael@0: function checkIfInitialized(aTag) { michael@0: info("Checking if initialization is ok (" + aTag + ")."); michael@0: michael@0: ok(aMonitor._view, michael@0: "The network monitor view object exists (" + aTag + ")."); michael@0: ok(aMonitor._controller, michael@0: "The network monitor controller object exists (" + aTag + ")."); michael@0: ok(aMonitor._controller._startup, michael@0: "The network monitor controller object exists and is initialized (" + aTag + ")."); michael@0: michael@0: ok(aMonitor.isReady, michael@0: "The network monitor panel appears to be ready (" + aTag + ")."); michael@0: michael@0: ok(aMonitor._controller.client, michael@0: "There should be a client available at this point (" + aTag + ")."); michael@0: ok(aMonitor._controller.tabClient, michael@0: "There should be a tabClient available at this point (" + aTag + ")."); michael@0: ok(aMonitor._controller.webConsoleClient, michael@0: "There should be a webConsoleClient available at this point (" + aTag + ")."); michael@0: } michael@0: michael@0: function checkIfDestroyed(aTag) { michael@0: info("Checking if destruction is ok."); michael@0: michael@0: ok(aMonitor._view, michael@0: "The network monitor view object still exists (" + aTag + ")."); michael@0: ok(aMonitor._controller, michael@0: "The network monitor controller object still exists (" + aTag + ")."); michael@0: ok(aMonitor._controller._shutdown, michael@0: "The network monitor controller object still exists and is destroyed (" + aTag + ")."); michael@0: michael@0: ok(!aMonitor._controller.client, michael@0: "There shouldn't be a client available after destruction (" + aTag + ")."); michael@0: ok(!aMonitor._controller.tabClient, michael@0: "There shouldn't be a tabClient available after destruction (" + aTag + ")."); michael@0: ok(!aMonitor._controller.webConsoleClient, michael@0: "There shouldn't be a webConsoleClient available after destruction (" + aTag + ")."); michael@0: } michael@0: michael@0: executeSoon(() => { michael@0: checkIfInitialized(1); michael@0: michael@0: aMonitor._controller.startupNetMonitor() michael@0: .then(() => { michael@0: info("Starting up again shouldn't do anything special."); michael@0: checkIfInitialized(2); michael@0: return aMonitor._controller.connect(); michael@0: }) michael@0: .then(() => { michael@0: info("Connecting again shouldn't do anything special."); michael@0: checkIfInitialized(3); michael@0: return teardown(aMonitor); michael@0: }) michael@0: .then(finish); michael@0: }); michael@0: michael@0: registerCleanupFunction(() => { michael@0: checkIfDestroyed(1); michael@0: michael@0: aMonitor._controller.shutdownNetMonitor() michael@0: .then(() => { michael@0: info("Shutting down again shouldn't do anything special."); michael@0: checkIfDestroyed(2); michael@0: return aMonitor._controller.disconnect(); michael@0: }) michael@0: .then(() => { michael@0: info("Disconnecting again shouldn't do anything special."); michael@0: checkIfDestroyed(3); michael@0: }); michael@0: }); michael@0: }); michael@0: }