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.

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

mercurial