|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if the network monitor leaks on initialization and sudden destruction. |
|
6 * You can also use this initialization format as a template for other tests. |
|
7 */ |
|
8 |
|
9 function test() { |
|
10 let monitor, reqMenu; |
|
11 initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
12 info("Starting test... "); |
|
13 |
|
14 monitor = aMonitor; |
|
15 let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin; |
|
16 let { RequestsMenu, NetworkDetails } = NetMonitorView; |
|
17 reqMenu = RequestsMenu; |
|
18 |
|
19 Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); |
|
20 content.location.reload(true); |
|
21 }) |
|
22 .then(() => { |
|
23 return waitForNetworkEvents(monitor, 2); |
|
24 }) |
|
25 .then(() => { |
|
26 is(reqMenu.itemCount, 2, |
|
27 "The request menu should have two items at this point."); |
|
28 }) |
|
29 .then(() => { |
|
30 content.location.reload(true); |
|
31 return waitForNetworkEvents(monitor, 2); |
|
32 }) |
|
33 .then(() => { |
|
34 // Since the reload clears the log, we still expect two requests in the log |
|
35 is(reqMenu.itemCount, 2, |
|
36 "The request menu should still have two items at this point."); |
|
37 }) |
|
38 .then(() => { |
|
39 // Now we toggle the persistence logs on |
|
40 Services.prefs.setBoolPref("devtools.webconsole.persistlog", true); |
|
41 content.location.reload(true); |
|
42 return waitForNetworkEvents(monitor, 2); |
|
43 }) |
|
44 .then(() => { |
|
45 // Since we togged the persistence logs, we expect four items after the reload |
|
46 is(reqMenu.itemCount, 4, |
|
47 "The request menu should now have four items at this point."); |
|
48 }) |
|
49 .then(() => { |
|
50 Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); |
|
51 return teardown(monitor).then(finish); |
|
52 }); |
|
53 } |