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 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.SDKModel} | 7 * @extends {WebInspector.SDKModel} |
8 * @param {!WebInspector.Target} target | 8 * @param {!WebInspector.Target} target |
9 */ | 9 */ |
10 WebInspector.SubTargetsManager = function(target) | 10 WebInspector.SubTargetsManager = function(target) |
11 { | 11 { |
12 WebInspector.SDKModel.call(this, WebInspector.SubTargetsManager, target); | 12 WebInspector.SDKModel.call(this, 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._targets = new Map(); | 18 this._targets = 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.setWaitForDebuggerOnStart(true); | 22 this._agent.setWaitForDebuggerOnStart(true); |
| 23 this._agent.setAttachToFrames(Runtime.experiments.isEnabled("autoAttachToCro
ssProcessSubframes")); |
23 this._agent.enable(); | 24 this._agent.enable(); |
24 } | 25 } |
25 | 26 |
26 /** @enum {symbol} */ | 27 /** @enum {symbol} */ |
27 WebInspector.SubTargetsManager.Events = { | 28 WebInspector.SubTargetsManager.Events = { |
28 SubTargetAdded: Symbol("SubTargetAdded"), | 29 SubTargetAdded: Symbol("SubTargetAdded"), |
29 SubTargetRemoved: Symbol("SubTargetRemoved"), | 30 SubTargetRemoved: Symbol("SubTargetRemoved"), |
30 } | 31 } |
31 | 32 |
32 WebInspector.SubTargetsManager._TypeSymbol = Symbol("SubTargetType"); | 33 WebInspector.SubTargetsManager._TypeSymbol = Symbol("SubTargetType"); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 /** | 132 /** |
132 * @param {string} type | 133 * @param {string} type |
133 * @return {number} | 134 * @return {number} |
134 */ | 135 */ |
135 _capabilitiesForType: function(type) | 136 _capabilitiesForType: function(type) |
136 { | 137 { |
137 if (type === "worker") | 138 if (type === "worker") |
138 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab
ility.Log; | 139 return WebInspector.Target.Capability.JS | WebInspector.Target.Capab
ility.Log; |
139 if (type === "service_worker") | 140 if (type === "service_worker") |
140 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa
bility.Network | WebInspector.Target.Capability.Worker; | 141 return WebInspector.Target.Capability.Log | WebInspector.Target.Capa
bility.Network | WebInspector.Target.Capability.Worker; |
| 142 if (type === "iframe") |
| 143 return WebInspector.Target.Capability.Browser | WebInspector.Target.
Capability.DOM | |
| 144 WebInspector.Target.Capability.JS | WebInspector.Target.Capabili
ty.Log | |
| 145 WebInspector.Target.Capability.Network | WebInspector.Target.Cap
ability.Worker; |
141 return 0; | 146 return 0; |
142 }, | 147 }, |
143 | 148 |
144 /** | 149 /** |
145 * @param {string} targetId | 150 * @param {string} targetId |
146 * @param {string} type | 151 * @param {string} type |
147 * @param {string} url | 152 * @param {string} url |
148 * @param {boolean} waitingForDebugger | 153 * @param {boolean} waitingForDebugger |
149 */ | 154 */ |
150 _targetCreated: function(targetId, type, url, waitingForDebugger) | 155 _targetCreated: function(targetId, type, url, waitingForDebugger) |
151 { | 156 { |
152 var connection = new WebInspector.SubTargetConnection(this._agent, targe
tId); | 157 var connection = new WebInspector.SubTargetConnection(this._agent, targe
tId); |
153 this._connections.set(targetId, connection); | 158 this._connections.set(targetId, connection); |
154 | 159 |
155 var parsedURL = url.asParsedURL(); | 160 var targetName = ""; |
156 var targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
"#" + (++this._lastAnonymousTargetId); | 161 if (type !== "iframe") { |
| 162 var parsedURL = url.asParsedURL(); |
| 163 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
"#" + (++this._lastAnonymousTargetId); |
| 164 } |
157 var target = WebInspector.targetManager.createTarget(targetName, this._c
apabilitiesForType(type), connection, this.target()); | 165 var target = WebInspector.targetManager.createTarget(targetName, this._c
apabilitiesForType(type), connection, this.target()); |
158 target[WebInspector.SubTargetsManager._TypeSymbol] = type; | 166 target[WebInspector.SubTargetsManager._TypeSymbol] = type; |
159 target[WebInspector.SubTargetsManager._IdSymbol] = targetId; | 167 target[WebInspector.SubTargetsManager._IdSymbol] = targetId; |
160 this._targets.set(targetId, target); | 168 this._targets.set(targetId, target); |
161 | 169 |
162 // Only pause new worker if debugging SW - we are going through the paus
e on start checkbox. | 170 // Only pause new worker if debugging SW - we are going through the paus
e on start checkbox. |
163 var mainIsServiceWorker = !this.target().parentTarget() && this.target()
.hasWorkerCapability() && !this.target().hasBrowserCapability(); | 171 var mainIsServiceWorker = !this.target().parentTarget() && this.target()
.hasWorkerCapability() && !this.target().hasBrowserCapability(); |
164 if (mainIsServiceWorker && waitingForDebugger) | 172 if (mainIsServiceWorker && waitingForDebugger) |
165 target.debuggerAgent().pause(); | 173 target.debuggerAgent().pause(); |
166 target.runtimeAgent().runIfWaitingForDebugger(); | 174 target.runtimeAgent().runIfWaitingForDebugger(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 279 } |
272 | 280 |
273 /** | 281 /** |
274 * @constructor | 282 * @constructor |
275 * @param {!TargetAgent.TargetInfo} payload | 283 * @param {!TargetAgent.TargetInfo} payload |
276 */ | 284 */ |
277 WebInspector.TargetInfo = function(payload) | 285 WebInspector.TargetInfo = function(payload) |
278 { | 286 { |
279 this.id = payload.targetId; | 287 this.id = payload.targetId; |
280 this.url = payload.url; | 288 this.url = payload.url; |
281 if (payload.type !== "page" && payload.type !== "frame") { | 289 if (payload.type !== "page" && payload.type !== "iframe") { |
282 this.title = WebInspector.UIString("Worker: %s", this.url); | 290 this.title = WebInspector.UIString("Worker: %s", this.url); |
283 this.canActivate = false; | 291 this.canActivate = false; |
284 } else { | 292 } else { |
285 this.title = payload.title; | 293 this.title = payload.title; |
286 this.canActivate = true; | 294 this.canActivate = true; |
287 } | 295 } |
288 } | 296 } |
OLD | NEW |