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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial