@@ -163,12 +163,14 @@ V8Debug.prototype._unwrapDebugCommandProcessor = function() {
163
163
164
164
V8Debug . prototype . register =
165
165
V8Debug . prototype . registerCommand = function ( name , func ) {
166
- overrides . extendedProcessDebugJSONRequestHandles_ [ name ] = func ;
166
+ var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
167
+ proto . extendedProcessDebugJSONRequestHandles_ [ name ] = func ;
167
168
} ;
168
169
169
170
V8Debug . prototype . registerAsync =
170
171
V8Debug . prototype . registerAsyncCommand = function ( name , func ) {
171
- overrides . extendedProcessDebugJSONRequestAsyncHandles_ [ name ] = func ;
172
+ var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
173
+ proto . extendedProcessDebugJSONRequestAsyncHandles_ [ name ] = func ;
172
174
} ;
173
175
174
176
V8Debug . prototype . command =
@@ -193,14 +195,13 @@ V8Debug.prototype.commandToEvent = function(request, response) {
193
195
} ;
194
196
195
197
V8Debug . prototype . registerEvent = function ( name ) {
196
- overrides . extendedProcessDebugJSONRequestHandles_ [ name ] = this . commandToEvent ;
198
+ var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
199
+ proto . extendedProcessDebugJSONRequestHandles_ [ name ] = this . commandToEvent ;
197
200
} ;
198
201
199
202
V8Debug . prototype . get =
200
203
V8Debug . prototype . runInDebugContext = function ( script ) {
201
- if ( typeof script == 'function' ) script = script . toString ( ) + '()' ;
202
-
203
- script = / \) ; $ / . test ( script ) ? script : '(' + script + ');' ;
204
+ if ( typeof script == 'function' ) script = '(' + script . toString ( ) + ')()' ;
204
205
205
206
return binding . runScript ( script ) ;
206
207
} ;
@@ -242,25 +243,25 @@ V8Debug.prototype.enableWebkitProtocol = function() {
242
243
InjectedScriptHostSource ,
243
244
InjectedScriptHost ;
244
245
245
- function prepareSource ( source ) {
246
- return 'var ToggleMirrorCache = ToggleMirrorCache || function() {};\n' +
247
- '(function() {' +
248
- ( '' + source ) . replace ( / ^ .* ?" u s e s t r i c t " ; ( \r ? \n .* ?) * \( / m, '\r\n"use strict";\nreturn (' ) +
249
- '}());' ;
250
- }
246
+ this . runInDebugContext ( 'ToggleMirrorCache = ToggleMirrorCache || function() {}' ) ;
251
247
252
- DebuggerScriptSource = prepareSource ( fs . readFileSync ( DebuggerScriptLink , 'utf8' ) ) ;
248
+ DebuggerScriptSource = fs . readFileSync ( DebuggerScriptLink , 'utf8' ) ;
253
249
DebuggerScript = this . runInDebugContext ( DebuggerScriptSource ) ;
254
250
255
- InjectedScriptSource = prepareSource ( fs . readFileSync ( InjectedScriptLink , 'utf8' ) ) ;
251
+ InjectedScriptSource = fs . readFileSync ( InjectedScriptLink , 'utf8' ) ;
256
252
InjectedScript = this . runInDebugContext ( InjectedScriptSource ) ;
257
253
258
- InjectedScriptHostSource = prepareSource ( fs . readFileSync ( InjectedScriptHostLink , 'utf8' ) ) ;
254
+ InjectedScriptHostSource = fs . readFileSync ( InjectedScriptHostLink , 'utf8' ) ;
259
255
InjectedScriptHost = this . runInDebugContext ( InjectedScriptHostSource ) ( binding , DebuggerScript ) ;
260
256
261
257
var injectedScript = InjectedScript ( InjectedScriptHost , global , 1 ) ;
262
258
263
259
this . registerAgentCommand = function ( command , parameters , callback ) {
260
+ if ( typeof parameters === 'function' ) {
261
+ callback = parameters ;
262
+ parameters = [ ] ;
263
+ }
264
+
264
265
this . registerCommand ( command , new WebkitProtocolCallback ( parameters , callback ) ) ;
265
266
} ;
266
267
0 commit comments