OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | |
5 /** | 4 /** |
6 * @constructor | 5 * @unrestricted |
7 * @extends {WebInspector.SDKModel} | |
8 * @param {!WebInspector.Target} target | |
9 */ | 6 */ |
10 WebInspector.SubTargetsManager = function(target) | 7 WebInspector.SubTargetsManager = class extends WebInspector.SDKModel { |
11 { | 8 /** |
12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target); | 9 * @param {!WebInspector.Target} target |
| 10 */ |
| 11 constructor(target) { |
| 12 super(WebInspector.SubTargetsManager, target); |
13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this))
; | 13 target.registerTargetDispatcher(new WebInspector.SubTargetsDispatcher(this))
; |
14 this._lastAnonymousTargetId = 0; | 14 this._lastAnonymousTargetId = 0; |
15 this._agent = target.targetAgent(); | 15 this._agent = target.targetAgent(); |
16 | 16 |
17 /** @type {!Map<string, !WebInspector.Target>} */ | 17 /** @type {!Map<string, !WebInspector.Target>} */ |
18 this._attachedTargets = new Map(); | 18 this._attachedTargets = new Map(); |
19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ | 19 /** @type {!Map<string, !WebInspector.SubTargetConnection>} */ |
20 this._connections = new Map(); | 20 this._connections = new Map(); |
21 | 21 |
22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt
art */); | 22 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt
art */); |
23 if (Runtime.experiments.isEnabled("autoAttachToCrossProcessSubframes")) | 23 if (Runtime.experiments.isEnabled('autoAttachToCrossProcessSubframes')) |
24 this._agent.setAttachToFrames(true); | 24 this._agent.setAttachToFrames(true); |
25 | 25 |
26 if (Runtime.experiments.isEnabled("nodeDebugging") && !target.parentTarget()
) { | 26 if (Runtime.experiments.isEnabled('nodeDebugging') && !target.parentTarget()
) { |
27 var defaultLocations = [{host: "localhost", port: 9229}]; | 27 var defaultLocations = [{host: 'localhost', port: 9229}]; |
28 this._agent.setRemoteLocations(defaultLocations); | 28 this._agent.setRemoteLocations(defaultLocations); |
29 this._agent.setDiscoverTargets(true); | 29 this._agent.setDiscoverTargets(true); |
30 } | 30 } |
31 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.MainFrameNavigated, this._mainFrameNavigated, this); | 31 WebInspector.targetManager.addEventListener( |
| 32 WebInspector.TargetManager.Events.MainFrameNavigated, this._mainFrameNav
igated, this); |
| 33 } |
| 34 |
| 35 /** |
| 36 * @override |
| 37 * @return {!Promise} |
| 38 */ |
| 39 suspendModel() { |
| 40 var fulfill; |
| 41 var promise = new Promise(f => fulfill = f); |
| 42 this._agent.setAutoAttach(true /* autoAttach */, false /* waitForDebuggerOnS
tart */, fulfill); |
| 43 return promise; |
| 44 } |
| 45 |
| 46 /** |
| 47 * @override |
| 48 * @return {!Promise} |
| 49 */ |
| 50 resumeModel() { |
| 51 var fulfill; |
| 52 var promise = new Promise(f => fulfill = f); |
| 53 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebuggerOnSt
art */, fulfill); |
| 54 return promise; |
| 55 } |
| 56 |
| 57 /** |
| 58 * @override |
| 59 */ |
| 60 dispose() { |
| 61 for (var connection of this._connections.values()) { |
| 62 this._agent.detachFromTarget(connection._targetId); |
| 63 connection._onDisconnect.call(null, 'disposed'); |
| 64 } |
| 65 this._connections.clear(); |
| 66 this._attachedTargets.clear(); |
| 67 } |
| 68 |
| 69 /** |
| 70 * @param {!TargetAgent.TargetID} targetId |
| 71 */ |
| 72 activateTarget(targetId) { |
| 73 this._agent.activateTarget(targetId); |
| 74 } |
| 75 |
| 76 /** |
| 77 * @param {!TargetAgent.TargetID} targetId |
| 78 * @param {function(?WebInspector.TargetInfo)=} callback |
| 79 */ |
| 80 getTargetInfo(targetId, callback) { |
| 81 /** |
| 82 * @param {?Protocol.Error} error |
| 83 * @param {?TargetAgent.TargetInfo} targetInfo |
| 84 */ |
| 85 function innerCallback(error, targetInfo) { |
| 86 if (error) { |
| 87 console.error(error); |
| 88 callback(null); |
| 89 return; |
| 90 } |
| 91 if (targetInfo) |
| 92 callback(new WebInspector.TargetInfo(targetInfo)); |
| 93 else |
| 94 callback(null); |
| 95 } |
| 96 this._agent.getTargetInfo(targetId, innerCallback); |
| 97 } |
| 98 |
| 99 /** |
| 100 * @param {string} targetId |
| 101 * @return {?WebInspector.Target} |
| 102 */ |
| 103 targetForId(targetId) { |
| 104 return this._attachedTargets.get(targetId) || null; |
| 105 } |
| 106 |
| 107 /** |
| 108 * @param {!WebInspector.Target} target |
| 109 * @return {?WebInspector.TargetInfo} |
| 110 */ |
| 111 targetInfo(target) { |
| 112 return target[WebInspector.SubTargetsManager._InfoSymbol] || null; |
| 113 } |
| 114 |
| 115 /** |
| 116 * @param {string} type |
| 117 * @return {number} |
| 118 */ |
| 119 _capabilitiesForType(type) { |
| 120 if (type === 'worker') |
| 121 return WebInspector.Target.Capability.JS | WebInspector.Target.Capability.
Log; |
| 122 if (type === 'service_worker') |
| 123 return WebInspector.Target.Capability.Log | WebInspector.Target.Capability
.Network | |
| 124 WebInspector.Target.Capability.Target; |
| 125 if (type === 'iframe') |
| 126 return WebInspector.Target.Capability.Browser | WebInspector.Target.Capabi
lity.DOM | |
| 127 WebInspector.Target.Capability.JS | WebInspector.Target.Capability.Log
| |
| 128 WebInspector.Target.Capability.Network | WebInspector.Target.Capabilit
y.Target; |
| 129 if (type === 'node') |
| 130 return WebInspector.Target.Capability.JS; |
| 131 return 0; |
| 132 } |
| 133 |
| 134 /** |
| 135 * @param {!WebInspector.TargetInfo} targetInfo |
| 136 * @param {boolean} waitingForDebugger |
| 137 */ |
| 138 _attachedToTarget(targetInfo, waitingForDebugger) { |
| 139 var targetName = ''; |
| 140 if (targetInfo.type === 'node') { |
| 141 targetName = targetInfo.title; |
| 142 } else if (targetInfo.type !== 'iframe') { |
| 143 var parsedURL = targetInfo.url.asParsedURL(); |
| 144 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' +
(++this._lastAnonymousTargetId); |
| 145 } |
| 146 var target = WebInspector.targetManager.createTarget( |
| 147 targetName, this._capabilitiesForType(targetInfo.type), this._createConn
ection.bind(this, targetInfo.id), |
| 148 this.target()); |
| 149 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; |
| 150 this._attachedTargets.set(targetInfo.id, target); |
| 151 |
| 152 // Only pause new worker if debugging SW - we are going through the pause on
start checkbox. |
| 153 var mainIsServiceWorker = |
| 154 !this.target().parentTarget() && this.target().hasTargetCapability() &&
!this.target().hasBrowserCapability(); |
| 155 if (mainIsServiceWorker && waitingForDebugger) |
| 156 target.debuggerAgent().pause(); |
| 157 target.runtimeAgent().runIfWaitingForDebugger(); |
| 158 |
| 159 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubTarge
tAdded, target); |
| 160 } |
| 161 |
| 162 /** |
| 163 * @param {string} targetId |
| 164 * @param {!InspectorBackendClass.Connection.Params} params |
| 165 * @return {!InspectorBackendClass.Connection} |
| 166 */ |
| 167 _createConnection(targetId, params) { |
| 168 var connection = new WebInspector.SubTargetConnection(this._agent, targetId,
params); |
| 169 this._connections.set(targetId, connection); |
| 170 return connection; |
| 171 } |
| 172 |
| 173 /** |
| 174 * @param {string} targetId |
| 175 */ |
| 176 _detachedFromTarget(targetId) { |
| 177 var target = this._attachedTargets.get(targetId); |
| 178 this._attachedTargets.delete(targetId); |
| 179 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubTarge
tRemoved, target); |
| 180 var connection = this._connections.get(targetId); |
| 181 if (connection) |
| 182 connection._onDisconnect.call(null, 'target terminated'); |
| 183 this._connections.delete(targetId); |
| 184 } |
| 185 |
| 186 /** |
| 187 * @param {string} targetId |
| 188 * @param {string} message |
| 189 */ |
| 190 _receivedMessageFromTarget(targetId, message) { |
| 191 var connection = this._connections.get(targetId); |
| 192 if (connection) |
| 193 connection._onMessage.call(null, message); |
| 194 } |
| 195 |
| 196 /** |
| 197 * @param {!WebInspector.TargetInfo} targetInfo |
| 198 */ |
| 199 _targetCreated(targetInfo) { |
| 200 if (targetInfo.type !== 'node') |
| 201 return; |
| 202 this._agent.attachToTarget(targetInfo.id); |
| 203 } |
| 204 |
| 205 /** |
| 206 * @param {string} targetId |
| 207 */ |
| 208 _targetDestroyed(targetId) { |
| 209 // All the work is done in _detachedFromTarget. |
| 210 } |
| 211 |
| 212 /** |
| 213 * @param {!WebInspector.Event} event |
| 214 */ |
| 215 _mainFrameNavigated(event) { |
| 216 if (event.data.target() !== this.target()) |
| 217 return; |
| 218 |
| 219 var idsToDetach = []; |
| 220 for (var targetId of this._attachedTargets.keys()) { |
| 221 var target = this._attachedTargets.get(targetId); |
| 222 var targetInfo = this.targetInfo(target); |
| 223 if (targetInfo.type === 'worker') |
| 224 idsToDetach.push(targetId); |
| 225 } |
| 226 idsToDetach.forEach(id => this._detachedFromTarget(id)); |
| 227 } |
32 }; | 228 }; |
33 | 229 |
34 /** @enum {symbol} */ | 230 /** @enum {symbol} */ |
35 WebInspector.SubTargetsManager.Events = { | 231 WebInspector.SubTargetsManager.Events = { |
36 SubTargetAdded: Symbol("SubTargetAdded"), | 232 SubTargetAdded: Symbol('SubTargetAdded'), |
37 SubTargetRemoved: Symbol("SubTargetRemoved"), | 233 SubTargetRemoved: Symbol('SubTargetRemoved'), |
38 }; | 234 }; |
39 | 235 |
40 WebInspector.SubTargetsManager._InfoSymbol = Symbol("SubTargetInfo"); | 236 WebInspector.SubTargetsManager._InfoSymbol = Symbol('SubTargetInfo'); |
41 | |
42 WebInspector.SubTargetsManager.prototype = { | |
43 /** | |
44 * @override | |
45 * @return {!Promise} | |
46 */ | |
47 suspendModel: function() | |
48 { | |
49 var fulfill; | |
50 var promise = new Promise(f => fulfill = f); | |
51 this._agent.setAutoAttach(true /* autoAttach */, false /* waitForDebugge
rOnStart */, fulfill); | |
52 return promise; | |
53 }, | |
54 | |
55 /** | |
56 * @override | |
57 * @return {!Promise} | |
58 */ | |
59 resumeModel: function() | |
60 { | |
61 var fulfill; | |
62 var promise = new Promise(f => fulfill = f); | |
63 this._agent.setAutoAttach(true /* autoAttach */, true /* waitForDebugger
OnStart */, fulfill); | |
64 return promise; | |
65 }, | |
66 | |
67 /** | |
68 * @override | |
69 */ | |
70 dispose: function() | |
71 { | |
72 for (var connection of this._connections.values()) { | |
73 this._agent.detachFromTarget(connection._targetId); | |
74 connection._onDisconnect.call(null, "disposed"); | |
75 } | |
76 this._connections.clear(); | |
77 this._attachedTargets.clear(); | |
78 }, | |
79 | |
80 /** | |
81 * @param {!TargetAgent.TargetID} targetId | |
82 */ | |
83 activateTarget: function(targetId) | |
84 { | |
85 this._agent.activateTarget(targetId); | |
86 }, | |
87 | |
88 /** | |
89 * @param {!TargetAgent.TargetID} targetId | |
90 * @param {function(?WebInspector.TargetInfo)=} callback | |
91 */ | |
92 getTargetInfo: function(targetId, callback) | |
93 { | |
94 /** | |
95 * @param {?Protocol.Error} error | |
96 * @param {?TargetAgent.TargetInfo} targetInfo | |
97 */ | |
98 function innerCallback(error, targetInfo) | |
99 { | |
100 if (error) { | |
101 console.error(error); | |
102 callback(null); | |
103 return; | |
104 } | |
105 if (targetInfo) | |
106 callback(new WebInspector.TargetInfo(targetInfo)); | |
107 else | |
108 callback(null); | |
109 } | |
110 this._agent.getTargetInfo(targetId, innerCallback); | |
111 }, | |
112 | |
113 /** | |
114 * @param {string} targetId | |
115 * @return {?WebInspector.Target} | |
116 */ | |
117 targetForId: function(targetId) | |
118 { | |
119 return this._attachedTargets.get(targetId) || null; | |
120 }, | |
121 | |
122 /** | |
123 * @param {!WebInspector.Target} target | |
124 * @return {?WebInspector.TargetInfo} | |
125 */ | |
126 targetInfo: function(target) | |
127 { | |
128 return target[WebInspector.SubTargetsManager._InfoSymbol] || null; | |
129 }, | |
130 | |
131 /** | |
132 * @param {string} type | |
133 * @return {number} | |
134 */ | |
135 _capabilitiesForType: function(type) | |
136 { | |
137 if (type === "worker") | |
138 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab
ility.Log; | |
139 if (type === "service_worker") | |
140 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa
bility.Network | WebInspector.Target.Capability.Target; | |
141 if (type === "iframe") | |
142 return WebInspector.Target.Capability.Browser | WebInspector.Target.
Capability.DOM | | |
143 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili
ty.Log | | |
144 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Target; | |
145 if (type === "node") | |
146 return WebInspector.Target.Capability.JS; | |
147 return 0; | |
148 }, | |
149 | |
150 /** | |
151 * @param {!WebInspector.TargetInfo} targetInfo | |
152 * @param {boolean} waitingForDebugger | |
153 */ | |
154 _attachedToTarget: function(targetInfo, waitingForDebugger) | |
155 { | |
156 var targetName = ""; | |
157 if (targetInfo.type === "node") { | |
158 targetName = targetInfo.title; | |
159 } else if (targetInfo.type !== "iframe") { | |
160 var parsedURL = targetInfo.url.asParsedURL(); | |
161 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
"#" + (++this._lastAnonymousTargetId); | |
162 } | |
163 var target = WebInspector.targetManager.createTarget(targetName, this._c
apabilitiesForType(targetInfo.type), this._createConnection.bind(this, targetInf
o.id), this.target()); | |
164 target[WebInspector.SubTargetsManager._InfoSymbol] = targetInfo; | |
165 this._attachedTargets.set(targetInfo.id, target); | |
166 | |
167 // Only pause new worker if debugging SW - we are going through the paus
e on start checkbox. | |
168 var mainIsServiceWorker = !this.target().parentTarget() && this.target()
.hasTargetCapability() && !this.target().hasBrowserCapability(); | |
169 if (mainIsServiceWorker && waitingForDebugger) | |
170 target.debuggerAgent().pause(); | |
171 target.runtimeAgent().runIfWaitingForDebugger(); | |
172 | |
173 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT
argetAdded, target); | |
174 }, | |
175 | |
176 /** | |
177 * @param {string} targetId | |
178 * @param {!InspectorBackendClass.Connection.Params} params | |
179 * @return {!InspectorBackendClass.Connection} | |
180 */ | |
181 _createConnection: function(targetId, params) | |
182 { | |
183 var connection = new WebInspector.SubTargetConnection(this._agent, targe
tId, params); | |
184 this._connections.set(targetId, connection); | |
185 return connection; | |
186 }, | |
187 | |
188 /** | |
189 * @param {string} targetId | |
190 */ | |
191 _detachedFromTarget: function(targetId) | |
192 { | |
193 var target = this._attachedTargets.get(targetId); | |
194 this._attachedTargets.delete(targetId); | |
195 this.dispatchEventToListeners(WebInspector.SubTargetsManager.Events.SubT
argetRemoved, target); | |
196 var connection = this._connections.get(targetId); | |
197 if (connection) | |
198 connection._onDisconnect.call(null, "target terminated"); | |
199 this._connections.delete(targetId); | |
200 }, | |
201 | |
202 /** | |
203 * @param {string} targetId | |
204 * @param {string} message | |
205 */ | |
206 _receivedMessageFromTarget: function(targetId, message) | |
207 { | |
208 var connection = this._connections.get(targetId); | |
209 if (connection) | |
210 connection._onMessage.call(null, message); | |
211 }, | |
212 | |
213 /** | |
214 * @param {!WebInspector.TargetInfo} targetInfo | |
215 */ | |
216 _targetCreated: function(targetInfo) | |
217 { | |
218 if (targetInfo.type !== "node") | |
219 return; | |
220 this._agent.attachToTarget(targetInfo.id); | |
221 }, | |
222 | |
223 /** | |
224 * @param {string} targetId | |
225 */ | |
226 _targetDestroyed: function(targetId) | |
227 { | |
228 // All the work is done in _detachedFromTarget. | |
229 }, | |
230 | |
231 /** | |
232 * @param {!WebInspector.Event} event | |
233 */ | |
234 _mainFrameNavigated: function(event) | |
235 { | |
236 if (event.data.target() !== this.target()) | |
237 return; | |
238 | |
239 var idsToDetach = []; | |
240 for (var targetId of this._attachedTargets.keys()) { | |
241 var target = this._attachedTargets.get(targetId); | |
242 var targetInfo = this.targetInfo(target); | |
243 if (targetInfo.type === "worker") | |
244 idsToDetach.push(targetId); | |
245 } | |
246 idsToDetach.forEach(id => this._detachedFromTarget(id)); | |
247 }, | |
248 | |
249 __proto__: WebInspector.SDKModel.prototype | |
250 }; | |
251 | 237 |
252 /** | 238 /** |
253 * @constructor | |
254 * @implements {TargetAgent.Dispatcher} | 239 * @implements {TargetAgent.Dispatcher} |
255 * @param {!WebInspector.SubTargetsManager} manager | 240 * @unrestricted |
256 */ | 241 */ |
257 WebInspector.SubTargetsDispatcher = function(manager) | 242 WebInspector.SubTargetsDispatcher = class { |
258 { | 243 /** |
| 244 * @param {!WebInspector.SubTargetsManager} manager |
| 245 */ |
| 246 constructor(manager) { |
259 this._manager = manager; | 247 this._manager = manager; |
260 }; | 248 } |
261 | 249 |
262 WebInspector.SubTargetsDispatcher.prototype = { | 250 /** |
263 /** | 251 * @override |
264 * @override | 252 * @param {!TargetAgent.TargetInfo} targetInfo |
265 * @param {!TargetAgent.TargetInfo} targetInfo | 253 */ |
266 */ | 254 targetCreated(targetInfo) { |
267 targetCreated: function(targetInfo) | 255 this._manager._targetCreated(new WebInspector.TargetInfo(targetInfo)); |
268 { | 256 } |
269 this._manager._targetCreated(new WebInspector.TargetInfo(targetInfo)); | 257 |
270 }, | 258 /** |
271 | 259 * @override |
272 /** | 260 * @param {string} targetId |
273 * @override | 261 */ |
274 * @param {string} targetId | 262 targetDestroyed(targetId) { |
275 */ | 263 this._manager._targetDestroyed(targetId); |
276 targetDestroyed: function(targetId) | 264 } |
277 { | 265 |
278 this._manager._targetDestroyed(targetId); | 266 /** |
279 }, | 267 * @override |
280 | 268 * @param {!TargetAgent.TargetInfo} targetInfo |
281 /** | 269 * @param {boolean} waitingForDebugger |
282 * @override | 270 */ |
283 * @param {!TargetAgent.TargetInfo} targetInfo | 271 attachedToTarget(targetInfo, waitingForDebugger) { |
284 * @param {boolean} waitingForDebugger | 272 this._manager._attachedToTarget(new WebInspector.TargetInfo(targetInfo), wai
tingForDebugger); |
285 */ | 273 } |
286 attachedToTarget: function(targetInfo, waitingForDebugger) | 274 |
287 { | 275 /** |
288 this._manager._attachedToTarget(new WebInspector.TargetInfo(targetInfo),
waitingForDebugger); | 276 * @override |
289 }, | 277 * @param {string} targetId |
290 | 278 */ |
291 /** | 279 detachedFromTarget(targetId) { |
292 * @override | 280 this._manager._detachedFromTarget(targetId); |
293 * @param {string} targetId | 281 } |
294 */ | 282 |
295 detachedFromTarget: function(targetId) | 283 /** |
296 { | 284 * @override |
297 this._manager._detachedFromTarget(targetId); | 285 * @param {string} targetId |
298 }, | 286 * @param {string} message |
299 | 287 */ |
300 /** | 288 receivedMessageFromTarget(targetId, message) { |
301 * @override | 289 this._manager._receivedMessageFromTarget(targetId, message); |
302 * @param {string} targetId | 290 } |
303 * @param {string} message | |
304 */ | |
305 receivedMessageFromTarget: function(targetId, message) | |
306 { | |
307 this._manager._receivedMessageFromTarget(targetId, message); | |
308 } | |
309 }; | 291 }; |
310 | 292 |
311 /** | 293 /** |
312 * @constructor | |
313 * @implements {InspectorBackendClass.Connection} | 294 * @implements {InspectorBackendClass.Connection} |
314 * @param {!Protocol.TargetAgent} agent | 295 * @unrestricted |
315 * @param {string} targetId | |
316 * @param {!InspectorBackendClass.Connection.Params} params | |
317 */ | 296 */ |
318 WebInspector.SubTargetConnection = function(agent, targetId, params) | 297 WebInspector.SubTargetConnection = class { |
319 { | 298 /** |
| 299 * @param {!Protocol.TargetAgent} agent |
| 300 * @param {string} targetId |
| 301 * @param {!InspectorBackendClass.Connection.Params} params |
| 302 */ |
| 303 constructor(agent, targetId, params) { |
320 this._agent = agent; | 304 this._agent = agent; |
321 this._targetId = targetId; | 305 this._targetId = targetId; |
322 this._onMessage = params.onMessage; | 306 this._onMessage = params.onMessage; |
323 this._onDisconnect = params.onDisconnect; | 307 this._onDisconnect = params.onDisconnect; |
324 }; | 308 } |
325 | 309 |
326 WebInspector.SubTargetConnection.prototype = { | 310 /** |
327 /** | 311 * @override |
328 * @override | 312 * @param {string} message |
329 * @param {string} message | 313 */ |
330 */ | 314 sendMessage(message) { |
331 sendMessage: function(message) | 315 this._agent.sendMessageToTarget(this._targetId, message); |
332 { | 316 } |
333 this._agent.sendMessageToTarget(this._targetId, message); | 317 |
334 }, | 318 /** |
335 | 319 * @override |
336 /** | 320 * @return {!Promise} |
337 * @override | 321 */ |
338 * @return {!Promise} | 322 disconnect() { |
339 */ | 323 throw new Error('Not implemented'); |
340 disconnect: function() | 324 } |
341 { | |
342 throw new Error("Not implemented"); | |
343 }, | |
344 }; | 325 }; |
345 | 326 |
346 /** | 327 /** |
347 * @constructor | 328 * @unrestricted |
348 * @param {!TargetAgent.TargetInfo} payload | |
349 */ | 329 */ |
350 WebInspector.TargetInfo = function(payload) | 330 WebInspector.TargetInfo = class { |
351 { | 331 /** |
| 332 * @param {!TargetAgent.TargetInfo} payload |
| 333 */ |
| 334 constructor(payload) { |
352 this.id = payload.targetId; | 335 this.id = payload.targetId; |
353 this.url = payload.url; | 336 this.url = payload.url; |
354 this.type = payload.type; | 337 this.type = payload.type; |
355 this.canActivate = this.type === "page" || this.type === "iframe"; | 338 this.canActivate = this.type === 'page' || this.type === 'iframe'; |
356 if (this.type === "node") | 339 if (this.type === 'node') |
357 this.title = WebInspector.UIString("Node: %s", this.url); | 340 this.title = WebInspector.UIString('Node: %s', this.url); |
358 else if (this.type === "page" || this.type === "iframe") | 341 else if (this.type === 'page' || this.type === 'iframe') |
359 this.title = payload.title; | 342 this.title = payload.title; |
360 else | 343 else |
361 this.title = WebInspector.UIString("Worker: %s", this.url); | 344 this.title = WebInspector.UIString('Worker: %s', this.url); |
362 }; | 345 } |
| 346 }; |
OLD | NEW |