cdp-tunnel 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.js +1 -1
- package/extension-new/cdp/handler/special.js +34 -8
- package/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -18,7 +18,7 @@ const program = new Command();
|
|
|
18
18
|
program
|
|
19
19
|
.name('cdp-tunnel')
|
|
20
20
|
.description('Chrome DevTools Protocol Tunnel')
|
|
21
|
-
.version('
|
|
21
|
+
.version(require(path.join(__dirname, '..', 'package.json')).version);
|
|
22
22
|
|
|
23
23
|
function log(color, ...args) {
|
|
24
24
|
const colors = {
|
|
@@ -21,7 +21,7 @@ var SpecialHandler = (function() {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
if (params && params.autoAttach) {
|
|
24
|
-
return emitAutoAttachForExistingTargets().then(function() {
|
|
24
|
+
return emitAutoAttachForExistingTargets(context).then(function() {
|
|
25
25
|
return {};
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -354,9 +354,11 @@ function checkTabVisibility(tabId) {
|
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
function emitAutoAttachForExistingTargets() {
|
|
357
|
+
function emitAutoAttachForExistingTargets(context) {
|
|
358
|
+
var clientId = context ? context.clientId : null;
|
|
359
|
+
var config = State.getAutoAttachConfig();
|
|
360
|
+
|
|
358
361
|
return chrome.debugger.getTargets().then(function(targets) {
|
|
359
|
-
var config = State.getAutoAttachConfig();
|
|
360
362
|
var promises = [];
|
|
361
363
|
|
|
362
364
|
Logger.info('[CDP] emitAutoAttachForExistingTargets: checking', targets.length, 'targets');
|
|
@@ -389,13 +391,14 @@ function checkTabVisibility(tabId) {
|
|
|
389
391
|
EventBuilder.send('Target.targetCreated', { targetInfo: targetInfo });
|
|
390
392
|
|
|
391
393
|
if (target.attached && isAttachedByUs) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
promises.push(promise.then(function() {
|
|
394
|
+
promises.push(Promise.resolve().then(function() {
|
|
395
395
|
var sessionId = CDPUtils.generateSessionId();
|
|
396
396
|
State.mapSession(sessionId, target.tabId, targetId);
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
if (clientId) {
|
|
399
|
+
State.setTabIdToClientId(target.tabId, clientId);
|
|
400
|
+
}
|
|
401
|
+
addTabToAutomationGroup(target.tabId, clientId);
|
|
399
402
|
|
|
400
403
|
if (config.waitForDebuggerOnStart) {
|
|
401
404
|
State.addPendingDebuggerTab(target.tabId);
|
|
@@ -404,9 +407,32 @@ function checkTabVisibility(tabId) {
|
|
|
404
407
|
EventBuilder.send('Target.attachedToTarget', {
|
|
405
408
|
sessionId: sessionId,
|
|
406
409
|
targetInfo: Object.assign({}, targetInfo, { attached: true }),
|
|
407
|
-
waitingForDebugger: config.waitForDebuggerOnStart
|
|
410
|
+
waitingForDebugger: config.waitForDebuggerOnStart || false
|
|
408
411
|
});
|
|
409
412
|
}));
|
|
413
|
+
} else if (!target.attached) {
|
|
414
|
+
promises.push(
|
|
415
|
+
DebuggerManager.attach(target.tabId).then(function(attached) {
|
|
416
|
+
if (!attached) return;
|
|
417
|
+
var sessionId = CDPUtils.generateSessionId();
|
|
418
|
+
State.mapSession(sessionId, target.tabId, targetId);
|
|
419
|
+
|
|
420
|
+
if (clientId) {
|
|
421
|
+
State.setTabIdToClientId(target.tabId, clientId);
|
|
422
|
+
}
|
|
423
|
+
addTabToAutomationGroup(target.tabId, clientId);
|
|
424
|
+
|
|
425
|
+
if (config.waitForDebuggerOnStart) {
|
|
426
|
+
State.addPendingDebuggerTab(target.tabId);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
EventBuilder.send('Target.attachedToTarget', {
|
|
430
|
+
sessionId: sessionId,
|
|
431
|
+
targetInfo: Object.assign({}, targetInfo, { attached: true }),
|
|
432
|
+
waitingForDebugger: config.waitForDebuggerOnStart || false
|
|
433
|
+
});
|
|
434
|
+
})
|
|
435
|
+
);
|
|
410
436
|
}
|
|
411
437
|
});
|
|
412
438
|
|