-
Notifications
You must be signed in to change notification settings - Fork 7
/
target.js
61 lines (53 loc) · 2.09 KB
/
target.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* 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/. */
/* global alert, BrowserToolboxProcess, gDevTools, React, TargetFactory,
Toolbox */
"use strict";
const React = require("devtools/client/shared/vendor/react");
const { TargetFactory } = require("devtools/client/framework/target");
const { Toolbox } = require("devtools/client/framework/toolbox");
const { Services } = require("devtools/sham/services");
const { BrowserToolboxProcess } = require("devtools/client/framework/ToolboxProcess");
const { gDevTools } = require("devtools/client/framework/gDevTools");
const Strings = Services.strings.createBundle(
require("l10n/aboutdebugging.properties"));
exports.TargetComponent = React.createClass({
displayName: "TargetComponent",
debug() {
let client = this.props.client;
let target = this.props.target;
switch (target.type) {
case "extension":
BrowserToolboxProcess.init({ addonID: target.addonID });
break;
case "serviceworker":
// Fall through.
case "sharedworker":
// Fall through.
case "worker":
let workerActor = this.props.target.actorID;
client.attachWorker(workerActor, (response, workerClient) => {
gDevTools.showToolbox(TargetFactory.forWorker(workerClient),
"jsdebugger", Toolbox.HostType.WINDOW);
});
break;
default:
alert("Not implemented yet!");
}
},
render() {
let target = this.props.target;
return React.createElement("div", { className: "target" },
React.createElement("img", {
className: "target-icon",
src: target.icon }),
React.createElement("div", { className: "target-details" },
React.createElement("div", { className: "target-name" }, target.name),
React.createElement("div", { className: "target-url" }, target.url)
),
React.createElement("button", { onClick: this.debug },
Strings.GetStringFromName("debug"))
);
},
});