|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Simple check if the network monitor starts up and shuts down properly. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
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."); |
|
16 |
|
17 function checkIfInitialized(aTag) { |
|
18 info("Checking if initialization is ok (" + aTag + ")."); |
|
19 |
|
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 + ")."); |
|
26 |
|
27 ok(aMonitor.isReady, |
|
28 "The network monitor panel appears to be ready (" + aTag + ")."); |
|
29 |
|
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 } |
|
37 |
|
38 function checkIfDestroyed(aTag) { |
|
39 info("Checking if destruction is ok."); |
|
40 |
|
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 + ")."); |
|
47 |
|
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 } |
|
55 |
|
56 executeSoon(() => { |
|
57 checkIfInitialized(1); |
|
58 |
|
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 }); |
|
72 |
|
73 registerCleanupFunction(() => { |
|
74 checkIfDestroyed(1); |
|
75 |
|
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 } |