|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if focus modifiers work for the SideMenuWidget. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 // It seems that this test may be slow on Ubuntu builds running on ec2. |
|
13 requestLongerTimeout(2); |
|
14 |
|
15 let { NetMonitorView } = aMonitor.panelWin; |
|
16 let { RequestsMenu } = NetMonitorView; |
|
17 |
|
18 RequestsMenu.lazyUpdate = false; |
|
19 |
|
20 waitForNetworkEvents(aMonitor, 2).then(() => { |
|
21 check(-1, false); |
|
22 |
|
23 RequestsMenu.focusLastVisibleItem(); |
|
24 check(1, true); |
|
25 RequestsMenu.focusFirstVisibleItem(); |
|
26 check(0, true); |
|
27 |
|
28 RequestsMenu.focusNextItem(); |
|
29 check(1, true); |
|
30 RequestsMenu.focusPrevItem(); |
|
31 check(0, true); |
|
32 |
|
33 RequestsMenu.focusItemAtDelta(+1); |
|
34 check(1, true); |
|
35 RequestsMenu.focusItemAtDelta(-1); |
|
36 check(0, true); |
|
37 |
|
38 RequestsMenu.focusItemAtDelta(+10); |
|
39 check(1, true); |
|
40 RequestsMenu.focusItemAtDelta(-10); |
|
41 check(0, true); |
|
42 |
|
43 aDebuggee.performRequests(18); |
|
44 return waitForNetworkEvents(aMonitor, 18); |
|
45 }) |
|
46 .then(() => { |
|
47 RequestsMenu.focusLastVisibleItem(); |
|
48 check(19, true); |
|
49 RequestsMenu.focusFirstVisibleItem(); |
|
50 check(0, true); |
|
51 |
|
52 RequestsMenu.focusNextItem(); |
|
53 check(1, true); |
|
54 RequestsMenu.focusPrevItem(); |
|
55 check(0, true); |
|
56 |
|
57 RequestsMenu.focusItemAtDelta(+10); |
|
58 check(10, true); |
|
59 RequestsMenu.focusItemAtDelta(-10); |
|
60 check(0, true); |
|
61 |
|
62 RequestsMenu.focusItemAtDelta(+100); |
|
63 check(19, true); |
|
64 RequestsMenu.focusItemAtDelta(-100); |
|
65 check(0, true); |
|
66 |
|
67 teardown(aMonitor).then(finish); |
|
68 }); |
|
69 |
|
70 let count = 0; |
|
71 |
|
72 function check(aSelectedIndex, aPaneVisibility) { |
|
73 info("Performing check " + (count++) + "."); |
|
74 |
|
75 is(RequestsMenu.selectedIndex, aSelectedIndex, |
|
76 "The selected item in the requests menu was incorrect."); |
|
77 is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, |
|
78 "The network requests details pane visibility state was incorrect."); |
|
79 } |
|
80 |
|
81 aDebuggee.performRequests(2); |
|
82 }); |
|
83 } |