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: * Tests if the network monitor leaks on initialization and sudden destruction. michael@0: * You can also use this initialization format as a template for other tests. michael@0: */ michael@0: michael@0: function test() { michael@0: let monitor, reqMenu; michael@0: initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: monitor = aMonitor; michael@0: let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin; michael@0: let { RequestsMenu, NetworkDetails } = NetMonitorView; michael@0: reqMenu = RequestsMenu; michael@0: michael@0: Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); michael@0: content.location.reload(true); michael@0: }) michael@0: .then(() => { michael@0: return waitForNetworkEvents(monitor, 2); michael@0: }) michael@0: .then(() => { michael@0: is(reqMenu.itemCount, 2, michael@0: "The request menu should have two items at this point."); michael@0: }) michael@0: .then(() => { michael@0: content.location.reload(true); michael@0: return waitForNetworkEvents(monitor, 2); michael@0: }) michael@0: .then(() => { michael@0: // Since the reload clears the log, we still expect two requests in the log michael@0: is(reqMenu.itemCount, 2, michael@0: "The request menu should still have two items at this point."); michael@0: }) michael@0: .then(() => { michael@0: // Now we toggle the persistence logs on michael@0: Services.prefs.setBoolPref("devtools.webconsole.persistlog", true); michael@0: content.location.reload(true); michael@0: return waitForNetworkEvents(monitor, 2); michael@0: }) michael@0: .then(() => { michael@0: // Since we togged the persistence logs, we expect four items after the reload michael@0: is(reqMenu.itemCount, 4, michael@0: "The request menu should now have four items at this point."); michael@0: }) michael@0: .then(() => { michael@0: Services.prefs.setBoolPref("devtools.webconsole.persistlog", false); michael@0: return teardown(monitor).then(finish); michael@0: }); michael@0: }