browser/devtools/webconsole/test/browser_webconsole_bug_594477_clickable_output.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_594477_clickable_output.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* ***** BEGIN LICENSE BLOCK *****
     1.6 + * Any copyright is dedicated to the Public Domain.
     1.7 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.8 + *
     1.9 + * Contributor(s):
    1.10 + *  Mihai Șucan <mihai.sucan@gmail.com>
    1.11 + *
    1.12 + * ***** END LICENSE BLOCK ***** */
    1.13 +
    1.14 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    1.15 +let HUD;
    1.16 +
    1.17 +let outputItem;
    1.18 +
    1.19 +function consoleOpened(aHud) {
    1.20 +  HUD = aHud;
    1.21 +
    1.22 +  outputNode = HUD.outputNode;
    1.23 +
    1.24 +  browser.addEventListener("load", tabLoad2, true);
    1.25 +
    1.26 +  // Reload so we get some output in the console.
    1.27 +  browser.contentWindow.location.reload();
    1.28 +}
    1.29 +
    1.30 +function tabLoad2(aEvent) {
    1.31 +  browser.removeEventListener(aEvent.type, tabLoad2, true);
    1.32 +
    1.33 +  waitForMessages({
    1.34 +    webconsole: HUD,
    1.35 +    messages: [{
    1.36 +      text: "test-console.html",
    1.37 +      category: CATEGORY_NETWORK,
    1.38 +      severity: SEVERITY_LOG,
    1.39 +    }],
    1.40 +  }).then(([result]) => {
    1.41 +    let msg = [...result.matched][0];
    1.42 +    outputItem = msg.querySelector(".message-body .url");
    1.43 +    ok(outputItem, "found a network message");
    1.44 +    document.addEventListener("popupshown", networkPanelShown, false);
    1.45 +
    1.46 +    // Send the mousedown and click events such that the network panel opens.
    1.47 +    EventUtils.sendMouseEvent({type: "mousedown"}, outputItem);
    1.48 +    EventUtils.sendMouseEvent({type: "click"}, outputItem);
    1.49 +  });
    1.50 +}
    1.51 +
    1.52 +function networkPanelShown(aEvent) {
    1.53 +  document.removeEventListener(aEvent.type, networkPanelShown, false);
    1.54 +
    1.55 +  info("networkPanelShown");
    1.56 +
    1.57 +  document.addEventListener("popupshown", networkPanelShowFailure, false);
    1.58 +
    1.59 +  // The network panel should not open for the second time.
    1.60 +  EventUtils.sendMouseEvent({type: "mousedown"}, outputItem);
    1.61 +  EventUtils.sendMouseEvent({type: "click"}, outputItem);
    1.62 +
    1.63 +  executeSoon(function() {
    1.64 +    aEvent.target.addEventListener("popuphidden", networkPanelHidden, false);
    1.65 +    aEvent.target.hidePopup();
    1.66 +  });
    1.67 +}
    1.68 +
    1.69 +function networkPanelShowFailure(aEvent) {
    1.70 +  document.removeEventListener(aEvent.type, networkPanelShowFailure, false);
    1.71 +
    1.72 +  ok(false, "the network panel should not show");
    1.73 +}
    1.74 +
    1.75 +function networkPanelHidden(aEvent) {
    1.76 +  this.removeEventListener(aEvent.type, networkPanelHidden, false);
    1.77 +
    1.78 +  info("networkPanelHidden");
    1.79 +
    1.80 +  // The network panel should not show because this is a mouse event that starts
    1.81 +  // in a position and ends in another.
    1.82 +  EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4},
    1.83 +    outputItem);
    1.84 +  EventUtils.sendMouseEvent({type: "click", clientX: 5, clientY: 6},
    1.85 +    outputItem);
    1.86 +
    1.87 +  // The network panel should not show because this is a middle-click.
    1.88 +  EventUtils.sendMouseEvent({type: "mousedown", button: 1},
    1.89 +    outputItem);
    1.90 +  EventUtils.sendMouseEvent({type: "click", button: 1},
    1.91 +    outputItem);
    1.92 +
    1.93 +  // The network panel should not show because this is a right-click.
    1.94 +  EventUtils.sendMouseEvent({type: "mousedown", button: 2},
    1.95 +    outputItem);
    1.96 +  EventUtils.sendMouseEvent({type: "click", button: 2},
    1.97 +    outputItem);
    1.98 +
    1.99 +  executeSoon(function() {
   1.100 +    document.removeEventListener("popupshown", networkPanelShowFailure, false);
   1.101 +
   1.102 +    // Done with the network output. Now test the jsterm output and the property
   1.103 +    // panel.
   1.104 +    HUD.jsterm.execute("document", (msg) => {
   1.105 +      info("jsterm execute 'document' callback");
   1.106 +
   1.107 +      HUD.jsterm.once("variablesview-open", onVariablesViewOpen);
   1.108 +      let outputItem = msg.querySelector(".message-body a");
   1.109 +      ok(outputItem, "jsterm output message found");
   1.110 +
   1.111 +      // Send the mousedown and click events such that the property panel opens.
   1.112 +      EventUtils.sendMouseEvent({type: "mousedown"}, outputItem);
   1.113 +      EventUtils.sendMouseEvent({type: "click"}, outputItem);
   1.114 +    });
   1.115 +  });
   1.116 +}
   1.117 +
   1.118 +function onVariablesViewOpen() {
   1.119 +  info("onVariablesViewOpen");
   1.120 +
   1.121 +  executeSoon(function() {
   1.122 +    HUD = outputItem = null;
   1.123 +    executeSoon(finishTest);
   1.124 +  });
   1.125 +}
   1.126 +
   1.127 +function test() {
   1.128 +  addTab(TEST_URI);
   1.129 +  browser.addEventListener("load", function onLoad() {
   1.130 +    browser.removeEventListener("load", onLoad, true);
   1.131 +    openConsole(null, consoleOpened);
   1.132 +  }, true);
   1.133 +}
   1.134 +

mercurial