This commit is contained in:
Rob 2015-10-28 18:57:15 -07:00
Родитель 8da6fb12d5
Коммит 904b797c27
2 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -111,7 +111,7 @@ suite('WebKitDebugAdapter', () => {
function makeExpectedResponse(lines: number[], cols?: number[]): SetBreakpointsResponseBody { function makeExpectedResponse(lines: number[], cols?: number[]): SetBreakpointsResponseBody {
const breakpoints = lines.map((line, i) => ({ const breakpoints = lines.map((line, i) => ({
line, line,
column: cols ? cols[i] : 0, column: cols? cols[i] : 0,
verified: true verified: true
})); }));
@ -170,7 +170,6 @@ suite('WebKitDebugAdapter', () => {
const lines = [14, 200]; const lines = [14, 200];
const cols = [33, 16]; const cols = [33, 16];
expectSetBreakpoint(lines, cols); expectSetBreakpoint(lines, cols);
expectRemoveBreakpoint([0, 1]);
const wkda = instantiateWKDA(); const wkda = instantiateWKDA();
return attach(wkda).then(() => { return attach(wkda).then(() => {
@ -179,6 +178,8 @@ suite('WebKitDebugAdapter', () => {
}).then(response => { }).then(response => {
lines.push(321); lines.push(321);
cols.push(123); cols.push(123);
expectRemoveBreakpoint([0, 1]);
expectSetBreakpoint(lines, cols); expectSetBreakpoint(lines, cols);
return wkda.setBreakpoints({ source: { path: FILE_NAME }, lines, cols }); return wkda.setBreakpoints({ source: { path: FILE_NAME }, lines, cols });
}).then(response => { }).then(response => {

Просмотреть файл

@ -87,7 +87,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
const chromeArgs: string[] = ['--remote-debugging-port=' + port]; const chromeArgs: string[] = ['--remote-debugging-port=' + port];
// Also start with extra stuff disabled, and user-data-dir in tmp directory // Also start with extra stuff disabled, and user-data-dir in tmp directory
chromeArgs.push(...['--no-first-run', '--no-default-browser-check', `--user-data-dir=${Os.tmpdir()}/webkitdebugadapter${Date.now()}`]); chromeArgs.push(...['--no-first-run', '--no-default-browser-check', `--user-data-dir=${Os.tmpdir() }/webkitdebugadapter${Date.now() }`]);
if (args.runtimeArguments) { if (args.runtimeArguments) {
chromeArgs.push(...args.runtimeArguments); chromeArgs.push(...args.runtimeArguments);
} }
@ -101,7 +101,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
///return Promise.reject('The launch config must specify either the "program" or "url" field.'); ///return Promise.reject('The launch config must specify either the "program" or "url" field.');
} }
Logger.log(`spawn('${chromeExe}', ${JSON.stringify(chromeArgs)})`); Logger.log(`spawn('${chromeExe}', ${JSON.stringify(chromeArgs) })`);
this._chromeProc = spawn(chromeExe, chromeArgs); this._chromeProc = spawn(chromeExe, chromeArgs);
this._chromeProc.on('error', (err) => { this._chromeProc.on('error', (err) => {
Logger.log('chrome error: ' + err); Logger.log('chrome error: ' + err);
@ -127,11 +127,11 @@ export class WebKitDebugAdapter implements IDebugAdapter {
return this._webKitConnection.attach(port) return this._webKitConnection.attach(port)
.then( .then(
() => this.fireEvent(new InitializedEvent()), () => this.fireEvent(new InitializedEvent()),
e => { e => {
this.clearEverything(); this.clearEverything();
return Promise.reject(e); return Promise.reject(e);
}); });
} else { } else {
return Promise.resolve<void>(); return Promise.resolve<void>();
} }
@ -252,7 +252,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
if (targetScript) { if (targetScript) {
// DebugProtocol sends all current breakpoints for the script. Clear all scripts for the breakpoint then add all of them // DebugProtocol sends all current breakpoints for the script. Clear all scripts for the breakpoint then add all of them
const setBreakpointsPFailOnError = this._setBreakpointsRequestQ const setBreakpointsPFailOnError = this._setBreakpointsRequestQ
.then(() => this.clearAllBreakpoints(targetScript.scriptId)) .then(() => this._clearAllBreakpoints(targetScript.scriptId))
.then(() => this._addBreakpoints(args.source.path, targetScript.scriptId, args.lines, args.cols)) .then(() => this._addBreakpoints(args.source.path, targetScript.scriptId, args.lines, args.cols))
.then(responses => ({ breakpoints: this._webkitBreakpointResponsesToODPBreakpoints(targetScript, responses, args.lines) })); .then(responses => ({ breakpoints: this._webkitBreakpointResponsesToODPBreakpoints(targetScript, responses, args.lines) }));
@ -272,6 +272,17 @@ export class WebKitDebugAdapter implements IDebugAdapter {
} }
} }
private _clearAllBreakpoints(scriptId: WebKitProtocol.Debugger.ScriptId): Promise<void> {
const committedBps = this._committedBreakpointsByScriptId.get(scriptId) || [];
// Remove breakpoints one at a time. Seems like it would be ok to send the removes all at once,
// but there is a chrome bug where when removing 5+ or so breakpoints at once, it gets into a weird
// state where later adds on the same line will fail with 'breakpoint already exists' even though it
// does not break there.
return committedBps.reduce<Promise<void>>((p, bpId) => {
return p.then(() => this._webKitConnection.debugger_removeBreakpoint(bpId)).then(() => { });
}, Promise.resolve<void>());
}
private _addBreakpoints(sourcePath: string, scriptId: WebKitProtocol.Debugger.ScriptId, lines: number[], cols?: number[]): Promise<WebKitProtocol.Debugger.SetBreakpointResponse[]> { private _addBreakpoints(sourcePath: string, scriptId: WebKitProtocol.Debugger.ScriptId, lines: number[], cols?: number[]): Promise<WebKitProtocol.Debugger.SetBreakpointResponse[]> {
// Call setBreakpoint for all breakpoints in the script simultaneously // Call setBreakpoint for all breakpoints in the script simultaneously
@ -516,18 +527,6 @@ export class WebKitDebugAdapter implements IDebugAdapter {
return { value, variablesReference }; return { value, variablesReference };
} }
private clearAllBreakpoints(scriptId: WebKitProtocol.Debugger.ScriptId): Promise<void> {
const committedBps = this._committedBreakpointsByScriptId.get(scriptId) || [];
// Remove breakpoints one at a time. Seems like it would be ok to send the removes all at once,
// but there is a chrome bug where when removing 5+ or so breakpoints at once, it gets into a weird
// state where later adds on the same line will fail with 'breakpoint already exists' even though it
// does not break there.
return committedBps.reduce<Promise<void>>((p, bpId) => {
return p.then(() => this._webKitConnection.debugger_removeBreakpoint(bpId)).then(() => { });
}, Promise.resolve<void>());
}
/** /**
* http://localhost/app/scripts/code.js => d:/scripts/code.js * http://localhost/app/scripts/code.js => d:/scripts/code.js
* file:///d:/scripts/code.js => d:/scripts/code.js * file:///d:/scripts/code.js => d:/scripts/code.js