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