From 9e04d1726c30f2a4150e10d49d1ea5e03f0f5594 Mon Sep 17 00:00:00 2001 From: Diego Geffner Date: Tue, 25 Jul 2017 16:56:06 -0700 Subject: [PATCH 1/3] Added the extraCRDPChannelPort parameter and updated logs to be generated on %tmpdir%\vscode-chrome-debug_%timestamp%.txt --- src/chromeDebug.ts | 9 ++++++--- src/chromeDebugAdapter.ts | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/chromeDebug.ts b/src/chromeDebug.ts index b2c3317a..ad07a422 100644 --- a/src/chromeDebug.ts +++ b/src/chromeDebug.ts @@ -4,6 +4,8 @@ import {ChromeDebugSession, logger, UrlPathTransformer, BaseSourceMapTransformer} from 'vscode-chrome-debug-core'; import * as path from 'path'; +import * as os from 'os'; +import * as fs from 'fs'; import {targetFilter} from './utils'; import {ChromeDebugAdapter} from './chromeDebugAdapter'; @@ -14,9 +16,10 @@ const EXTENSION_NAME = 'debugger-for-chrome'; declare let VERSION: string; let versionWithDefault = typeof VERSION === 'undefined' ? 'unspecified' : VERSION; // Not built with webpack for tests -// non-.txt file types can't be uploaded to github -// also note that __dirname here is out/ -const logFilePath = path.resolve(__dirname, '../vscode-chrome-debug.txt'); +// non-.txt file types can't be uploaded to github. Generated filename is something like: vscode-chrome-debug_2017-07-19_161210.txt +const timestampForFilename = new Date().toISOString().replace(/T/, '_').replace(/:/g, '').replace(/\..*/, ''); +const logFilePath = path.join(os.tmpdir(), `vscode-chrome-debug_${timestampForFilename}.txt`) + // Start a ChromeDebugSession configured to only match 'page' targets, which are Chrome tabs. // Cast because DebugSession is declared twice - in this repo's vscode-debugadapter, and that of -core... TODO diff --git a/src/chromeDebugAdapter.ts b/src/chromeDebugAdapter.ts index 7089abce..cabf1be4 100644 --- a/src/chromeDebugAdapter.ts +++ b/src/chromeDebugAdapter.ts @@ -86,7 +86,7 @@ export class ChromeDebugAdapter extends CoreDebugAdapter { }); return args.noDebug ? undefined : - this.doAttach(port, launchUrl || args.urlFilter, args.address, args.timeout); + this.doAttach(port, launchUrl || args.urlFilter, args.address, args.timeout, undefined, args.extraCRDPChannelPort); }); } @@ -111,8 +111,8 @@ export class ChromeDebugAdapter extends CoreDebugAdapter { super.commonArgs(args); } - protected doAttach(port: number, targetUrl?: string, address?: string, timeout?: number): Promise { - return super.doAttach(port, targetUrl, address, timeout).then(() => { + protected doAttach(port: number, targetUrl?: string, address?: string, timeout?: number, websocketUrl?: string, extraCRDPChannelPort?: number): Promise { + return super.doAttach(port, targetUrl, address, timeout, websocketUrl, extraCRDPChannelPort).then(() => { // Don't return this promise, a failure shouldn't fail attach this.globalEvaluate({ expression: 'navigator.userAgent', silent: true }) .then( From c6d542b156c098b0c6793cf920299292ac7ef923 Mon Sep 17 00:00:00 2001 From: Diego Geffner Date: Wed, 26 Jul 2017 09:37:06 -0700 Subject: [PATCH 2/3] Updated core package version, and reverted some of the logfile logic --- package.json | 2 +- src/chromeDebug.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fcd4144a..d1409b83 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { - "vscode-chrome-debug-core": "3.15.9", + "vscode-chrome-debug-core": "3.16.0", "vscode-debugadapter": "1.19.0" }, "devDependencies": { diff --git a/src/chromeDebug.ts b/src/chromeDebug.ts index ad07a422..a8dd8c33 100644 --- a/src/chromeDebug.ts +++ b/src/chromeDebug.ts @@ -5,7 +5,6 @@ import {ChromeDebugSession, logger, UrlPathTransformer, BaseSourceMapTransformer} from 'vscode-chrome-debug-core'; import * as path from 'path'; import * as os from 'os'; -import * as fs from 'fs'; import {targetFilter} from './utils'; import {ChromeDebugAdapter} from './chromeDebugAdapter'; @@ -16,10 +15,9 @@ const EXTENSION_NAME = 'debugger-for-chrome'; declare let VERSION: string; let versionWithDefault = typeof VERSION === 'undefined' ? 'unspecified' : VERSION; // Not built with webpack for tests -// non-.txt file types can't be uploaded to github. Generated filename is something like: vscode-chrome-debug_2017-07-19_161210.txt -const timestampForFilename = new Date().toISOString().replace(/T/, '_').replace(/:/g, '').replace(/\..*/, ''); -const logFilePath = path.join(os.tmpdir(), `vscode-chrome-debug_${timestampForFilename}.txt`) - +// non-.txt file types can't be uploaded to github +// also note that __dirname here is out/ +const logFilePath = path.resolve(os.tmpdir(), 'vscode-chrome-debug.txt'); // Start a ChromeDebugSession configured to only match 'page' targets, which are Chrome tabs. // Cast because DebugSession is declared twice - in this repo's vscode-debugadapter, and that of -core... TODO From 626d56ca37e78242935dcc9cc2af4d04136b4c41 Mon Sep 17 00:00:00 2001 From: Diego Geffner Date: Wed, 26 Jul 2017 09:58:18 -0700 Subject: [PATCH 3/3] Make tests pass --- test/chromeDebugAdapter.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/chromeDebugAdapter.test.ts b/test/chromeDebugAdapter.test.ts index b8064140..2c70bc8e 100644 --- a/test/chromeDebugAdapter.test.ts +++ b/test/chromeDebugAdapter.test.ts @@ -108,7 +108,7 @@ suite('ChromeDebugAdapter', () => { require('fs').statSync = () => true; mockChromeConnection - .setup(x => x.attach(It.isValue(undefined), It.isAnyNumber(), It.isAnyString(), It.isValue(undefined))) + .setup(x => x.attach(It.isValue(undefined), It.isAnyNumber(), It.isAnyString(), It.isValue(undefined), It.isValue(undefined))) .returns(() => Promise.resolve()) .verifiable();