Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Commit 9fcf773

Browse files
author
Raghav Katyal
authored
Merge branch 'master' into breakonload
2 parents 7df509a + a7bb4c7 commit 9fcf773

File tree

6 files changed

+69
-33
lines changed

6 files changed

+69
-33
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ gulp.task('tslint', () => {
109109
});
110110

111111
gulp.task('transifex-push', function () {
112-
return gulp.src('**/*.nls.json')
112+
return gulp.src(['**/*.nls.json', '!testSupport/**'])
113113
.pipe(nls.prepareXlfFiles(transifexProjectName, transifexExtensionName))
114114
.pipe(nls.pushXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken));
115115
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-chrome-debug-core",
33
"displayName": "vscode-chrome-debug-core",
4-
"version": "3.18.2",
4+
"version": "3.18.4",
55
"description": "A library for building VS Code debug adapters for targets that support the Chrome Remote Debug Protocol",
66
"repository": {
77
"type": "git",

src/chrome/chromeDebugAdapter.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {ICommonRequestArgs, ILaunchRequestArgs, ISetBreakpointsArgs, ISetBreakpo
99
IAttachRequestArgs, IScopesResponseBody, IVariablesResponseBody,
1010
ISourceResponseBody, IThreadsResponseBody, IEvaluateResponseBody, ISetVariableResponseBody, IDebugAdapter,
1111
ICompletionsResponseBody, IToggleSkipFileStatusArgs, IInternalStackTraceResponseBody, IGetLoadedSourcesResponseBody,
12-
IExceptionInfoResponseBody, ISetBreakpointResult, TimeTravelRuntime, IRestartRequestArgs, BreakOnLoadStrategy} from '../debugAdapterInterfaces';
12+
IExceptionInfoResponseBody, ISetBreakpointResult, TimeTravelRuntime, IRestartRequestArgs, IInitializeRequestArgs, BreakOnLoadStrategy} from '../debugAdapterInterfaces';
1313
import {IChromeDebugAdapterOpts, ChromeDebugSession} from './chromeDebugSession';
1414
import {ChromeConnection} from './chromeConnection';
1515
import * as ChromeUtils from './chromeUtils';
@@ -185,9 +185,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
185185
this._pathTransformer.clearTargetContext();
186186
}
187187

188-
public initialize(args: DebugProtocol.InitializeRequestArguments): DebugProtocol.Capabilities {
188+
public initialize(args: IInitializeRequestArgs): DebugProtocol.Capabilities {
189189
if (args.supportsMapURLToFilePathRequest) {
190-
// We do this at the top of the method so we are less likely to add some code working on pathTransformer before this.
191190
this._pathTransformer = new FallbackToClientPathTransformer(this._session);
192191
}
193192

@@ -326,7 +325,7 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
326325
*/
327326
telemetry.reportEvent('debugStopped', { reason });
328327
this._hasTerminated = true;
329-
if (this._clientAttached || (<ILaunchRequestArgs>this._launchAttachArgs).noDebug) {
328+
if (this._clientAttached || (this._launchAttachArgs && (<ILaunchRequestArgs>this._launchAttachArgs).noDebug)) {
330329
this._session.sendEvent(new TerminatedEvent(restart));
331330
}
332331

@@ -434,10 +433,11 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
434433
protected sendInitializedEvent(): void {
435434
// Wait to finish loading sourcemaps from the initial scriptParsed events
436435
if (this._initialSourceMapsP) {
437-
this._initialSourceMapsP.then(() => {
438-
this._session.sendEvent(new InitializedEvent());
439-
this._initialSourceMapsP = null;
436+
const initialSourceMapsP = this._initialSourceMapsP;
437+
this._initialSourceMapsP = null;
440438

439+
initialSourceMapsP.then(() => {
440+
this._session.sendEvent(new InitializedEvent());
441441
this._earlyScripts.forEach(script => this.sendLoadedSourceEvent(script));
442442
this._earlyScripts = null;
443443
});
@@ -1976,7 +1976,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
19761976
result: variable.value,
19771977
variablesReference: variable.variablesReference,
19781978
indexedVariables: variable.indexedVariables,
1979-
namedVariables: variable.namedVariables
1979+
namedVariables: variable.namedVariables,
1980+
type: variable.type
19801981
};
19811982
}
19821983

@@ -2214,7 +2215,10 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
22142215

22152216
public createPrimitiveVariable(name: string, object: Crdp.Runtime.RemoteObject, parentEvaluateName?: string, stringify?: boolean): DebugProtocol.Variable {
22162217
const value = variables.getRemoteObjectPreview_primitive(object, stringify);
2217-
return this.createPrimitiveVariableWithValue(name, value, parentEvaluateName);
2218+
const variable = this.createPrimitiveVariableWithValue(name, value, parentEvaluateName);
2219+
variable.type = object.type;
2220+
2221+
return variable;
22182222
}
22192223

22202224
public createPrimitiveVariableWithValue(name: string, value: string, parentEvaluateName?: string): DebugProtocol.Variable {

src/debugAdapterInterfaces.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export interface ICommonRequestArgs {
3838
extraCRDPChannelPort?: number;
3939
}
4040

41+
export interface IInitializeRequestArgs extends DebugProtocol.InitializeRequestArguments {
42+
supportsMapURLToFilePathRequest?: boolean;
43+
}
44+
4145
export interface IRestartRequestArgs {
4246
port: number;
4347
}

test/chrome/chromeDebugAdapter.test.ts

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -342,33 +342,60 @@ suite('ChromeDebugAdapter', () => {
342342
});
343343

344344
suite('Console.messageAdded', () => {
345-
test('Fires an output event when a console message is added', () => {
345+
test('Fires an output event when a console message is added', done => {
346346
const testLog = 'Hello, world!';
347-
let outputEventFired = false;
348347
sendEventHandler = (event: DebugProtocol.Event) => {
349348
if (event.event === 'output') {
350-
outputEventFired = true;
351-
assert.equal(event.body.text, testLog);
349+
assert.equal(event.body.output.trim(), testLog);
350+
done();
352351
} else {
353352
testUtils.assertFail('An unexpected event was fired');
354353
}
355354
};
356355

357-
mockEventEmitter.emit('Console.onMessageAdded', {
358-
message: {
359-
source: 'console-api',
360-
level: 'log',
361-
type: 'log',
362-
text: testLog,
363-
timestamp: Date.now(),
364-
line: 2,
365-
column: 13,
366-
url: 'file:///c:/page/script.js',
367-
executionContextId: 2,
368-
parameters: [
369-
{ type: 'string', value: testLog }
370-
]
356+
chromeDebugAdapter.attach(ATTACH_ARGS).then(() => {
357+
mockEventEmitter.emit('Console.messageAdded', {
358+
message: {
359+
source: 'console-api',
360+
level: 'log',
361+
type: 'log',
362+
text: testLog,
363+
timestamp: Date.now(),
364+
line: 2,
365+
column: 13,
366+
url: 'file:///c:/page/script.js',
367+
executionContextId: 2,
368+
parameters: [
369+
{ type: 'string', value: testLog }
370+
]
371+
}
372+
});
373+
});
374+
});
375+
});
376+
377+
suite('Runtime.consoleAPICalled', () => {
378+
test('Fires an output event when a console api is called', done => {
379+
const testLog = 'Hello, world!';
380+
sendEventHandler = (event: DebugProtocol.Event) => {
381+
if (event.event === 'output') {
382+
assert.equal(event.body.output.trim(), testLog);
383+
done();
384+
} else {
385+
testUtils.assertFail('An unexpected event was fired');
371386
}
387+
};
388+
389+
chromeDebugAdapter.attach(ATTACH_ARGS).then(() => {
390+
mockEventEmitter.emit('Runtime.consoleAPICalled', {
391+
type: 'log',
392+
args: [{
393+
type: 'string',
394+
value: testLog
395+
}],
396+
executionContextId: 1,
397+
timestamp: 1754079033.244016
398+
});
372399
});
373400
});
374401
});
@@ -414,7 +441,8 @@ suite('ChromeDebugAdapter', () => {
414441
result,
415442
variablesReference,
416443
indexedVariables: undefined,
417-
namedVariables: undefined
444+
namedVariables: undefined,
445+
type: resultObj.type
418446
};
419447
}
420448

test/mocks/debugProtocolMocks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export interface IMockChromeConnectionAPI {
1919
}
2020

2121
// See https://github.com/florinn/typemoq/issues/20
22-
function getConsoleStubs() {
22+
function getConsoleStubs(mockEventEmitter) {
2323
return {
2424
enable() { },
25-
onMessageAdded() { }
25+
onMessageAdded(handler) { mockEventEmitter.on('Console.messageAdded', handler); }
2626
};
2727
}
2828

@@ -62,7 +62,7 @@ function getInspectorStubs(mockEventEmitter) {
6262
export function getMockChromeConnectionApi(): IMockChromeConnectionAPI {
6363
const mockEventEmitter = new EventEmitter();
6464

65-
let mockConsole = Mock.ofInstance<Crdp.ConsoleClient>(<any>getConsoleStubs());
65+
let mockConsole = Mock.ofInstance<Crdp.ConsoleClient>(<any>getConsoleStubs(mockEventEmitter));
6666
mockConsole.callBase = true;
6767
mockConsole
6868
.setup(x => x.enable())

0 commit comments

Comments
 (0)