зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1411920 - about:debugging to ES6 classes r=jdescottes
MozReview-Commit-ID: Js4NQoGfgtI --HG-- extra : rebase_source : 9c627a1010ade3290536fd30b72b2c789e3aa949
This commit is contained in:
Родитель
1c91386c90
Коммит
55f243558a
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createFactory, createClass, DOM: dom, PropTypes } =
|
||||
const { createFactory, Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -46,41 +46,46 @@ const panels = [{
|
|||
|
||||
const defaultPanelId = "addons";
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "AboutDebuggingApp",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
telemetry: PropTypes.instanceOf(Telemetry).isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class AboutDebuggingApp extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).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 } = this.props;
|
||||
|
@ -108,4 +113,6 @@ module.exports = createClass({
|
|||
dom.div({ className: "main-content" }, panel)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = AboutDebuggingApp;
|
||||
|
|
|
@ -4,21 +4,23 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "PanelHeader",
|
||||
|
||||
propTypes: {
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired
|
||||
},
|
||||
class PanelHeader extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
let { name, id } = this.props;
|
||||
|
||||
return dom.div({ className: "header" },
|
||||
dom.h1({ id, className: "header-name" }, name));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PanelHeader;
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, createFactory, DOM: dom, PropTypes } =
|
||||
const { Component, createFactory, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const PanelMenuEntry = createFactory(require("./PanelMenuEntry"));
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "PanelMenu",
|
||||
|
||||
propTypes: {
|
||||
panels: PropTypes.arrayOf(PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
icon: PropTypes.string.isRequired,
|
||||
component: PropTypes.func.isRequired
|
||||
})).isRequired,
|
||||
selectPanel: PropTypes.func.isRequired,
|
||||
selectedPanelId: PropTypes.string
|
||||
},
|
||||
class PanelMenu extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
panels: PropTypes.arrayOf(PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
icon: PropTypes.string.isRequired,
|
||||
component: PropTypes.func.isRequired
|
||||
})).isRequired,
|
||||
selectPanel: PropTypes.func.isRequired,
|
||||
selectedPanelId: PropTypes.string
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
let { panels, selectedPanelId, selectPanel } = this.props;
|
||||
|
@ -37,5 +37,7 @@ module.exports = createClass({
|
|||
|
||||
// "categories" id used for styling purposes
|
||||
return dom.div({ id: "categories", role: "tablist" }, panelLinks);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PanelMenu;
|
||||
|
|
|
@ -4,23 +4,28 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "PanelMenuEntry",
|
||||
class PanelMenuEntry extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
icon: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
selected: PropTypes.bool,
|
||||
selectPanel: PropTypes.func.isRequired
|
||||
};
|
||||
}
|
||||
|
||||
propTypes: {
|
||||
icon: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
selected: PropTypes.bool,
|
||||
selectPanel: PropTypes.func.isRequired
|
||||
},
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.onClick = this.onClick.bind(this);
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.props.selectPanel(this.props.id);
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { id, name, icon, selected } = this.props;
|
||||
|
@ -38,4 +43,6 @@ module.exports = createClass({
|
|||
dom.img({ className: "category-icon", src: icon, role: "presentation" }),
|
||||
dom.div({ className: "category-name" }, name));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = PanelMenuEntry;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -18,19 +18,19 @@ const LocaleCompare = (a, b) => {
|
|||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
};
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "TargetList",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
error: PropTypes.node,
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string,
|
||||
sort: PropTypes.bool,
|
||||
targetClass: PropTypes.func.isRequired,
|
||||
targets: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||
},
|
||||
class TargetList extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
error: PropTypes.node,
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string,
|
||||
sort: PropTypes.bool,
|
||||
targetClass: PropTypes.func.isRequired,
|
||||
targets: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
let { client, debugDisabled, error, targetClass, targets, sort } = this.props;
|
||||
|
@ -52,5 +52,7 @@ module.exports = createClass({
|
|||
|
||||
return dom.div({ id: this.props.id, className: "targets" },
|
||||
dom.h2(null, this.props.name), content);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TargetList;
|
||||
|
|
|
@ -11,7 +11,7 @@ loader.lazyImporter(this, "AddonManager",
|
|||
"resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
const { Cc, Ci } = require("chrome");
|
||||
const { createFactory, createClass, DOM: dom, PropTypes } =
|
||||
const { createFactory, Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
const AddonsInstallError = createFactory(require("./InstallError"));
|
||||
|
@ -22,24 +22,31 @@ const Strings = Services.strings.createBundle(
|
|||
const MORE_INFO_URL = "https://developer.mozilla.org/docs/Tools" +
|
||||
"/about:debugging#Enabling_add-on_debugging";
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "AddonsControls",
|
||||
|
||||
propTypes: {
|
||||
debugDisabled: PropTypes.bool
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class AddonsControls extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
debugDisabled: PropTypes.bool
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
installError: null,
|
||||
};
|
||||
},
|
||||
|
||||
this.onEnableAddonDebuggingChange = this.onEnableAddonDebuggingChange.bind(this);
|
||||
this.loadAddonFromFile = this.loadAddonFromFile.bind(this);
|
||||
this.retryInstall = this.retryInstall.bind(this);
|
||||
this.installAddon = this.installAddon.bind(this);
|
||||
}
|
||||
|
||||
onEnableAddonDebuggingChange(event) {
|
||||
let enabled = event.target.checked;
|
||||
Services.prefs.setBoolPref("devtools.chrome.enabled", enabled);
|
||||
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", enabled);
|
||||
},
|
||||
}
|
||||
|
||||
loadAddonFromFile() {
|
||||
this.setState({ installError: null });
|
||||
|
@ -60,12 +67,12 @@ module.exports = createClass({
|
|||
|
||||
this.installAddon(file);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
retryInstall() {
|
||||
this.setState({ installError: null });
|
||||
this.installAddon(this.state.lastInstallErrorFile);
|
||||
},
|
||||
}
|
||||
|
||||
installAddon(file) {
|
||||
AddonManager.installTemporaryAddon(file)
|
||||
|
@ -76,7 +83,7 @@ module.exports = createClass({
|
|||
console.error(e);
|
||||
this.setState({ installError: e.message, lastInstallErrorFile: file });
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { debugDisabled } = this.props;
|
||||
|
@ -110,4 +117,6 @@ module.exports = createClass({
|
|||
retryInstall: this.retryInstall,
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = AddonsControls;
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
/* eslint-env browser */
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } = require("devtools/client/shared/vendor/react");
|
||||
const { Component, DOM: dom, PropTypes } = require("devtools/client/shared/vendor/react");
|
||||
|
||||
const Services = require("Services");
|
||||
|
||||
const Strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/aboutdebugging.properties");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "AddonsInstallError",
|
||||
|
||||
propTypes: {
|
||||
error: PropTypes.string,
|
||||
retryInstall: PropTypes.func,
|
||||
},
|
||||
class AddonsInstallError extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
error: PropTypes.string,
|
||||
retryInstall: PropTypes.func,
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.error) {
|
||||
|
@ -36,4 +36,6 @@ module.exports = createClass({
|
|||
{ className: "addons-install-retry", onClick: this.props.retryInstall },
|
||||
Strings.GetStringFromName("retryTemporaryInstall")));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = AddonsInstallError;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
||||
const { Management } = require("resource://gre/modules/Extension.jsm");
|
||||
const { createFactory, createClass, DOM: dom, PropTypes } =
|
||||
const { createFactory, Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -27,20 +27,29 @@ const REMOTE_ENABLED_PREF = "devtools.debugger.remote-enabled";
|
|||
const WEB_EXT_URL = "https://developer.mozilla.org/Add-ons" +
|
||||
"/WebExtensions/Getting_started_with_web-ext";
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "AddonsPanel",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class AddonsPanel extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
extensions: [],
|
||||
debugDisabled: false,
|
||||
};
|
||||
},
|
||||
|
||||
this.updateDebugStatus = this.updateDebugStatus.bind(this);
|
||||
this.updateAddonsList = this.updateAddonsList.bind(this);
|
||||
this.onInstalled = this.onInstalled.bind(this);
|
||||
this.onUninstalled = this.onUninstalled.bind(this);
|
||||
this.onEnabled = this.onEnabled.bind(this);
|
||||
this.onDisabled = this.onDisabled.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
AddonManager.addAddonListener(this);
|
||||
|
@ -55,7 +64,7 @@ module.exports = createClass({
|
|||
|
||||
this.updateDebugStatus();
|
||||
this.updateAddonsList();
|
||||
},
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AddonManager.removeAddonListener(this);
|
||||
|
@ -65,7 +74,7 @@ module.exports = createClass({
|
|||
this.updateDebugStatus);
|
||||
Services.prefs.removeObserver(REMOTE_ENABLED_PREF,
|
||||
this.updateDebugStatus);
|
||||
},
|
||||
}
|
||||
|
||||
updateDebugStatus() {
|
||||
let debugDisabled =
|
||||
|
@ -73,7 +82,7 @@ module.exports = createClass({
|
|||
!Services.prefs.getBoolPref(REMOTE_ENABLED_PREF);
|
||||
|
||||
this.setState({ debugDisabled });
|
||||
},
|
||||
}
|
||||
|
||||
updateAddonsList() {
|
||||
this.props.client.listAddons()
|
||||
|
@ -95,35 +104,35 @@ module.exports = createClass({
|
|||
}, error => {
|
||||
throw new Error("Client error while listing addons: " + error);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Mandatory callback as AddonManager listener.
|
||||
*/
|
||||
onInstalled() {
|
||||
this.updateAddonsList();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Mandatory callback as AddonManager listener.
|
||||
*/
|
||||
onUninstalled() {
|
||||
this.updateAddonsList();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Mandatory callback as AddonManager listener.
|
||||
*/
|
||||
onEnabled() {
|
||||
this.updateAddonsList();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Mandatory callback as AddonManager listener.
|
||||
*/
|
||||
onDisabled() {
|
||||
this.updateAddonsList();
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { client, id } = this.props;
|
||||
|
@ -177,4 +186,6 @@ module.exports = createClass({
|
|||
})
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = AddonsPanel;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const { debugAddon, isTemporaryID, parseFileUri, uninstallAddon } =
|
||||
require("../../modules/addon");
|
||||
|
@ -122,32 +122,39 @@ function warningMessages(warnings = []) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "AddonTarget",
|
||||
class AddonTarget extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
addonActor: PropTypes.string.isRequired,
|
||||
addonID: PropTypes.string.isRequired,
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
temporarilyInstalled: PropTypes.bool,
|
||||
url: PropTypes.string,
|
||||
warnings: PropTypes.array,
|
||||
}).isRequired
|
||||
};
|
||||
}
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
addonActor: PropTypes.string.isRequired,
|
||||
addonID: PropTypes.string.isRequired,
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
temporarilyInstalled: PropTypes.bool,
|
||||
url: PropTypes.string,
|
||||
warnings: PropTypes.array,
|
||||
}).isRequired
|
||||
},
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.debug = this.debug.bind(this);
|
||||
this.uninstall = this.uninstall.bind(this);
|
||||
this.reload = this.reload.bind(this);
|
||||
}
|
||||
|
||||
debug() {
|
||||
let { target } = this.props;
|
||||
debugAddon(target.addonID);
|
||||
},
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
let { target } = this.props;
|
||||
uninstallAddon(target.addonID);
|
||||
},
|
||||
}
|
||||
|
||||
reload() {
|
||||
let { client, target } = this.props;
|
||||
|
@ -160,7 +167,7 @@ module.exports = createClass({
|
|||
throw new Error(
|
||||
"Error reloading addon " + target.addonID + ": " + error);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { target, debugDisabled } = this.props;
|
||||
|
@ -205,4 +212,6 @@ module.exports = createClass({
|
|||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = AddonTarget;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, createFactory, DOM: dom, PropTypes } =
|
||||
const { Component, createFactory, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -20,30 +20,34 @@ loader.lazyRequireGetter(this, "DebuggerClient",
|
|||
const Strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/aboutdebugging.properties");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "TabsPanel",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class TabsPanel extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
tabs: []
|
||||
};
|
||||
},
|
||||
|
||||
this.update = this.update.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let { client } = this.props;
|
||||
client.addListener("tabListChanged", this.update);
|
||||
this.update();
|
||||
},
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
let { client } = this.props;
|
||||
client.removeListener("tabListChanged", this.update);
|
||||
},
|
||||
}
|
||||
|
||||
update() {
|
||||
this.props.client.mainRoot.listTabs().then(({ tabs }) => {
|
||||
|
@ -68,7 +72,7 @@ module.exports = createClass({
|
|||
});
|
||||
this.setState({ tabs });
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { client, id } = this.props;
|
||||
|
@ -95,4 +99,6 @@ module.exports = createClass({
|
|||
})
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = TabsPanel;
|
||||
|
|
|
@ -6,29 +6,34 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
|
||||
const Strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/aboutdebugging.properties");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "TabTarget",
|
||||
class TabTarget extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
target: PropTypes.shape({
|
||||
icon: PropTypes.string,
|
||||
outerWindowID: PropTypes.number.isRequired,
|
||||
title: PropTypes.string,
|
||||
url: PropTypes.string.isRequired
|
||||
}).isRequired
|
||||
};
|
||||
}
|
||||
|
||||
propTypes: {
|
||||
target: PropTypes.shape({
|
||||
icon: PropTypes.string,
|
||||
outerWindowID: PropTypes.number.isRequired,
|
||||
title: PropTypes.string,
|
||||
url: PropTypes.string.isRequired
|
||||
}).isRequired
|
||||
},
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.debug = this.debug.bind(this);
|
||||
}
|
||||
|
||||
debug() {
|
||||
let { target } = this.props;
|
||||
window.open("about:devtools-toolbox?type=tab&id=" + target.outerWindowID);
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { target } = this.props;
|
||||
|
@ -50,4 +55,6 @@ module.exports = createClass({
|
|||
}, Strings.GetStringFromName("debug"))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = TabTarget;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
loader.lazyImporter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
const { createClass, DOM: dom } =
|
||||
const { Component, DOM: dom } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const Services = require("Services");
|
||||
const { Ci } = require("chrome");
|
||||
|
@ -22,8 +22,11 @@ loader.lazyRequireGetter(this, "DebuggerClient",
|
|||
const Strings = Services.strings.createBundle("chrome://devtools/locale/aboutdebugging.properties");
|
||||
const MULTI_OPT_OUT_PREF = "dom.ipc.multiOptOut";
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "multiE10SWarning",
|
||||
class multiE10SWarning extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.onUpdatePreferenceClick = this.onUpdatePreferenceClick.bind(this);
|
||||
}
|
||||
|
||||
onUpdatePreferenceClick() {
|
||||
let message = Strings.GetStringFromName("multiProcessWarningConfirmUpdate2");
|
||||
|
@ -34,7 +37,7 @@ module.exports = createClass({
|
|||
// Restart the browser.
|
||||
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
return dom.div(
|
||||
|
@ -58,5 +61,7 @@ module.exports = createClass({
|
|||
Strings.GetStringFromName("multiProcessWarningUpdateLink2")
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = multiE10SWarning;
|
||||
|
|
|
@ -8,7 +8,7 @@ loader.lazyImporter(this, "PrivateBrowsingUtils",
|
|||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const { createClass, createFactory, DOM: dom, PropTypes } =
|
||||
const { Component, createFactory, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const { getWorkerForms } = require("../../modules/worker");
|
||||
const Services = require("Services");
|
||||
|
@ -34,24 +34,25 @@ const MORE_INFO_URL = "https://developer.mozilla.org/en-US/docs/Tools/about%3Ade
|
|||
const PROCESS_COUNT_PREF = "dom.ipc.processCount";
|
||||
const MULTI_OPTOUT_PREF = "dom.ipc.multiOptOut";
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "WorkersPanel",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class WorkersPanel extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
workers: {
|
||||
service: [],
|
||||
shared: [],
|
||||
other: []
|
||||
},
|
||||
processCount: 1,
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
id: PropTypes.string.isRequired
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.updateMultiE10S = this.updateMultiE10S.bind(this);
|
||||
this.updateWorkers = this.updateWorkers.bind(this);
|
||||
this.getRegistrationForWorker = this.getRegistrationForWorker.bind(this);
|
||||
this.isE10S = this.isE10S.bind(this);
|
||||
this.renderServiceWorkersError = this.renderServiceWorkersError.bind(this);
|
||||
|
||||
this.state = this.initialState;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let client = this.props.client;
|
||||
|
@ -77,7 +78,7 @@ module.exports = createClass({
|
|||
|
||||
this.updateMultiE10S();
|
||||
this.updateWorkers();
|
||||
},
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
let client = this.props.client;
|
||||
|
@ -88,17 +89,28 @@ module.exports = createClass({
|
|||
|
||||
Services.prefs.removeObserver(PROCESS_COUNT_PREF, this.updateMultiE10S);
|
||||
Services.prefs.removeObserver(MULTI_OPTOUT_PREF, this.updateMultiE10S);
|
||||
},
|
||||
}
|
||||
|
||||
get initialState() {
|
||||
return {
|
||||
workers: {
|
||||
service: [],
|
||||
shared: [],
|
||||
other: []
|
||||
},
|
||||
processCount: 1,
|
||||
};
|
||||
}
|
||||
|
||||
updateMultiE10S() {
|
||||
// We watch the pref but set the state based on
|
||||
// nsIXULRuntime.maxWebProcessCount.
|
||||
let processCount = Services.appinfo.maxWebProcessCount;
|
||||
this.setState({ processCount });
|
||||
},
|
||||
}
|
||||
|
||||
updateWorkers() {
|
||||
let workers = this.getInitialState().workers;
|
||||
let workers = this.initialState.workers;
|
||||
|
||||
getWorkerForms(this.props.client).then(forms => {
|
||||
forms.registrations.forEach(form => {
|
||||
|
@ -156,7 +168,7 @@ module.exports = createClass({
|
|||
|
||||
this.setState({ workers });
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getRegistrationForWorker(form, registrations) {
|
||||
for (let registration of registrations) {
|
||||
|
@ -165,11 +177,11 @@ module.exports = createClass({
|
|||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
}
|
||||
|
||||
isE10S() {
|
||||
return Services.appinfo.browserTabsRemoteAutostart;
|
||||
},
|
||||
}
|
||||
|
||||
renderServiceWorkersError() {
|
||||
let isWindowPrivate = PrivateBrowsingUtils.isContentWindowPrivate(window);
|
||||
|
@ -200,7 +212,7 @@ module.exports = createClass({
|
|||
Strings.GetStringFromName("configurationIsNotCompatible.learnMore")
|
||||
),
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { client, id } = this.props;
|
||||
|
@ -255,4 +267,6 @@ module.exports = createClass({
|
|||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = WorkersPanel;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const { debugWorker } = require("../../modules/worker");
|
||||
const Services = require("Services");
|
||||
|
@ -17,36 +17,50 @@ loader.lazyRequireGetter(this, "DebuggerClient",
|
|||
const Strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/aboutdebugging.properties");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "ServiceWorkerTarget",
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
active: PropTypes.bool,
|
||||
fetch: PropTypes.bool.isRequired,
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
url: PropTypes.string,
|
||||
scope: PropTypes.string.isRequired,
|
||||
// registrationActor can be missing in e10s.
|
||||
registrationActor: PropTypes.string,
|
||||
workerActor: PropTypes.string
|
||||
}).isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
class ServiceWorkerTarget extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
active: PropTypes.bool,
|
||||
fetch: PropTypes.bool.isRequired,
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
url: PropTypes.string,
|
||||
scope: PropTypes.string.isRequired,
|
||||
// registrationActor can be missing in e10s.
|
||||
registrationActor: PropTypes.string,
|
||||
workerActor: PropTypes.string
|
||||
}).isRequired
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
pushSubscription: null
|
||||
};
|
||||
},
|
||||
|
||||
this.debug = this.debug.bind(this);
|
||||
this.push = this.push.bind(this);
|
||||
this.start = this.start.bind(this);
|
||||
this.unregister = this.unregister.bind(this);
|
||||
this.onPushSubscriptionModified = this.onPushSubscriptionModified.bind(this);
|
||||
this.updatePushSubscription = this.updatePushSubscription.bind(this);
|
||||
this.isRunning = this.isRunning.bind(this);
|
||||
this.isActive = this.isActive.bind(this);
|
||||
this.getServiceWorkerStatus = this.getServiceWorkerStatus.bind(this);
|
||||
this.renderButtons = this.renderButtons.bind(this);
|
||||
this.renderUnregisterLink = this.renderUnregisterLink.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let { client } = this.props;
|
||||
client.addListener("push-subscription-modified", this.onPushSubscriptionModified);
|
||||
this.updatePushSubscription();
|
||||
},
|
||||
}
|
||||
|
||||
componentDidUpdate(oldProps, oldState) {
|
||||
let wasActive = oldProps.target.active;
|
||||
|
@ -56,12 +70,12 @@ module.exports = createClass({
|
|||
// subscription change by updating it now.
|
||||
this.updatePushSubscription();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
let { client } = this.props;
|
||||
client.removeListener("push-subscription-modified", this.onPushSubscriptionModified);
|
||||
},
|
||||
}
|
||||
|
||||
debug() {
|
||||
if (!this.isRunning()) {
|
||||
|
@ -71,7 +85,7 @@ module.exports = createClass({
|
|||
|
||||
let { client, target } = this.props;
|
||||
debugWorker(client, target.workerActor);
|
||||
},
|
||||
}
|
||||
|
||||
push() {
|
||||
if (!this.isActive() || !this.isRunning()) {
|
||||
|
@ -86,7 +100,7 @@ module.exports = createClass({
|
|||
to: target.workerActor,
|
||||
type: "push"
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
start() {
|
||||
if (!this.isActive() || this.isRunning()) {
|
||||
|
@ -99,7 +113,7 @@ module.exports = createClass({
|
|||
to: target.registrationActor,
|
||||
type: "start"
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
unregister() {
|
||||
let { client, target } = this.props;
|
||||
|
@ -107,14 +121,14 @@ module.exports = createClass({
|
|||
to: target.registrationActor,
|
||||
type: "unregister"
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
onPushSubscriptionModified(type, data) {
|
||||
let { target } = this.props;
|
||||
if (data.from === target.registrationActor) {
|
||||
this.updatePushSubscription();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
updatePushSubscription() {
|
||||
if (!this.props.target.registrationActor) {
|
||||
|
@ -129,16 +143,16 @@ module.exports = createClass({
|
|||
}, ({ subscription }) => {
|
||||
this.setState({ pushSubscription: subscription });
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
isRunning() {
|
||||
// We know the target is running if it has a worker actor.
|
||||
return !!this.props.target.workerActor;
|
||||
},
|
||||
}
|
||||
|
||||
isActive() {
|
||||
return this.props.target.active;
|
||||
},
|
||||
}
|
||||
|
||||
getServiceWorkerStatus() {
|
||||
if (this.isActive() && this.isRunning()) {
|
||||
|
@ -150,7 +164,7 @@ module.exports = createClass({
|
|||
// ACTIVE state. Unable to know the actual state ("installing", "waiting"), we
|
||||
// display a custom state "registering" for now. See Bug 1153292.
|
||||
return "registering";
|
||||
},
|
||||
}
|
||||
|
||||
renderButtons() {
|
||||
let pushButton = dom.button({
|
||||
|
@ -179,7 +193,7 @@ module.exports = createClass({
|
|||
return debugButton;
|
||||
}
|
||||
return startButton;
|
||||
},
|
||||
}
|
||||
|
||||
renderUnregisterLink() {
|
||||
if (!this.isActive()) {
|
||||
|
@ -191,7 +205,7 @@ module.exports = createClass({
|
|||
onClick: this.unregister,
|
||||
className: "unregister-link",
|
||||
}, Strings.GetStringFromName("unregister"));
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { target } = this.props;
|
||||
|
@ -240,4 +254,6 @@ module.exports = createClass({
|
|||
this.renderButtons()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ServiceWorkerTarget;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { createClass, DOM: dom, PropTypes } =
|
||||
const { Component, DOM: dom, PropTypes } =
|
||||
require("devtools/client/shared/vendor/react");
|
||||
const { debugWorker } = require("../../modules/worker");
|
||||
const Services = require("Services");
|
||||
|
@ -17,23 +17,28 @@ loader.lazyRequireGetter(this, "DebuggerClient",
|
|||
const Strings = Services.strings.createBundle(
|
||||
"chrome://devtools/locale/aboutdebugging.properties");
|
||||
|
||||
module.exports = createClass({
|
||||
displayName: "WorkerTarget",
|
||||
class WorkerTarget extends Component {
|
||||
static get propTypes() {
|
||||
return {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
workerActor: PropTypes.string
|
||||
}).isRequired
|
||||
};
|
||||
}
|
||||
|
||||
propTypes: {
|
||||
client: PropTypes.instanceOf(DebuggerClient).isRequired,
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
workerActor: PropTypes.string
|
||||
}).isRequired
|
||||
},
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.debug = this.debug.bind(this);
|
||||
}
|
||||
|
||||
debug() {
|
||||
let { client, target } = this.props;
|
||||
debugWorker(client, target.workerActor);
|
||||
},
|
||||
}
|
||||
|
||||
render() {
|
||||
let { target, debugDisabled } = this.props;
|
||||
|
@ -54,4 +59,6 @@ module.exports = createClass({
|
|||
}, Strings.GetStringFromName("debug"))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = WorkerTarget;
|
||||
|
|
Загрузка…
Ссылка в новой задаче