|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that checking/unchecking an event listener's group in the view will |
|
6 * cause the active thread to get updated with the new event breakpoints for |
|
7 * all children inside that group. |
|
8 */ |
|
9 |
|
10 const TAB_URL = EXAMPLE_URL + "doc_event-listeners-02.html"; |
|
11 |
|
12 function test() { |
|
13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
14 let gDebugger = aPanel.panelWin; |
|
15 let gView = gDebugger.DebuggerView; |
|
16 let gController = gDebugger.DebuggerController |
|
17 let gEvents = gView.EventListeners; |
|
18 let gBreakpoints = gController.Breakpoints; |
|
19 |
|
20 Task.spawn(function() { |
|
21 yield waitForSourceShown(aPanel, ".html"); |
|
22 |
|
23 let fetched = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_LISTENERS_FETCHED); |
|
24 gView.toggleInstrumentsPane({ visible: true, animated: false }, 1); |
|
25 yield fetched; |
|
26 |
|
27 testEventItem(0, false); |
|
28 testEventItem(1, false); |
|
29 testEventItem(2, false); |
|
30 testEventItem(3, false); |
|
31 testEventGroup("interactionEvents", false); |
|
32 testEventGroup("keyboardEvents", false); |
|
33 testEventGroup("mouseEvents", false); |
|
34 testEventArrays("keydown,click,change,keyup", ""); |
|
35 |
|
36 let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
|
37 EventUtils.sendMouseEvent({ type: "click" }, getGroupCheckboxNode("interactionEvents"), gDebugger); |
|
38 yield updated; |
|
39 |
|
40 testEventItem(0, false); |
|
41 testEventItem(1, false); |
|
42 testEventItem(2, true); |
|
43 testEventItem(3, false); |
|
44 testEventGroup("interactionEvents", true); |
|
45 testEventGroup("keyboardEvents", false); |
|
46 testEventGroup("mouseEvents", false); |
|
47 testEventArrays("keydown,click,change,keyup", "change"); |
|
48 |
|
49 let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
|
50 EventUtils.sendMouseEvent({ type: "click" }, getGroupCheckboxNode("interactionEvents"), gDebugger); |
|
51 yield updated; |
|
52 |
|
53 testEventItem(0, false); |
|
54 testEventItem(1, false); |
|
55 testEventItem(2, false); |
|
56 testEventItem(3, false); |
|
57 testEventGroup("interactionEvents", false); |
|
58 testEventGroup("keyboardEvents", false); |
|
59 testEventGroup("mouseEvents", false); |
|
60 testEventArrays("keydown,click,change,keyup", ""); |
|
61 |
|
62 let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
|
63 EventUtils.sendMouseEvent({ type: "click" }, getGroupCheckboxNode("keyboardEvents"), gDebugger); |
|
64 yield updated; |
|
65 |
|
66 testEventItem(0, true); |
|
67 testEventItem(1, false); |
|
68 testEventItem(2, false); |
|
69 testEventItem(3, true); |
|
70 testEventGroup("interactionEvents", false); |
|
71 testEventGroup("keyboardEvents", true); |
|
72 testEventGroup("mouseEvents", false); |
|
73 testEventArrays("keydown,click,change,keyup", "keydown,keyup"); |
|
74 |
|
75 let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED); |
|
76 EventUtils.sendMouseEvent({ type: "click" }, getGroupCheckboxNode("keyboardEvents"), gDebugger); |
|
77 yield updated; |
|
78 |
|
79 testEventItem(0, false); |
|
80 testEventItem(1, false); |
|
81 testEventItem(2, false); |
|
82 testEventItem(3, false); |
|
83 testEventGroup("interactionEvents", false); |
|
84 testEventGroup("keyboardEvents", false); |
|
85 testEventGroup("mouseEvents", false); |
|
86 testEventArrays("keydown,click,change,keyup", ""); |
|
87 |
|
88 yield ensureThreadClientState(aPanel, "resumed"); |
|
89 yield closeDebuggerAndFinish(aPanel); |
|
90 }); |
|
91 |
|
92 function getItemCheckboxNode(index) { |
|
93 return gEvents.items[index].target.parentNode |
|
94 .querySelector(".side-menu-widget-item-checkbox"); |
|
95 } |
|
96 |
|
97 function getGroupCheckboxNode(string) { |
|
98 return gEvents.widget._parent |
|
99 .querySelector(".side-menu-widget-group[name=" + gDebugger.L10N.getStr(string) + "]") |
|
100 .querySelector(".side-menu-widget-group-checkbox"); |
|
101 } |
|
102 |
|
103 function testEventItem(index, checked) { |
|
104 is(gEvents.attachments[index].checkboxState, checked, |
|
105 "The event at index " + index + " has the correct checkbox state."); |
|
106 is(getItemCheckboxNode(index).checked, checked, |
|
107 "The correct checkbox state is shown for this event."); |
|
108 } |
|
109 |
|
110 function testEventGroup(string, checked) { |
|
111 is(getGroupCheckboxNode(string).checked, checked, |
|
112 "The correct checkbox state is shown for the group " + string + "."); |
|
113 } |
|
114 |
|
115 function testEventArrays(all, checked) { |
|
116 is(gEvents.getAllEvents().toString(), all, |
|
117 "The getAllEvents() method returns the correct stuff."); |
|
118 is(gEvents.getCheckedEvents().toString(), checked, |
|
119 "The getCheckedEvents() method returns the correct stuff."); |
|
120 is(gBreakpoints.DOM.activeEventNames.toString(), checked, |
|
121 "The correct event names are listed as being active breakpoints."); |
|
122 } |
|
123 }); |
|
124 } |