Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 ***** */
11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
12 let HUD;
14 let outputItem;
16 function consoleOpened(aHud) {
17 HUD = aHud;
19 outputNode = HUD.outputNode;
21 browser.addEventListener("load", tabLoad2, true);
23 // Reload so we get some output in the console.
24 browser.contentWindow.location.reload();
25 }
27 function tabLoad2(aEvent) {
28 browser.removeEventListener(aEvent.type, tabLoad2, true);
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);
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 }
49 function networkPanelShown(aEvent) {
50 document.removeEventListener(aEvent.type, networkPanelShown, false);
52 info("networkPanelShown");
54 document.addEventListener("popupshown", networkPanelShowFailure, false);
56 // The network panel should not open for the second time.
57 EventUtils.sendMouseEvent({type: "mousedown"}, outputItem);
58 EventUtils.sendMouseEvent({type: "click"}, outputItem);
60 executeSoon(function() {
61 aEvent.target.addEventListener("popuphidden", networkPanelHidden, false);
62 aEvent.target.hidePopup();
63 });
64 }
66 function networkPanelShowFailure(aEvent) {
67 document.removeEventListener(aEvent.type, networkPanelShowFailure, false);
69 ok(false, "the network panel should not show");
70 }
72 function networkPanelHidden(aEvent) {
73 this.removeEventListener(aEvent.type, networkPanelHidden, false);
75 info("networkPanelHidden");
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);
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);
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);
96 executeSoon(function() {
97 document.removeEventListener("popupshown", networkPanelShowFailure, false);
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");
104 HUD.jsterm.once("variablesview-open", onVariablesViewOpen);
105 let outputItem = msg.querySelector(".message-body a");
106 ok(outputItem, "jsterm output message found");
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 }
115 function onVariablesViewOpen() {
116 info("onVariablesViewOpen");
118 executeSoon(function() {
119 HUD = outputItem = null;
120 executeSoon(finishTest);
121 });
122 }
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 }