browser/devtools/framework/test/browser_toolbox_select_event.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 let toolbox;
     6 function test() {
     7   addTab("about:blank", function() {
     8     let target = TargetFactory.forTab(gBrowser.selectedTab);
     9     gDevTools.showToolbox(target, "webconsole").then(testSelect);
    10   });
    11 }
    13 let called = {
    14   inspector: false,
    15   webconsole: false,
    16   styleeditor: false,
    17   //jsdebugger: false,
    18 }
    20 function testSelect(aToolbox) {
    21   toolbox = aToolbox;
    23   info("Toolbox fired a `ready` event");
    25   toolbox.on("select", selectCB);
    27   toolbox.selectTool("inspector");
    28   toolbox.selectTool("webconsole");
    29   toolbox.selectTool("styleeditor");
    30   //toolbox.selectTool("jsdebugger");
    31 }
    33 function selectCB(event, id) {
    34   called[id] = true;
    35   info("toolbox-select event from " + id);
    37   for (let tool in called) {
    38     if (!called[tool]) {
    39       return;
    40     }
    41   }
    43   ok(true, "All the tools fired a 'select event'");
    44   toolbox.off("select", selectCB);
    46   reselect();
    47 }
    49 function reselect() {
    50   for (let tool in called) {
    51     called[tool] = false;
    52   }
    54   toolbox.once("inspector-selected", function() {
    55     tidyUpIfAllCalled("inspector");
    56   });
    58   toolbox.once("webconsole-selected", function() {
    59     tidyUpIfAllCalled("webconsole");
    60   });
    62   /*
    63   toolbox.once("jsdebugger-selected", function() {
    64     tidyUpIfAllCalled("jsdebugger");
    65   });
    66   */
    68   toolbox.once("styleeditor-selected", function() {
    69     tidyUpIfAllCalled("styleeditor");
    70   });
    72   toolbox.selectTool("inspector");
    73   toolbox.selectTool("webconsole");
    74   toolbox.selectTool("styleeditor");
    75   //toolbox.selectTool("jsdebugger");
    76 }
    78 function tidyUpIfAllCalled(id) {
    79   called[id] = true;
    80   info("select event from " + id);
    82   for (let tool in called) {
    83     if (!called[tool]) {
    84       return;
    85     }
    86   }
    88   ok(true, "All the tools fired a {id}-selected event");
    89   tidyUp();
    90 }
    92 function tidyUp() {
    93   toolbox.destroy();
    94   gBrowser.removeCurrentTab();
    96   toolbox = null;
    97   finish();
    98 }

mercurial