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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | const gcli = require("gcli/index"); |
michael@0 | 8 | const EventEmitter = require("devtools/toolkit/event-emitter"); |
michael@0 | 9 | const { gDevTools } = require("resource:///modules/devtools/gDevTools.jsm"); |
michael@0 | 10 | |
michael@0 | 11 | const eventEmitter = new EventEmitter(); |
michael@0 | 12 | |
michael@0 | 13 | gDevTools.on("toolbox-ready", (e, toolbox) => { |
michael@0 | 14 | if (!toolbox.target) { |
michael@0 | 15 | return; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | let fireChangeForTab = () => { |
michael@0 | 19 | eventEmitter.emit("changed", toolbox.target.tab); |
michael@0 | 20 | }; |
michael@0 | 21 | |
michael@0 | 22 | toolbox.on("split-console", fireChangeForTab); |
michael@0 | 23 | toolbox.on("select", fireChangeForTab); |
michael@0 | 24 | |
michael@0 | 25 | toolbox.once("destroyed", () => { |
michael@0 | 26 | toolbox.off("split-console", fireChangeForTab); |
michael@0 | 27 | toolbox.off("select", fireChangeForTab); |
michael@0 | 28 | }); |
michael@0 | 29 | }); |
michael@0 | 30 | |
michael@0 | 31 | exports.items = [ |
michael@0 | 32 | { |
michael@0 | 33 | name: 'splitconsole', |
michael@0 | 34 | hidden: true, |
michael@0 | 35 | buttonId: "command-button-splitconsole", |
michael@0 | 36 | buttonClass: "command-button command-button-invertable", |
michael@0 | 37 | tooltipText: gcli.lookup("splitconsoleTooltip"), |
michael@0 | 38 | state: { |
michael@0 | 39 | isChecked: function(target) { |
michael@0 | 40 | let toolbox = gDevTools.getToolbox(target); |
michael@0 | 41 | return toolbox && toolbox.splitConsole; |
michael@0 | 42 | }, |
michael@0 | 43 | onChange: function(target, changeHandler) { |
michael@0 | 44 | eventEmitter.on("changed", changeHandler); |
michael@0 | 45 | }, |
michael@0 | 46 | offChange: function(target, changeHandler) { |
michael@0 | 47 | eventEmitter.off("changed", changeHandler); |
michael@0 | 48 | }, |
michael@0 | 49 | }, |
michael@0 | 50 | exec: function(args, context) { |
michael@0 | 51 | let target = context.environment.target; |
michael@0 | 52 | let toolbox = gDevTools.getToolbox(target); |
michael@0 | 53 | |
michael@0 | 54 | if (!toolbox) { |
michael@0 | 55 | return gDevTools.showToolbox(target, "inspector").then((toolbox) => { |
michael@0 | 56 | toolbox.toggleSplitConsole(); |
michael@0 | 57 | }); |
michael@0 | 58 | } else { |
michael@0 | 59 | toolbox.toggleSplitConsole(); |
michael@0 | 60 | } |
michael@0 | 61 | } |
michael@0 | 62 | }, |
michael@0 | 63 | { |
michael@0 | 64 | name: "console", |
michael@0 | 65 | description: gcli.lookup("consoleDesc"), |
michael@0 | 66 | manual: gcli.lookup("consoleManual") |
michael@0 | 67 | }, |
michael@0 | 68 | { |
michael@0 | 69 | name: "console clear", |
michael@0 | 70 | description: gcli.lookup("consoleclearDesc"), |
michael@0 | 71 | exec: function(args, context) { |
michael@0 | 72 | let toolbox = gDevTools.getToolbox(context.environment.target); |
michael@0 | 73 | if (toolbox == null) { |
michael@0 | 74 | return; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | let panel = toolbox.getPanel("webconsole"); |
michael@0 | 78 | if (panel == null) { |
michael@0 | 79 | return; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | panel.hud.jsterm.clearOutput(); |
michael@0 | 83 | } |
michael@0 | 84 | }, |
michael@0 | 85 | { |
michael@0 | 86 | name: "console close", |
michael@0 | 87 | description: gcli.lookup("consolecloseDesc"), |
michael@0 | 88 | exec: function(args, context) { |
michael@0 | 89 | return gDevTools.closeToolbox(context.environment.target); |
michael@0 | 90 | } |
michael@0 | 91 | }, |
michael@0 | 92 | { |
michael@0 | 93 | name: "console open", |
michael@0 | 94 | description: gcli.lookup("consoleopenDesc"), |
michael@0 | 95 | exec: function(args, context) { |
michael@0 | 96 | return gDevTools.showToolbox(context.environment.target, "webconsole"); |
michael@0 | 97 | } |
michael@0 | 98 | } |
michael@0 | 99 | ]; |