summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js')
-rw-r--r--chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js80
1 files changed, 30 insertions, 50 deletions
diff --git a/chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js b/chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js
index 559e26aa151..2af3af65392 100644
--- a/chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js
+++ b/chromium/third_party/blink/renderer/devtools/front_end/sdk/ChildTargetManager.js
@@ -17,20 +17,20 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
/** @type {!Map<string, !Protocol.Target.TargetInfo>} */
this._targetInfos = new Map();
- /** @type {!Map<string, !SDK.ChildConnection>} */
- this._childConnections = new Map();
+ /** @type {!Map<string, !SDK.Target>} */
+ this._childTargets = new Map();
parentTarget.registerTargetDispatcher(this);
- this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true});
+ this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
- if (!parentTarget.parentTarget()) {
+ if (!parentTarget.parentTarget() && !Host.isUnderTest()) {
this._targetAgent.setDiscoverTargets(true);
this._targetAgent.setRemoteLocations([{host: 'localhost', port: 9229}]);
}
}
/**
- * @param {function({target: !SDK.Target, waitingForDebugger: boolean})=} attachCallback
+ * @param {function({target: !SDK.Target, waitingForDebugger: boolean}):!Promise=} attachCallback
*/
static install(attachCallback) {
SDK.ChildTargetManager._attachCallback = attachCallback;
@@ -42,7 +42,7 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
* @return {!Promise}
*/
suspendModel() {
- return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: false});
+ return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: false, flatten: true});
}
/**
@@ -50,37 +50,18 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
* @return {!Promise}
*/
resumeModel() {
- return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true});
+ return this._targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
}
/**
* @override
*/
dispose() {
- for (const sessionId of this._childConnections.keys())
+ for (const sessionId of this._childTargets.keys())
this.detachedFromTarget(sessionId, undefined);
}
/**
- * @param {string} type
- * @return {number}
- */
- _capabilitiesForType(type) {
- if (type === 'worker') {
- return SDK.Target.Capability.JS | SDK.Target.Capability.Log | SDK.Target.Capability.Network |
- SDK.Target.Capability.Target;
- }
- if (type === 'service_worker')
- return SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target;
- if (type === 'iframe') {
- return SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Target.Capability.JS |
- SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target |
- SDK.Target.Capability.Tracing | SDK.Target.Capability.Emulation | SDK.Target.Capability.Input;
- }
- return 0;
- }
-
- /**
* @override
* @param {!Protocol.Target.TargetInfo} targetInfo
*/
@@ -134,13 +115,26 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
targetName = parsedURL ? parsedURL.lastPathComponentWithFragment() :
'#' + (++SDK.ChildTargetManager._lastAnonymousTargetId);
}
- const target = this._targetManager.createTarget(
- targetInfo.targetId, targetName, this._capabilitiesForType(targetInfo.type),
- this._createChildConnection.bind(this, this._targetAgent, sessionId), this._parentTarget, false /* isNodeJS */);
- if (SDK.ChildTargetManager._attachCallback)
- SDK.ChildTargetManager._attachCallback({target, waitingForDebugger});
- target.runtimeAgent().runIfWaitingForDebugger();
+ let type = SDK.Target.Type.Browser;
+ if (targetInfo.type === 'iframe')
+ type = SDK.Target.Type.Frame;
+ else if (targetInfo.type === 'worker')
+ type = SDK.Target.Type.Worker;
+ else if (targetInfo.type === 'service_worker')
+ type = SDK.Target.Type.ServiceWorker;
+
+ const target =
+ this._targetManager.createTarget(targetInfo.targetId, targetName, type, this._parentTarget, sessionId);
+ this._childTargets.set(sessionId, target);
+
+ if (SDK.ChildTargetManager._attachCallback) {
+ SDK.ChildTargetManager._attachCallback({target, waitingForDebugger}).then(() => {
+ target.runtimeAgent().runIfWaitingForDebugger();
+ });
+ } else {
+ target.runtimeAgent().runIfWaitingForDebugger();
+ }
}
/**
@@ -149,8 +143,8 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
* @param {string=} childTargetId
*/
detachedFromTarget(sessionId, childTargetId) {
- this._childConnections.get(sessionId).onDisconnect.call(null, 'target terminated');
- this._childConnections.delete(sessionId);
+ this._childTargets.get(sessionId).dispose('target terminated');
+ this._childTargets.delete(sessionId);
}
/**
@@ -160,21 +154,7 @@ SDK.ChildTargetManager = class extends SDK.SDKModel {
* @param {string=} childTargetId
*/
receivedMessageFromTarget(sessionId, message, childTargetId) {
- const connection = this._childConnections.get(sessionId);
- if (connection)
- connection.onMessage.call(null, message);
- }
-
- /**
- * @param {!Protocol.TargetAgent} agent
- * @param {string} sessionId
- * @param {!Protocol.InspectorBackend.Connection.Params} params
- * @return {!Protocol.InspectorBackend.Connection}
- */
- _createChildConnection(agent, sessionId, params) {
- const connection = new SDK.ChildConnection(agent, sessionId, params);
- this._childConnections.set(sessionId, connection);
- return connection;
+ // We use flatten protocol.
}
};