mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-30 14:17:36 -10:00
73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
"use strict";
|
|
|
|
const { Task } = require("devtools/shared/task");
|
|
|
|
function DebuggerPanel(iframeWindow, toolbox) {
|
|
this.panelWin = iframeWindow;
|
|
this.toolbox = toolbox;
|
|
}
|
|
|
|
DebuggerPanel.prototype = {
|
|
open: Task.async(function*() {
|
|
if (!this.toolbox.target.isRemote) {
|
|
yield this.toolbox.target.makeRemote();
|
|
}
|
|
|
|
yield this.panelWin.Debugger.bootstrap({
|
|
threadClient: this.toolbox.threadClient,
|
|
tabTarget: this.toolbox.target
|
|
});
|
|
|
|
this.isReady = true;
|
|
return this;
|
|
}),
|
|
|
|
_store: function() {
|
|
return this.panelWin.Debugger.store;
|
|
},
|
|
|
|
_getState: function() {
|
|
return this._store().getState();
|
|
},
|
|
|
|
_actions: function() {
|
|
return this.panelWin.Debugger.actions;
|
|
},
|
|
|
|
_selectors: function() {
|
|
return this.panelWin.Debugger.selectors;
|
|
},
|
|
|
|
getFrames: function() {
|
|
let frames = this._selectors().getFrames(this._getState());
|
|
|
|
// frames is an empty array when the debugger is not paused
|
|
if (!frames.toJS) {
|
|
return {
|
|
frames: [],
|
|
selected: -1
|
|
}
|
|
}
|
|
|
|
frames = frames.toJS();
|
|
const selectedFrame = this._selectors().getSelectedFrame(this._getState());
|
|
const selected = frames.findIndex(frame => frame.id == selectedFrame.id);
|
|
|
|
frames.forEach(frame => {
|
|
frame.actor = frame.id;
|
|
});
|
|
|
|
return { frames, selected };
|
|
},
|
|
|
|
destroy: function() {
|
|
this.panelWin.Debugger.destroy();
|
|
this.emit("destroyed");
|
|
}
|
|
};
|
|
|
|
exports.DebuggerPanel = DebuggerPanel;
|