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

Commit

Permalink
Merge branch 'master' into breakonload
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav Katyal authored Oct 30, 2017
2 parents 7df509a + a7bb4c7 commit 9fcf773
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ gulp.task('tslint', () => {
});

gulp.task('transifex-push', function () {
return gulp.src('**/*.nls.json')
return gulp.src(['**/*.nls.json', '!testSupport/**'])
.pipe(nls.prepareXlfFiles(transifexProjectName, transifexExtensionName))
.pipe(nls.pushXlfFiles(transifexApiHostname, transifexApiName, transifexApiToken));
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-chrome-debug-core",
"displayName": "vscode-chrome-debug-core",
"version": "3.18.2",
"version": "3.18.4",
"description": "A library for building VS Code debug adapters for targets that support the Chrome Remote Debug Protocol",
"repository": {
"type": "git",
Expand Down
22 changes: 13 additions & 9 deletions src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {ICommonRequestArgs, ILaunchRequestArgs, ISetBreakpointsArgs, ISetBreakpo
IAttachRequestArgs, IScopesResponseBody, IVariablesResponseBody,
ISourceResponseBody, IThreadsResponseBody, IEvaluateResponseBody, ISetVariableResponseBody, IDebugAdapter,
ICompletionsResponseBody, IToggleSkipFileStatusArgs, IInternalStackTraceResponseBody, IGetLoadedSourcesResponseBody,
IExceptionInfoResponseBody, ISetBreakpointResult, TimeTravelRuntime, IRestartRequestArgs, BreakOnLoadStrategy} from '../debugAdapterInterfaces';
IExceptionInfoResponseBody, ISetBreakpointResult, TimeTravelRuntime, IRestartRequestArgs, IInitializeRequestArgs, BreakOnLoadStrategy} from '../debugAdapterInterfaces';
import {IChromeDebugAdapterOpts, ChromeDebugSession} from './chromeDebugSession';
import {ChromeConnection} from './chromeConnection';
import * as ChromeUtils from './chromeUtils';
Expand Down Expand Up @@ -185,9 +185,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
this._pathTransformer.clearTargetContext();
}

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

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

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

initialSourceMapsP.then(() => {
this._session.sendEvent(new InitializedEvent());
this._earlyScripts.forEach(script => this.sendLoadedSourceEvent(script));
this._earlyScripts = null;
});
Expand Down Expand Up @@ -1976,7 +1976,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
result: variable.value,
variablesReference: variable.variablesReference,
indexedVariables: variable.indexedVariables,
namedVariables: variable.namedVariables
namedVariables: variable.namedVariables,
type: variable.type
};
}

Expand Down Expand Up @@ -2214,7 +2215,10 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {

public createPrimitiveVariable(name: string, object: Crdp.Runtime.RemoteObject, parentEvaluateName?: string, stringify?: boolean): DebugProtocol.Variable {
const value = variables.getRemoteObjectPreview_primitive(object, stringify);
return this.createPrimitiveVariableWithValue(name, value, parentEvaluateName);
const variable = this.createPrimitiveVariableWithValue(name, value, parentEvaluateName);
variable.type = object.type;

return variable;
}

public createPrimitiveVariableWithValue(name: string, value: string, parentEvaluateName?: string): DebugProtocol.Variable {
Expand Down
4 changes: 4 additions & 0 deletions src/debugAdapterInterfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface ICommonRequestArgs {
extraCRDPChannelPort?: number;
}

export interface IInitializeRequestArgs extends DebugProtocol.InitializeRequestArguments {
supportsMapURLToFilePathRequest?: boolean;
}

export interface IRestartRequestArgs {
port: number;
}
Expand Down
66 changes: 47 additions & 19 deletions test/chrome/chromeDebugAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,60 @@ suite('ChromeDebugAdapter', () => {
});

suite('Console.messageAdded', () => {
test('Fires an output event when a console message is added', () => {
test('Fires an output event when a console message is added', done => {
const testLog = 'Hello, world!';
let outputEventFired = false;
sendEventHandler = (event: DebugProtocol.Event) => {
if (event.event === 'output') {
outputEventFired = true;
assert.equal(event.body.text, testLog);
assert.equal(event.body.output.trim(), testLog);
done();
} else {
testUtils.assertFail('An unexpected event was fired');
}
};

mockEventEmitter.emit('Console.onMessageAdded', {
message: {
source: 'console-api',
level: 'log',
type: 'log',
text: testLog,
timestamp: Date.now(),
line: 2,
column: 13,
url: 'file:///c:/page/script.js',
executionContextId: 2,
parameters: [
{ type: 'string', value: testLog }
]
chromeDebugAdapter.attach(ATTACH_ARGS).then(() => {
mockEventEmitter.emit('Console.messageAdded', {
message: {
source: 'console-api',
level: 'log',
type: 'log',
text: testLog,
timestamp: Date.now(),
line: 2,
column: 13,
url: 'file:///c:/page/script.js',
executionContextId: 2,
parameters: [
{ type: 'string', value: testLog }
]
}
});
});
});
});

suite('Runtime.consoleAPICalled', () => {
test('Fires an output event when a console api is called', done => {
const testLog = 'Hello, world!';
sendEventHandler = (event: DebugProtocol.Event) => {
if (event.event === 'output') {
assert.equal(event.body.output.trim(), testLog);
done();
} else {
testUtils.assertFail('An unexpected event was fired');
}
};

chromeDebugAdapter.attach(ATTACH_ARGS).then(() => {
mockEventEmitter.emit('Runtime.consoleAPICalled', {
type: 'log',
args: [{
type: 'string',
value: testLog
}],
executionContextId: 1,
timestamp: 1754079033.244016
});
});
});
});
Expand Down Expand Up @@ -414,7 +441,8 @@ suite('ChromeDebugAdapter', () => {
result,
variablesReference,
indexedVariables: undefined,
namedVariables: undefined
namedVariables: undefined,
type: resultObj.type
};
}

Expand Down
6 changes: 3 additions & 3 deletions test/mocks/debugProtocolMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export interface IMockChromeConnectionAPI {
}

// See https://github.com/florinn/typemoq/issues/20
function getConsoleStubs() {
function getConsoleStubs(mockEventEmitter) {
return {
enable() { },
onMessageAdded() { }
onMessageAdded(handler) { mockEventEmitter.on('Console.messageAdded', handler); }
};
}

Expand Down Expand Up @@ -62,7 +62,7 @@ function getInspectorStubs(mockEventEmitter) {
export function getMockChromeConnectionApi(): IMockChromeConnectionAPI {
const mockEventEmitter = new EventEmitter();

let mockConsole = Mock.ofInstance<Crdp.ConsoleClient>(<any>getConsoleStubs());
let mockConsole = Mock.ofInstance<Crdp.ConsoleClient>(<any>getConsoleStubs(mockEventEmitter));
mockConsole.callBase = true;
mockConsole
.setup(x => x.enable())
Expand Down

0 comments on commit 9fcf773

Please sign in to comment.