Index: test/debugger/test-api.js |
diff --git a/test/debugger/test-api.js b/test/debugger/test-api.js |
index fc3d967e86600e0476a07670520614420c1f644c..b1f1db8ccd4af59f6884ac4e61791e8b1bf30190 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), |
+ scopeObject : () => this.execStateScopeObject(scope.object) |
}; |
} |
@@ -237,7 +260,9 @@ class DebugWrapper { |
functionName : () => frame.functionName, |
func : () => func, |
scopeCount : () => frame.scopeChain.length, |
- scope : (index) => this.execStateScope(frame.scopeChain[index]) |
+ scope : (index) => this.execStateScope(frame.scopeChain[index]), |
+ allScopes : () => frame.scopeChain.map( |
+ this.execStateScope.bind(this)) |
}; |
} |
@@ -255,6 +280,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 +304,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 +328,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 +336,8 @@ Object.defineProperty(debug, 'Debug', { get: function() { |
} |
return debug.instance; |
}}); |
+ |
+Object.defineProperty(debug, 'ScopeType', { get: function() { |
+ const instance = debug.Debug; |
+ return instance.ScopeType; |
+}}); |