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

mercurial