1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_persistent_logs.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if the network monitor leaks on initialization and sudden destruction. 1.9 + * You can also use this initialization format as a template for other tests. 1.10 + */ 1.11 + 1.12 +function test() { 1.13 + let monitor, reqMenu; 1.14 + initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.15 + info("Starting test... "); 1.16 + 1.17 + monitor = aMonitor; 1.18 + let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin; 1.19 + let { RequestsMenu, NetworkDetails } = NetMonitorView; 1.20 + reqMenu = RequestsMenu; 1.21 + 1.22 + Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); 1.23 + content.location.reload(true); 1.24 + }) 1.25 + .then(() => { 1.26 + return waitForNetworkEvents(monitor, 2); 1.27 + }) 1.28 + .then(() => { 1.29 + is(reqMenu.itemCount, 2, 1.30 + "The request menu should have two items at this point."); 1.31 + }) 1.32 + .then(() => { 1.33 + content.location.reload(true); 1.34 + return waitForNetworkEvents(monitor, 2); 1.35 + }) 1.36 + .then(() => { 1.37 + // Since the reload clears the log, we still expect two requests in the log 1.38 + is(reqMenu.itemCount, 2, 1.39 + "The request menu should still have two items at this point."); 1.40 + }) 1.41 + .then(() => { 1.42 + // Now we toggle the persistence logs on 1.43 + Services.prefs.setBoolPref("devtools.webconsole.persistlog", true); 1.44 + content.location.reload(true); 1.45 + return waitForNetworkEvents(monitor, 2); 1.46 + }) 1.47 + .then(() => { 1.48 + // Since we togged the persistence logs, we expect four items after the reload 1.49 + is(reqMenu.itemCount, 4, 1.50 + "The request menu should now have four items at this point."); 1.51 + }) 1.52 + .then(() => { 1.53 + Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); 1.54 + return teardown(monitor).then(finish); 1.55 + }); 1.56 +}