Chromium Code Reviews| Index: test/debugger/test-api.js |
| diff --git a/test/debugger/test-api.js b/test/debugger/test-api.js |
| index fc3d967e86600e0476a07670520614420c1f644c..32f4079dd8d7a30806ee16eb8beba7bddf9772e8 100644 |
| --- a/test/debugger/test-api.js |
| +++ b/test/debugger/test-api.js |
| @@ -220,10 +220,33 @@ class DebugWrapper { |
| } |
| } |
| + execStateScopeType(type) { |
| + switch (type) { |
| + case "global": return this.ScopeType.Global; |
| + case "local": return this.ScopeType.Local; |
| + case "with": return this.ScopeType.With; |
| + case "closure": return this.ScopeType.Closure; |
| + case "catch": return this.ScopeType.Catch; |
| + case "block": return this.ScopeType.Block; |
| + case "script": return this.ScopeType.Script; |
| + default: %AbortJS("Unexpected scope type"); |
| + } |
| + } |
| + |
| + // Returns an array of property descriptors of the scope object. |
| + // This is in contrast to the original API, which simply passed object |
| + // mirrors. |
| + execStateScopeObject(obj) { |
| + const {msgid, msg} = this.createMessage( |
| + "Runtime.getProperties", { objectId : obj.objectId }); |
| + this.sendMessage(msg); |
| + const reply = this.takeReplyChecked(msgid); |
| + return { value : () => reply.result.result }; |
| + } |
| + |
| execStateScope(scope) { |
| - // TODO(jgruber): Mapping |
| - return { scopeType: () => scope.type, |
| - scopeObject: () => scope.object |
| + return { scopeType : () => this.execStateScopeType(scope.type), |
|
Yang
2016/11/08 13:37:33
Just curious: do we need to specify 'this' explici
jgruber
2016/11/08 13:58:35
We do :/
$ out/debug/d8 <<< 'class Foo { x() { pr
|
| + scopeObject : () => this.execStateScopeObject(scope.object) |
| }; |
| } |
| @@ -238,6 +261,7 @@ class DebugWrapper { |
| func : () => func, |
| scopeCount : () => frame.scopeChain.length, |
| scope : (index) => this.execStateScope(frame.scopeChain[index]) |
| + , allScopes : () => frame.scopeChain.map(this.execStateScope.bind(this)) |
|
Yang
2016/11/08 13:37:33
formatting (comma, and 80-char limit) :)
jgruber
2016/11/08 13:58:35
Done, ty.
|
| }; |
| } |
| @@ -255,6 +279,18 @@ class DebugWrapper { |
| handleDebuggerPaused(message) { |
| const params = message.params; |
| + var debugEvent; |
| + switch (params.reason) { |
| + case "exception": |
| + case "promiseRejection": |
| + debugEvent = this.DebugEvent.Exception; |
| + break; |
| + default: |
| + // TODO(jgruber): More granularity. |
| + debugEvent = this.DebugEvent.Break; |
| + break; |
| + } |
| + |
| // Skip break events in this file. |
| if (params.callFrames[0].location.scriptId == this.thisScriptId) return; |
| @@ -267,7 +303,7 @@ class DebugWrapper { |
| frameCount : () => params.callFrames.length |
| }; |
| let eventData = this.execStateFrame(params.callFrames[0]); |
| - this.invokeListener(this.DebugEvent.Break, execState, eventData); |
| + this.invokeListener(debugEvent, execState, eventData); |
| } |
| handleDebuggerScriptParsed(message) { |
| @@ -291,6 +327,7 @@ class DebugWrapper { |
| // Simulate the debug object generated by --expose-debug-as debug. |
| var debug = { instance : undefined }; |
| + |
| Object.defineProperty(debug, 'Debug', { get: function() { |
| if (!debug.instance) { |
| debug.instance = new DebugWrapper(); |
| @@ -298,3 +335,8 @@ Object.defineProperty(debug, 'Debug', { get: function() { |
| } |
| return debug.instance; |
| }}); |
| + |
| +Object.defineProperty(debug, 'ScopeType', { get: function() { |
| + const instance = debug.Debug; |
| + return instance.ScopeType; |
| +}}); |