This commit is contained in:
Rob 2015-10-21 08:51:14 -07:00
Родитель 858966d541
Коммит f01bea6f95
5 изменённых файлов: 29 добавлений и 31 удалений

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

@ -2,7 +2,7 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import Utilities = require('../webkit/utilities');
import * as Utilities from '../webkit/utilities';
export type EventHandler = (event: DebugProtocol.Event) => void;
@ -52,7 +52,7 @@ export class AdapterProxy {
return reversedTransformers.reduce(
(p, transformer) => {
// If the transformer implements this command, give it a chance to modify the args. Otherwise skip it
const bodyTransformMethodName = request.command + "Response";
const bodyTransformMethodName = request.command + 'Response';
return bodyTransformMethodName in transformer ?
p.then(() => transformer[bodyTransformMethodName](body, request.seq)) :
p;

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

@ -27,8 +27,6 @@
"member-access": true,
"member-ordering": [
true,
//"public-before-private",
//"static-before-instance",
"variables-before-functions"
],
"no-any": false,
@ -50,7 +48,7 @@
"no-empty": false,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": true,
"no-internal-module": false,
"no-keyword-named-variables": true,
"no-require-imports": true,
"no-shadowed-variable": true,

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

@ -120,7 +120,7 @@ export class WebKitConnection {
*/
public attach(port: number): Promise<void> {
return getUrlWithRetry(`http://localhost:${port}/json`).then(jsonResponse => {
const pages = JSON.parse(jsonResponse).filter(target => target.type === "page");
const pages = JSON.parse(jsonResponse).filter(target => target.type === 'page');
const wsUrl = pages[0].webSocketDebuggerUrl;
return this._socket.attach(wsUrl);
}).then(() => <Promise<void>><any>this.sendMessage('Debugger.enable'));
@ -130,12 +130,12 @@ export class WebKitConnection {
this._socket.close();
}
public debugger_setBreakpoint(location: WebKitProtocol.Debugger.Location, condition?: string):Promise<WebKitProtocol.Debugger.SetBreakpointResponse> {
public debugger_setBreakpoint(location: WebKitProtocol.Debugger.Location, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointResponse> {
return this.sendMessage('Debugger.setBreakpoint', <WebKitProtocol.Debugger.SetBreakpointParams>{ location, condition });
}
public debugger_removeBreakpoint(breakpointId: string): Promise<WebKitProtocol.Response> {
return this.sendMessage('Debugger.removeBreakpoint', <WebKitProtocol.Debugger.RemoveBreakpointParams>{ breakpointId })
return this.sendMessage('Debugger.removeBreakpoint', <WebKitProtocol.Debugger.RemoveBreakpointParams>{ breakpointId });
}
public debugger_stepOver(): Promise<WebKitProtocol.Response> {

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

@ -2,15 +2,15 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import {DebugSession, StoppedEvent, InitializedEvent, TerminatedEvent} from '../common/debugSession';
import {StoppedEvent, InitializedEvent, TerminatedEvent} from '../common/debugSession';
import {Handles} from '../common/handles';
import {WebKitConnection} from './webKitConnection';
import * as Utilities from './utilities';
import {spawn, ChildProcess} from 'child_process';
import nodeUrl = require('url');
import path = require('path');
import fs = require('fs');
import * as nodeUrl from 'url';
import * as path from 'path';
import * as fs from 'fs';
interface IPendingBreakpoint {
resolve: (response: SetBreakpointsResponseBody) => void;
@ -26,7 +26,6 @@ export class WebKitDebugAdapter implements IDebugAdapter {
private _clientCWD: string;
private _clientAttached: boolean;
private _targetAttached: boolean;
private _variableHandles: Handles<string>;
private _currentStack: WebKitProtocol.Debugger.CallFrame[];
private _pendingBreakpointsByUrl: Map<string, IPendingBreakpoint>;
@ -101,7 +100,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
chromeArgs.push(...args.arguments);
}
console.log(`Spawning chrome: "${chromeExe}", ${JSON.stringify(chromeArgs)}`);
console.log(`Spawning chrome: '${chromeExe}', ${JSON.stringify(chromeArgs)}`);
this._chromeProc = spawn(chromeExe, chromeArgs);
this._chromeProc.on('error', (err) => {
console.error('chrome error: ' + err);
@ -185,9 +184,9 @@ export class WebKitDebugAdapter implements IDebugAdapter {
this._scriptsById.set(script.scriptId, script);
if (this._pendingBreakpointsByUrl.has(clientUrl)) {
const pendingBreakpoint = this._pendingBreakpointsByUrl.get(clientUrl);
///const pendingBreakpoint = this._pendingBreakpointsByUrl.get(clientUrl);
this._pendingBreakpointsByUrl.delete(clientUrl);
// TODO this.setBreakpoints(pendingBreakpoint.response, pendingBreakpoint.args);
///TODO this.setBreakpoints(pendingBreakpoint.response, pendingBreakpoint.args);
}
}
@ -240,10 +239,11 @@ export class WebKitDebugAdapter implements IDebugAdapter {
// TODO caching by source.path seems wrong because it may not exist? But this implies that we haven't told ODP about this script so it may have to be set. Assert non-null?
return new Promise((resolve: (response: SetBreakpointsResponseBody) => void, reject) => {
this._pendingBreakpointsByUrl.set(canonicalizeUrl(args.source.path), { resolve, reject, args });
})
});
}
}
private _addBreakpoints(sourcePath: string, scriptId: WebKitProtocol.Debugger.ScriptId, lines: number[]): Promise<WebKitProtocol.Debugger.SetBreakpointResponse[]> {
// Call setBreakpoint for all breakpoints in the script simultaneously
const responsePs = lines
@ -275,12 +275,12 @@ export class WebKitDebugAdapter implements IDebugAdapter {
public setExceptionBreakpoints(args: DebugProtocol.SetExceptionBreakpointsArguments): Promise<void> {
let state: string;
if (args.filters.indexOf("all") >= 0) {
state = "all";
} else if (args.filters.indexOf("uncaught") >= 0) {
state = "uncaught";
if (args.filters.indexOf('all') >= 0) {
state = 'all';
} else if (args.filters.indexOf('uncaught') >= 0) {
state = 'uncaught';
} else {
state = "none";
state = 'none';
}
return this._webKitConnection.debugger_setPauseOnExceptions(state)
@ -437,7 +437,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
// 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
// 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(() => { });
@ -450,7 +450,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
*/
private webkitUrlToClientUrl(url: string): string {
// If a file:/// url is loaded in the client, just send the absolute path of the file
if (url.substr(0, 8) === "file:///") {
if (url.substr(0, 8) === 'file:///') {
return canonicalizeUrl(url);
}
@ -504,7 +504,7 @@ function canonicalizeUrl(url: string): string {
}
function scriptIdToSourceReference(scriptId: WebKitProtocol.Debugger.ScriptId): number {
return parseInt(scriptId);
return parseInt(scriptId, 10);
}
function sourceReferenceToScriptId(sourceReference: number): WebKitProtocol.Debugger.ScriptId {

12
webkit/webKitProtocol.d.ts поставляемый
Просмотреть файл

@ -70,7 +70,7 @@ declare module WebKitProtocol {
result: {
breakpointId: BreakpointId;
actualLocation: Location;
}
};
}
interface RemoveBreakpointParams {
@ -100,8 +100,8 @@ declare module WebKitProtocol {
line: number;
column: number;
stackTrace: ExceptionStackFrame[];
}
}
};
};
}
interface SetPauseOnExceptionsParams {
@ -115,7 +115,7 @@ declare module WebKitProtocol {
interface GetScriptSourceResponse extends Response {
result: {
scriptSource: string;
}
};
}
}
@ -128,7 +128,7 @@ declare module WebKitProtocol {
interface GetPropertiesResponse extends Response {
result: {
result: PropertyDescriptor[];
}
};
}
interface PropertyDescriptor {
@ -162,7 +162,7 @@ declare module WebKitProtocol {
result: {
result: Runtime.RemoteObject;
wasThrown: boolean;
}
};
}
}