1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_page-nav.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if page navigation ("close", "navigate", etc.) triggers an appropriate 1.9 + * action in the network monitor. 1.10 + */ 1.11 + 1.12 +function test() { 1.13 + initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.14 + info("Starting test... "); 1.15 + 1.16 + testNavigate(() => testNavigateBack(() => testClose(() => finish()))); 1.17 + 1.18 + function testNavigate(aCallback) { 1.19 + info("Navigating forward..."); 1.20 + 1.21 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { 1.22 + is(aDebuggee.location, SIMPLE_URL, 1.23 + "Target started navigating to the correct location."); 1.24 + 1.25 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { 1.26 + is(aDebuggee.location, NAVIGATE_URL, 1.27 + "Target finished navigating to the correct location."); 1.28 + 1.29 + aCallback(); 1.30 + }); 1.31 + }); 1.32 + 1.33 + aDebuggee.location = NAVIGATE_URL; 1.34 + } 1.35 + 1.36 + function testNavigateBack(aCallback) { 1.37 + info("Navigating backward..."); 1.38 + 1.39 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { 1.40 + is(aDebuggee.location, NAVIGATE_URL, 1.41 + "Target started navigating back to the previous location."); 1.42 + 1.43 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { 1.44 + is(aDebuggee.location, SIMPLE_URL, 1.45 + "Target finished navigating back to the previous location."); 1.46 + 1.47 + aCallback(); 1.48 + }); 1.49 + }); 1.50 + 1.51 + aDebuggee.location = SIMPLE_URL; 1.52 + } 1.53 + 1.54 + function testClose(aCallback) { 1.55 + info("Closing..."); 1.56 + 1.57 + aMonitor.once("destroyed", () => { 1.58 + ok(!aMonitor._controller.client, 1.59 + "There shouldn't be a client available after destruction."); 1.60 + ok(!aMonitor._controller.tabClient, 1.61 + "There shouldn't be a tabClient available after destruction."); 1.62 + ok(!aMonitor._controller.webConsoleClient, 1.63 + "There shouldn't be a webConsoleClient available after destruction."); 1.64 + 1.65 + aCallback(); 1.66 + }); 1.67 + 1.68 + removeTab(aTab); 1.69 + } 1.70 + }); 1.71 +}