|
1 /* vim:set ts=2 sw=2 sts=2 et: */ |
|
2 /* ***** BEGIN LICENSE BLOCK ***** |
|
3 * Any copyright is dedicated to the Public Domain. |
|
4 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
5 * |
|
6 * Contributor(s): |
|
7 * Mihai Șucan <mihai.sucan@gmail.com> |
|
8 * |
|
9 * ***** END LICENSE BLOCK ***** */ |
|
10 |
|
11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
|
12 let HUD; |
|
13 |
|
14 let outputItem; |
|
15 |
|
16 function consoleOpened(aHud) { |
|
17 HUD = aHud; |
|
18 |
|
19 outputNode = HUD.outputNode; |
|
20 |
|
21 browser.addEventListener("load", tabLoad2, true); |
|
22 |
|
23 // Reload so we get some output in the console. |
|
24 browser.contentWindow.location.reload(); |
|
25 } |
|
26 |
|
27 function tabLoad2(aEvent) { |
|
28 browser.removeEventListener(aEvent.type, tabLoad2, true); |
|
29 |
|
30 waitForMessages({ |
|
31 webconsole: HUD, |
|
32 messages: [{ |
|
33 text: "test-console.html", |
|
34 category: CATEGORY_NETWORK, |
|
35 severity: SEVERITY_LOG, |
|
36 }], |
|
37 }).then(([result]) => { |
|
38 let msg = [...result.matched][0]; |
|
39 outputItem = msg.querySelector(".message-body .url"); |
|
40 ok(outputItem, "found a network message"); |
|
41 document.addEventListener("popupshown", networkPanelShown, false); |
|
42 |
|
43 // Send the mousedown and click events such that the network panel opens. |
|
44 EventUtils.sendMouseEvent({type: "mousedown"}, outputItem); |
|
45 EventUtils.sendMouseEvent({type: "click"}, outputItem); |
|
46 }); |
|
47 } |
|
48 |
|
49 function networkPanelShown(aEvent) { |
|
50 document.removeEventListener(aEvent.type, networkPanelShown, false); |
|
51 |
|
52 info("networkPanelShown"); |
|
53 |
|
54 document.addEventListener("popupshown", networkPanelShowFailure, false); |
|
55 |
|
56 // The network panel should not open for the second time. |
|
57 EventUtils.sendMouseEvent({type: "mousedown"}, outputItem); |
|
58 EventUtils.sendMouseEvent({type: "click"}, outputItem); |
|
59 |
|
60 executeSoon(function() { |
|
61 aEvent.target.addEventListener("popuphidden", networkPanelHidden, false); |
|
62 aEvent.target.hidePopup(); |
|
63 }); |
|
64 } |
|
65 |
|
66 function networkPanelShowFailure(aEvent) { |
|
67 document.removeEventListener(aEvent.type, networkPanelShowFailure, false); |
|
68 |
|
69 ok(false, "the network panel should not show"); |
|
70 } |
|
71 |
|
72 function networkPanelHidden(aEvent) { |
|
73 this.removeEventListener(aEvent.type, networkPanelHidden, false); |
|
74 |
|
75 info("networkPanelHidden"); |
|
76 |
|
77 // The network panel should not show because this is a mouse event that starts |
|
78 // in a position and ends in another. |
|
79 EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4}, |
|
80 outputItem); |
|
81 EventUtils.sendMouseEvent({type: "click", clientX: 5, clientY: 6}, |
|
82 outputItem); |
|
83 |
|
84 // The network panel should not show because this is a middle-click. |
|
85 EventUtils.sendMouseEvent({type: "mousedown", button: 1}, |
|
86 outputItem); |
|
87 EventUtils.sendMouseEvent({type: "click", button: 1}, |
|
88 outputItem); |
|
89 |
|
90 // The network panel should not show because this is a right-click. |
|
91 EventUtils.sendMouseEvent({type: "mousedown", button: 2}, |
|
92 outputItem); |
|
93 EventUtils.sendMouseEvent({type: "click", button: 2}, |
|
94 outputItem); |
|
95 |
|
96 executeSoon(function() { |
|
97 document.removeEventListener("popupshown", networkPanelShowFailure, false); |
|
98 |
|
99 // Done with the network output. Now test the jsterm output and the property |
|
100 // panel. |
|
101 HUD.jsterm.execute("document", (msg) => { |
|
102 info("jsterm execute 'document' callback"); |
|
103 |
|
104 HUD.jsterm.once("variablesview-open", onVariablesViewOpen); |
|
105 let outputItem = msg.querySelector(".message-body a"); |
|
106 ok(outputItem, "jsterm output message found"); |
|
107 |
|
108 // Send the mousedown and click events such that the property panel opens. |
|
109 EventUtils.sendMouseEvent({type: "mousedown"}, outputItem); |
|
110 EventUtils.sendMouseEvent({type: "click"}, outputItem); |
|
111 }); |
|
112 }); |
|
113 } |
|
114 |
|
115 function onVariablesViewOpen() { |
|
116 info("onVariablesViewOpen"); |
|
117 |
|
118 executeSoon(function() { |
|
119 HUD = outputItem = null; |
|
120 executeSoon(finishTest); |
|
121 }); |
|
122 } |
|
123 |
|
124 function test() { |
|
125 addTab(TEST_URI); |
|
126 browser.addEventListener("load", function onLoad() { |
|
127 browser.removeEventListener("load", onLoad, true); |
|
128 openConsole(null, consoleOpened); |
|
129 }, true); |
|
130 } |
|
131 |