|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if keyboard and mouse navigation works in the network requests menu. |
|
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 { window, $, NetMonitorView } = aMonitor.panelWin; |
|
16 let { RequestsMenu } = NetMonitorView; |
|
17 |
|
18 RequestsMenu.lazyUpdate = false; |
|
19 |
|
20 waitForNetworkEvents(aMonitor, 2).then(() => { |
|
21 check(-1, false); |
|
22 |
|
23 EventUtils.sendKey("DOWN", window); |
|
24 check(0, true); |
|
25 EventUtils.sendKey("UP", window); |
|
26 check(0, true); |
|
27 |
|
28 EventUtils.sendKey("PAGE_DOWN", window); |
|
29 check(1, true); |
|
30 EventUtils.sendKey("PAGE_UP", window); |
|
31 check(0, true); |
|
32 |
|
33 EventUtils.sendKey("END", window); |
|
34 check(1, true); |
|
35 EventUtils.sendKey("HOME", window); |
|
36 check(0, true); |
|
37 |
|
38 aDebuggee.performRequests(18); |
|
39 return waitForNetworkEvents(aMonitor, 18); |
|
40 }) |
|
41 .then(() => { |
|
42 EventUtils.sendKey("DOWN", window); |
|
43 check(1, true); |
|
44 EventUtils.sendKey("DOWN", window); |
|
45 check(2, true); |
|
46 EventUtils.sendKey("UP", window); |
|
47 check(1, true); |
|
48 EventUtils.sendKey("UP", window); |
|
49 check(0, true); |
|
50 |
|
51 EventUtils.sendKey("PAGE_DOWN", window); |
|
52 check(4, true); |
|
53 EventUtils.sendKey("PAGE_DOWN", window); |
|
54 check(8, true); |
|
55 EventUtils.sendKey("PAGE_UP", window); |
|
56 check(4, true); |
|
57 EventUtils.sendKey("PAGE_UP", window); |
|
58 check(0, true); |
|
59 |
|
60 EventUtils.sendKey("HOME", window); |
|
61 check(0, true); |
|
62 EventUtils.sendKey("HOME", window); |
|
63 check(0, true); |
|
64 EventUtils.sendKey("PAGE_UP", window); |
|
65 check(0, true); |
|
66 EventUtils.sendKey("HOME", window); |
|
67 check(0, true); |
|
68 |
|
69 EventUtils.sendKey("END", window); |
|
70 check(19, true); |
|
71 EventUtils.sendKey("END", window); |
|
72 check(19, true); |
|
73 EventUtils.sendKey("PAGE_DOWN", window); |
|
74 check(19, true); |
|
75 EventUtils.sendKey("END", window); |
|
76 check(19, true); |
|
77 |
|
78 EventUtils.sendKey("PAGE_UP", window); |
|
79 check(15, true); |
|
80 EventUtils.sendKey("PAGE_UP", window); |
|
81 check(11, true); |
|
82 EventUtils.sendKey("UP", window); |
|
83 check(10, true); |
|
84 EventUtils.sendKey("UP", window); |
|
85 check(9, true); |
|
86 EventUtils.sendKey("PAGE_DOWN", window); |
|
87 check(13, true); |
|
88 EventUtils.sendKey("PAGE_DOWN", window); |
|
89 check(17, true); |
|
90 EventUtils.sendKey("PAGE_DOWN", window); |
|
91 check(19, true); |
|
92 EventUtils.sendKey("PAGE_DOWN", window); |
|
93 check(19, true); |
|
94 |
|
95 EventUtils.sendKey("HOME", window); |
|
96 check(0, true); |
|
97 EventUtils.sendKey("DOWN", window); |
|
98 check(1, true); |
|
99 EventUtils.sendKey("END", window); |
|
100 check(19, true); |
|
101 EventUtils.sendKey("DOWN", window); |
|
102 check(19, true); |
|
103 |
|
104 EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); |
|
105 check(-1, false); |
|
106 |
|
107 EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item")); |
|
108 check(0, true); |
|
109 |
|
110 teardown(aMonitor).then(finish); |
|
111 }); |
|
112 |
|
113 let count = 0; |
|
114 |
|
115 function check(aSelectedIndex, aPaneVisibility) { |
|
116 info("Performing check " + (count++) + "."); |
|
117 |
|
118 is(RequestsMenu.selectedIndex, aSelectedIndex, |
|
119 "The selected item in the requests menu was incorrect."); |
|
120 is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, |
|
121 "The network requests details pane visibility state was incorrect."); |
|
122 } |
|
123 |
|
124 aDebuggee.performRequests(2); |
|
125 }); |
|
126 } |