browser/devtools/framework/test/browser_toolbox_select_event.js

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

mercurial