Files
firefox/devtools/client/aboutdebugging/components/Aboutdebugging.js
T
Julian Descottes 19fef9ac4c Bug 1411565 - about:debugging connect to remote runtime using url parameters;r=ochameau
This changeset adds basic remote connection functionality to about:debugging.
About:debugging can target a remote firefox instance if the host and port
parameters are passed as URL search params.

The feature is not explicitly exposed at the moment and there is no UI to
connect an instance, and no UI feedback when connected to a remote instance.

When connected, about:debugging should correctly list tabs, workers and addons
for the target instance of Firefox. Debugging features work for all supported
targets.

Known limitations:
- preferences are read from the local Firefox instance (multiprocess, addon
  debugging etc...). At the moment the remote instance must be manually
  correctly configured

MozReview-Commit-ID: DOekSCb96XC
2017-10-23 10:15:40 +02:00

121 lines
3.5 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/. */
/* eslint-env browser */
"use strict";
const { createFactory, Component } = require("devtools/client/shared/vendor/react");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const dom = require("devtools/client/shared/vendor/react-dom-factories");
const Services = require("Services");
const PanelMenu = createFactory(require("./PanelMenu"));
loader.lazyGetter(this, "AddonsPanel",
() => createFactory(require("./addons/Panel")));
loader.lazyGetter(this, "TabsPanel",
() => createFactory(require("./tabs/Panel")));
loader.lazyGetter(this, "WorkersPanel",
() => createFactory(require("./workers/Panel")));
loader.lazyRequireGetter(this, "DebuggerClient",
"devtools/shared/client/debugger-client", true);
loader.lazyRequireGetter(this, "Telemetry",
"devtools/client/shared/telemetry");
const Strings = Services.strings.createBundle(
"chrome://devtools/locale/aboutdebugging.properties");
const panels = [{
id: "addons",
name: Strings.GetStringFromName("addons"),
icon: "chrome://devtools/skin/images/debugging-addons.svg",
component: AddonsPanel
}, {
id: "tabs",
name: Strings.GetStringFromName("tabs"),
icon: "chrome://devtools/skin/images/debugging-tabs.svg",
component: TabsPanel
}, {
id: "workers",
name: Strings.GetStringFromName("workers"),
icon: "chrome://devtools/skin/images/debugging-workers.svg",
component: WorkersPanel
}];
const defaultPanelId = "addons";
class AboutDebuggingApp extends Component {
static get propTypes() {
return {
client: PropTypes.instanceOf(DebuggerClient).isRequired,
connect: PropTypes.object.isRequired,
telemetry: PropTypes.instanceOf(Telemetry).isRequired
};
}
constructor(props) {
super(props);
this.state = {
selectedPanelId: defaultPanelId
};
this.onHashChange = this.onHashChange.bind(this);
this.selectPanel = this.selectPanel.bind(this);
}
componentDidMount() {
window.addEventListener("hashchange", this.onHashChange);
this.onHashChange();
this.props.telemetry.toolOpened("aboutdebugging");
}
componentWillUnmount() {
window.removeEventListener("hashchange", this.onHashChange);
this.props.telemetry.toolClosed("aboutdebugging");
this.props.telemetry.destroy();
}
onHashChange() {
this.setState({
selectedPanelId: window.location.hash.substr(1) || defaultPanelId
});
}
selectPanel(panelId) {
window.location.hash = "#" + panelId;
}
render() {
let { client, connect } = this.props;
let { selectedPanelId } = this.state;
let selectPanel = this.selectPanel;
let selectedPanel = panels.find(p => p.id == selectedPanelId);
let panel;
if (selectedPanel) {
panel = selectedPanel.component({ client, connect, id: selectedPanel.id });
} else {
panel = (
dom.div({ className: "error-page" },
dom.h1({ className: "header-name" },
Strings.GetStringFromName("pageNotFound")
),
dom.h4({ className: "error-page-details" },
Strings.formatStringFromName("doesNotExist", [selectedPanelId], 1))
)
);
}
return dom.div({ className: "app" },
PanelMenu({ panels, selectedPanelId, selectPanel }),
dom.div({ className: "main-content" }, panel)
);
}
}
module.exports = AboutDebuggingApp;