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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     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  */
     9 function test() {
    10   let monitor, reqMenu;
    11   initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
    12     info("Starting test... ");
    14     monitor = aMonitor;
    15     let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
    16     let { RequestsMenu, NetworkDetails } = NetMonitorView;
    17     reqMenu = RequestsMenu;
    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 }

mercurial