Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// The build method should return a panel instance, so events can
// be fired with the panel as an argument. However, in order to keep
// backward compatibility with existing extensions do a check
// for a promise return value.
let built = definition.build(iframe.contentWindow, this);
if (!(built instanceof Promise)) {
let panel = built;
iframe.panel = panel;
// The panel instance is expected to fire (and listen to) various
// framework events, so make sure it's properly decorated with
// appropriate API (on, off, once, emit).
// In this case we decorate panel instances directly returned by
// the tool definition 'build' method.
if (typeof panel.emit == "undefined") {
EventEmitter.decorate(panel);
}
gDevTools.emit(id + "-build", this, panel);
this.emit(id + "-build", panel);
// The panel can implement an 'open' method for asynchronous
// initialization sequence.
if (typeof panel.open == "function") {
built = panel.open();
} else {
let deferred = promise.defer();
deferred.resolve(panel);
built = deferred.promise;
}
}
// Wait till the panel is fully ready and fire 'ready' events.
// Already disabled scanners during a previous call
return;
}
for (let scanner of this._scanners) {
this._disableScanner(scanner);
}
},
_disableScanner(scanner) {
scanner.off("runtime-list-updated", this._emitUpdated);
scanner.disable();
},
};
EventEmitter.decorate(RuntimeScanners);
exports.RuntimeScanners = RuntimeScanners;
/* SCANNERS */
var SimulatorScanner = {
_runtimes: [],
enable() {
this._updateRuntimes = this._updateRuntimes.bind(this);
Simulators.on("updated", this._updateRuntimes);
this._updateRuntimes();
},
disable() {
this._onBlur = this._onBlur.bind(this);
if (this.searchBox) {
this.searchBox.addEventListener("keydown", this._onKeyDown, true);
this.searchBox.addEventListener("command", this._onCommand, true);
this.searchBox.addEventListener("focus", this._onFocus, true);
this.searchBox.addEventListener("blur", this._onBlur, true);
this.autocompleter = new SelectorAutocompleter(inspector, input);
}
// For testing, we need to be able to wait for the most recent node request
// to finish. Tests can watch this promise for that.
this._lastQuery = promise.resolve(null);
EventEmitter.decorate(this);
}
function AbstractTreeItem({ parent, level }) {
this._rootItem = parent ? parent._rootItem : this;
this._parentItem = parent;
this._level = level || 0;
this._childTreeItems = [];
// Events are always propagated through the root item. Decorating every
// tree item as an event emitter is a very costly operation.
if (this == this._rootItem) {
EventEmitter.decorate(this);
}
}
function DebuggerTransport(socket) {
EventEmitter.decorate(this);
this._socket = socket;
// The current incoming (possibly partial) header, which will determine which
// type of Packet |_incoming| below will become.
this._incomingHeader = "";
// The current incoming Packet object
this._incoming = null;
// A queue of outgoing Packet objects
this._outgoing = [];
this.hooks = null;
this.active = false;
this._incomingEnabled = true;
this._outgoingEnabled = true;
disable() {
Devices.emit("adb-stop-polling");
},
scan() {
return promise.resolve();
},
listRuntimes: function() {
return [];
}
};
EventEmitter.decorate(LazyAdbScanner);
RuntimeScanners.add(LazyAdbScanner);
var WiFiScanner = {
_runtimes: [],
init() {
this.updateRegistration();
Services.prefs.addObserver(this.ALLOWED_PREF, this, false);
},
enable() {
this._updateRuntimes = this._updateRuntimes.bind(this);
discovery.on("devtools-device-added", this._updateRuntimes);
discovery.on("devtools-device-updated", this._updateRuntimes);
discovery.on("devtools-device-removed", this._updateRuntimes);
function LegacyTimelineFront (target) {
this._target = target;
EventEmitter.decorate(this);
}
this.panelWin = iframeWindow;
this.toolbox = toolbox;
this.isReady = false;
this._prefChanged = this._prefChanged.bind(this);
this._themeRegistered = this._themeRegistered.bind(this);
this._themeUnregistered = this._themeUnregistered.bind(this);
this._disableJSClicked = this._disableJSClicked.bind(this);
this.disableJSNode = this.panelDoc.getElementById("devtools-disable-javascript");
this._addListeners();
const EventEmitter = require("devtools/shared/event-emitter");
EventEmitter.decorate(this);
}
function TreeWidget(node, options={}) {
EventEmitter.decorate(this);
this.document = node.ownerDocument;
this.window = this.document.defaultView;
this._parent = node;
this.emptyText = options.emptyText || "";
this.defaultType = options.defaultType;
this.sorted = options.sorted !== false;
this.setupRoot();
this.placeholder = this.document.createElementNS(HTML_NS, "label");
this.placeholder.className = "tree-widget-empty-text";
this._parent.appendChild(this.placeholder);
if (this.emptyText) {
function ToolSidebar(tabbox, panel, uid, options={}) {
EventEmitter.decorate(this);
this._tabbox = tabbox;
this._tabboxTabs = tabbox.querySelector("tabs");
this._tabboxTabpanels = tabbox.querySelector("tabpanels");
this._uid = uid;
this._panelDoc = this._tabbox.ownerDocument;
this._toolPanel = panel;
this._options = options;
this._onTabBoxOverflow = this._onTabBoxOverflow.bind(this);
this._onTabBoxUnderflow = this._onTabBoxUnderflow.bind(this);
try {
this._width = Services.prefs.getIntPref("devtools.toolsidebar-width." + this._uid);
} catch(e) {}