browser/devtools/netmonitor/test/browser_net_page-nav.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 page navigation ("close", "navigate", etc.) triggers an appropriate
     6  * action in the network monitor.
     7  */
     9 function test() {
    10   initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    11     info("Starting test... ");
    13     testNavigate(() => testNavigateBack(() => testClose(() => finish())));
    15     function testNavigate(aCallback) {
    16       info("Navigating forward...");
    18       aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
    19         is(aDebuggee.location, SIMPLE_URL,
    20           "Target started navigating to the correct location.");
    22         aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
    23           is(aDebuggee.location, NAVIGATE_URL,
    24             "Target finished navigating to the correct location.");
    26           aCallback();
    27         });
    28       });
    30       aDebuggee.location = NAVIGATE_URL;
    31     }
    33     function testNavigateBack(aCallback) {
    34       info("Navigating backward...");
    36       aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
    37         is(aDebuggee.location, NAVIGATE_URL,
    38           "Target started navigating back to the previous location.");
    40         aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
    41           is(aDebuggee.location, SIMPLE_URL,
    42             "Target finished navigating back to the previous location.");
    44           aCallback();
    45         });
    46       });
    48       aDebuggee.location = SIMPLE_URL;
    49     }
    51     function testClose(aCallback) {
    52       info("Closing...");
    54       aMonitor.once("destroyed", () => {
    55         ok(!aMonitor._controller.client,
    56           "There shouldn't be a client available after destruction.");
    57         ok(!aMonitor._controller.tabClient,
    58           "There shouldn't be a tabClient available after destruction.");
    59         ok(!aMonitor._controller.webConsoleClient,
    60           "There shouldn't be a webConsoleClient available after destruction.");
    62         aCallback();
    63       });
    65       removeTab(aTab);
    66     }
    67   });
    68 }

mercurial