Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
"use strict";
6
7
var EXPORTED_SYMBOLS = ["DevTools"];
8
9
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
10
const { TargetFactory } = require("devtools/client/framework/target");
11
const { gDevTools } = require("devtools/client/framework/devtools");
12
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
13
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
14
15
async function getTargetForSelectedTab() {
16
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
17
let target = await TargetFactory.forTab(browserWindow.gBrowser.selectedTab);
18
return target;
19
}
20
21
function selectToolbox(toolbox) {
22
return toolbox.win.document.querySelector("#toolbox-container");
23
}
24
25
var DevTools = {
26
init(libDir) {
27
let panels = [
28
"options",
29
"webconsole",
30
"jsdebugger",
31
"styleeditor",
32
"performance",
33
"netmonitor",
34
];
35
36
panels.forEach(panel => {
37
this.configurations[panel] = {};
38
this.configurations[panel].applyConfig = async function() {
39
Services.prefs.setIntPref("devtools.toolbox.footer.height", 800);
40
let target = await getTargetForSelectedTab();
41
let toolbox = await gDevTools.showToolbox(target, panel, "bottom");
42
this.selectors = [selectToolbox.bind(null, toolbox)];
43
await new Promise(resolve => setTimeout(resolve, 500));
44
};
45
});
46
},
47
48
configurations: {
49
bottomToolbox: {
50
async applyConfig() {
51
Services.prefs.clearUserPref("devtools.toolbox.footer.height");
52
let target = await getTargetForSelectedTab();
53
let toolbox = await gDevTools.showToolbox(
54
target,
55
"inspector",
56
"bottom"
57
);
58
this.selectors = [selectToolbox.bind(null, toolbox)];
59
await new Promise(resolve => setTimeout(resolve, 1000));
60
},
61
},
62
sideToolbox: {
63
async applyConfig() {
64
let target = await getTargetForSelectedTab();
65
let toolbox = await gDevTools.showToolbox(target, "inspector", "right");
66
this.selectors = [selectToolbox.bind(null, toolbox)];
67
await new Promise(resolve => setTimeout(resolve, 500));
68
},
69
},
70
undockedToolbox: {
71
windowType: "devtools:toolbox",
72
async applyConfig() {
73
let target = await getTargetForSelectedTab();
74
let toolbox = await gDevTools.showToolbox(
75
target,
76
"inspector",
77
"window"
78
);
79
this.selectors = [selectToolbox.bind(null, toolbox)];
80
await new Promise(resolve => setTimeout(resolve, 500));
81
},
82
},
83
},
84
};