| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 SDK.SubTargetsManager = class extends SDK.SDKModel { | 7 SDK.SubTargetsManager = class extends SDK.SDKModel { |
| 8 /** | 8 /** |
| 9 * @param {!SDK.Target} target | 9 * @param {!SDK.Target} target |
| 10 */ | 10 */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 */ | 123 */ |
| 124 targetInfo(target) { | 124 targetInfo(target) { |
| 125 return target[SDK.SubTargetsManager._InfoSymbol] || null; | 125 return target[SDK.SubTargetsManager._InfoSymbol] || null; |
| 126 } | 126 } |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @param {string} type | 129 * @param {string} type |
| 130 * @return {number} | 130 * @return {number} |
| 131 */ | 131 */ |
| 132 _capabilitiesForType(type) { | 132 _capabilitiesForType(type) { |
| 133 if (type === 'worker') | 133 if (type === 'worker') { |
| 134 return SDK.Target.Capability.JS | SDK.Target.Capability.Log; | 134 var capabilities = SDK.Target.Capability.JS | SDK.Target.Capability.Log; |
| 135 var parentTargetInfo = this.targetInfo(this.target()); |
| 136 var mainIsServiceWorker = |
| 137 !this.target().parentTarget() && this.target().hasTargetCapability() &
& !this.target().hasJSCapability(); |
| 138 if ((parentTargetInfo && parentTargetInfo.type === 'service_worker') || ma
inIsServiceWorker) |
| 139 capabilities |= SDK.Target.Capability.Network; |
| 140 return capabilities; |
| 141 } |
| 135 if (type === 'service_worker') | 142 if (type === 'service_worker') |
| 136 return SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Tar
get.Capability.Target; | 143 return SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Tar
get.Capability.Target; |
| 137 if (type === 'iframe') { | 144 if (type === 'iframe') { |
| 138 return SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Tar
get.Capability.JS | | 145 return SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Tar
get.Capability.JS | |
| 139 SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target
.Capability.Target; | 146 SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target
.Capability.Target; |
| 140 } | 147 } |
| 141 if (type === 'node') | 148 if (type === 'node') |
| 142 return SDK.Target.Capability.JS; | 149 return SDK.Target.Capability.JS; |
| 143 return 0; | 150 return 0; |
| 144 } | 151 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 156 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' +
(++this._lastAnonymousTargetId); | 163 targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' +
(++this._lastAnonymousTargetId); |
| 157 } | 164 } |
| 158 var target = SDK.targetManager.createTarget( | 165 var target = SDK.targetManager.createTarget( |
| 159 targetName, this._capabilitiesForType(targetInfo.type), this._createConn
ection.bind(this, targetInfo.id), | 166 targetName, this._capabilitiesForType(targetInfo.type), this._createConn
ection.bind(this, targetInfo.id), |
| 160 this.target()); | 167 this.target()); |
| 161 target[SDK.SubTargetsManager._InfoSymbol] = targetInfo; | 168 target[SDK.SubTargetsManager._InfoSymbol] = targetInfo; |
| 162 this._attachedTargets.set(targetInfo.id, target); | 169 this._attachedTargets.set(targetInfo.id, target); |
| 163 | 170 |
| 164 // Only pause new worker if debugging SW - we are going through the pause on
start checkbox. | 171 // Only pause new worker if debugging SW - we are going through the pause on
start checkbox. |
| 165 var mainIsServiceWorker = | 172 var mainIsServiceWorker = |
| 166 !this.target().parentTarget() && this.target().hasTargetCapability() &&
!this.target().hasBrowserCapability(); | 173 !this.target().parentTarget() && this.target().hasTargetCapability() &&
!this.target().hasJSCapability(); |
| 167 if (mainIsServiceWorker && waitingForDebugger) | 174 if (mainIsServiceWorker && waitingForDebugger) |
| 168 target.debuggerAgent().pause(); | 175 target.debuggerAgent().pause(); |
| 169 target.runtimeAgent().runIfWaitingForDebugger(); | 176 target.runtimeAgent().runIfWaitingForDebugger(); |
| 170 } | 177 } |
| 171 | 178 |
| 172 /** | 179 /** |
| 173 * @param {string} targetId | 180 * @param {string} targetId |
| 174 * @param {!Protocol.InspectorBackend.Connection.Params} params | 181 * @param {!Protocol.InspectorBackend.Connection.Params} params |
| 175 * @return {!Protocol.InspectorBackend.Connection} | 182 * @return {!Protocol.InspectorBackend.Connection} |
| 176 */ | 183 */ |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 this.type = payload.type; | 358 this.type = payload.type; |
| 352 this.canActivate = this.type === 'page' || this.type === 'iframe'; | 359 this.canActivate = this.type === 'page' || this.type === 'iframe'; |
| 353 if (this.type === 'node') | 360 if (this.type === 'node') |
| 354 this.title = Common.UIString('Node: %s', this.url); | 361 this.title = Common.UIString('Node: %s', this.url); |
| 355 else if (this.type === 'page' || this.type === 'iframe') | 362 else if (this.type === 'page' || this.type === 'iframe') |
| 356 this.title = payload.title; | 363 this.title = payload.title; |
| 357 else | 364 else |
| 358 this.title = Common.UIString('Worker: %s', this.url); | 365 this.title = Common.UIString('Worker: %s', this.url); |
| 359 } | 366 } |
| 360 }; | 367 }; |
| OLD | NEW |