@@ -145,6 +145,7 @@ V8Debug.prototype._unshareSecurityToken = function() {
145
145
146
146
V8Debug . prototype . _wrapDebugCommandProcessor = function ( ) {
147
147
var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
148
+ this . _DebugCommandProcessor = proto ;
148
149
overrides . processDebugRequest_ = proto . processDebugRequest ;
149
150
extend ( proto , overrides ) ;
150
151
overrides . extendedProcessDebugJSONRequestHandles_ [ 'disconnect' ] = function ( request , response ) {
@@ -154,23 +155,30 @@ V8Debug.prototype._wrapDebugCommandProcessor = function() {
154
155
} ;
155
156
156
157
V8Debug . prototype . _unwrapDebugCommandProcessor = function ( ) {
157
- var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
158
+ var proto = this . _DebugCommandProcessor ;
158
159
proto . processDebugRequest = proto . processDebugRequest_ ;
159
160
delete proto . processDebugRequest_ ;
160
161
delete proto . extendedProcessDebugJSONRequest_ ;
161
162
delete proto . extendedProcessDebugJSONRequestHandles_ ;
162
163
delete proto . extendedProcessDebugJSONRequestAsyncHandles_ ;
164
+ delete this . _DebugCommandProcessor ;
163
165
} ;
164
166
165
167
V8Debug . prototype . register =
166
168
V8Debug . prototype . registerCommand = function ( name , func ) {
167
- var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
169
+ var proto = this . _DebugCommandProcessor ;
168
170
proto . extendedProcessDebugJSONRequestHandles_ [ name ] = func ;
169
171
} ;
170
172
173
+ V8Debug . prototype . unregister =
174
+ V8Debug . prototype . unregisterCommand = function ( name , func ) {
175
+ var proto = this . _DebugCommandProcessor ;
176
+ delete proto . extendedProcessDebugJSONRequestHandles_ [ name ] ;
177
+ } ;
178
+
171
179
V8Debug . prototype . registerAsync =
172
180
V8Debug . prototype . registerAsyncCommand = function ( name , func ) {
173
- var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
181
+ var proto = this . _DebugCommandProcessor ;
174
182
proto . extendedProcessDebugJSONRequestAsyncHandles_ [ name ] = func ;
175
183
} ;
176
184
@@ -196,7 +204,7 @@ V8Debug.prototype.commandToEvent = function(request, response) {
196
204
} ;
197
205
198
206
V8Debug . prototype . registerEvent = function ( name ) {
199
- var proto = this . get ( 'DebugCommandProcessor.prototype' ) ;
207
+ var proto = this . _DebugCommandProcessor ;
200
208
proto . extendedProcessDebugJSONRequestHandles_ [ name ] = this . commandToEvent ;
201
209
} ;
202
210
@@ -237,6 +245,8 @@ V8Debug.prototype.enableWebkitProtocol = function() {
237
245
238
246
if ( this . _webkitProtocolEnabled ) return ;
239
247
248
+ var nextTmpEventId = 1 ;
249
+
240
250
var DebuggerScriptSource ,
241
251
DebuggerScript ,
242
252
InjectedScriptSource ,
@@ -266,7 +276,19 @@ V8Debug.prototype.enableWebkitProtocol = function() {
266
276
parameters = [ ] ;
267
277
}
268
278
269
- this . registerCommand ( command , new WebkitProtocolCallback ( parameters , callback ) ) ;
279
+ this . registerCommand ( command , new WebkitCommandCallback ( parameters , callback ) ) ;
280
+ } ;
281
+
282
+ this . emitAgentEvent = function ( command , callback ) {
283
+ var handlerName = 'tmpEvent-' + nextTmpEventId ++ ;
284
+ this . registerCommand ( handlerName , function ( request , response ) {
285
+ this . commandToEvent ( request , response ) ;
286
+ response . event = command ;
287
+
288
+ new WebkitEventCallback ( callback ) ( request , response ) ;
289
+ } . bind ( this ) ) ;
290
+ this . sendCommand ( handlerName ) ;
291
+ this . unregisterCommand ( handlerName ) ;
270
292
} ;
271
293
272
294
this . wrapCallFrames = function ( execState , maximumLimit , scopeDetails ) {
@@ -288,7 +310,7 @@ V8Debug.prototype.enableWebkitProtocol = function() {
288
310
289
311
this . _webkitProtocolEnabled = true ;
290
312
291
- function WebkitProtocolCallback ( argsList , callback ) {
313
+ function WebkitCommandCallback ( argsList , callback ) {
292
314
return function ( request , response ) {
293
315
InjectedScriptHost . execState = this . exec_state_ ;
294
316
@@ -301,6 +323,16 @@ V8Debug.prototype.enableWebkitProtocol = function() {
301
323
InjectedScriptHost . execState = null ;
302
324
}
303
325
}
326
+
327
+ function WebkitEventCallback ( callback ) {
328
+ return function ( request , response ) {
329
+ InjectedScriptHost . execState = this . exec_state_ ;
330
+
331
+ callback . call ( this , response , injectedScript , DebuggerScript ) ;
332
+
333
+ InjectedScriptHost . execState = null ;
334
+ }
335
+ }
304
336
} ;
305
337
306
338
V8Debug . prototype . releaseObject =
0 commit comments