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