michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if page navigation ("close", "navigate", etc.) triggers an appropriate michael@0: * action in the network monitor. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: testNavigate(() => testNavigateBack(() => testClose(() => finish()))); michael@0: michael@0: function testNavigate(aCallback) { michael@0: info("Navigating forward..."); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { michael@0: is(aDebuggee.location, SIMPLE_URL, michael@0: "Target started navigating to the correct location."); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { michael@0: is(aDebuggee.location, NAVIGATE_URL, michael@0: "Target finished navigating to the correct location."); michael@0: michael@0: aCallback(); michael@0: }); michael@0: }); michael@0: michael@0: aDebuggee.location = NAVIGATE_URL; michael@0: } michael@0: michael@0: function testNavigateBack(aCallback) { michael@0: info("Navigating backward..."); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { michael@0: is(aDebuggee.location, NAVIGATE_URL, michael@0: "Target started navigating back to the previous location."); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { michael@0: is(aDebuggee.location, SIMPLE_URL, michael@0: "Target finished navigating back to the previous location."); michael@0: michael@0: aCallback(); michael@0: }); michael@0: }); michael@0: michael@0: aDebuggee.location = SIMPLE_URL; michael@0: } michael@0: michael@0: function testClose(aCallback) { michael@0: info("Closing..."); michael@0: michael@0: aMonitor.once("destroyed", () => { michael@0: ok(!aMonitor._controller.client, michael@0: "There shouldn't be a client available after destruction."); michael@0: ok(!aMonitor._controller.tabClient, michael@0: "There shouldn't be a tabClient available after destruction."); michael@0: ok(!aMonitor._controller.webConsoleClient, michael@0: "There shouldn't be a webConsoleClient available after destruction."); michael@0: michael@0: aCallback(); michael@0: }); michael@0: michael@0: removeTab(aTab); michael@0: } michael@0: }); michael@0: }