|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if page navigation ("close", "navigate", etc.) triggers an appropriate |
|
6 * action in the network monitor. |
|
7 */ |
|
8 |
|
9 function test() { |
|
10 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
11 info("Starting test... "); |
|
12 |
|
13 testNavigate(() => testNavigateBack(() => testClose(() => finish()))); |
|
14 |
|
15 function testNavigate(aCallback) { |
|
16 info("Navigating forward..."); |
|
17 |
|
18 aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => { |
|
19 is(aDebuggee.location, SIMPLE_URL, |
|
20 "Target started navigating to the correct location."); |
|
21 |
|
22 aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => { |
|
23 is(aDebuggee.location, NAVIGATE_URL, |
|
24 "Target finished navigating to the correct location."); |
|
25 |
|
26 aCallback(); |
|
27 }); |
|
28 }); |
|
29 |
|
30 aDebuggee.location = NAVIGATE_URL; |
|
31 } |
|
32 |
|
33 function testNavigateBack(aCallback) { |
|
34 info("Navigating backward..."); |
|
35 |
|
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."); |
|
39 |
|
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."); |
|
43 |
|
44 aCallback(); |
|
45 }); |
|
46 }); |
|
47 |
|
48 aDebuggee.location = SIMPLE_URL; |
|
49 } |
|
50 |
|
51 function testClose(aCallback) { |
|
52 info("Closing..."); |
|
53 |
|
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."); |
|
61 |
|
62 aCallback(); |
|
63 }); |
|
64 |
|
65 removeTab(aTab); |
|
66 } |
|
67 }); |
|
68 } |