michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let toolbox; michael@0: michael@0: function test() { michael@0: addTab("about:blank", function() { michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: gDevTools.showToolbox(target, "webconsole").then(testSelect); michael@0: }); michael@0: } michael@0: michael@0: let called = { michael@0: inspector: false, michael@0: webconsole: false, michael@0: styleeditor: false, michael@0: //jsdebugger: false, michael@0: } michael@0: michael@0: function testSelect(aToolbox) { michael@0: toolbox = aToolbox; michael@0: michael@0: info("Toolbox fired a `ready` event"); michael@0: michael@0: toolbox.on("select", selectCB); michael@0: michael@0: toolbox.selectTool("inspector"); michael@0: toolbox.selectTool("webconsole"); michael@0: toolbox.selectTool("styleeditor"); michael@0: //toolbox.selectTool("jsdebugger"); michael@0: } michael@0: michael@0: function selectCB(event, id) { michael@0: called[id] = true; michael@0: info("toolbox-select event from " + id); michael@0: michael@0: for (let tool in called) { michael@0: if (!called[tool]) { michael@0: return; michael@0: } michael@0: } michael@0: michael@0: ok(true, "All the tools fired a 'select event'"); michael@0: toolbox.off("select", selectCB); michael@0: michael@0: reselect(); michael@0: } michael@0: michael@0: function reselect() { michael@0: for (let tool in called) { michael@0: called[tool] = false; michael@0: } michael@0: michael@0: toolbox.once("inspector-selected", function() { michael@0: tidyUpIfAllCalled("inspector"); michael@0: }); michael@0: michael@0: toolbox.once("webconsole-selected", function() { michael@0: tidyUpIfAllCalled("webconsole"); michael@0: }); michael@0: michael@0: /* michael@0: toolbox.once("jsdebugger-selected", function() { michael@0: tidyUpIfAllCalled("jsdebugger"); michael@0: }); michael@0: */ michael@0: michael@0: toolbox.once("styleeditor-selected", function() { michael@0: tidyUpIfAllCalled("styleeditor"); michael@0: }); michael@0: michael@0: toolbox.selectTool("inspector"); michael@0: toolbox.selectTool("webconsole"); michael@0: toolbox.selectTool("styleeditor"); michael@0: //toolbox.selectTool("jsdebugger"); michael@0: } michael@0: michael@0: function tidyUpIfAllCalled(id) { michael@0: called[id] = true; michael@0: info("select event from " + id); michael@0: michael@0: for (let tool in called) { michael@0: if (!called[tool]) { michael@0: return; michael@0: } michael@0: } michael@0: michael@0: ok(true, "All the tools fired a {id}-selected event"); michael@0: tidyUp(); michael@0: } michael@0: michael@0: function tidyUp() { michael@0: toolbox.destroy(); michael@0: gBrowser.removeCurrentTab(); michael@0: michael@0: toolbox = null; michael@0: finish(); michael@0: }