Index: test/inspector/debugger/suspended-generator-scopes.js |
diff --git a/test/inspector/debugger/suspended-generator-scopes.js b/test/inspector/debugger/suspended-generator-scopes.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9c8662fc51fb633301f79427444f15c96a124eb7 |
--- /dev/null |
+++ b/test/inspector/debugger/suspended-generator-scopes.js |
@@ -0,0 +1,63 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+InspectorTest.addScript( |
+`function *gen(a) { |
+ var b = 42; |
+ yield a; |
+ return b; |
+} |
+function testSuspendedGenerator() |
+{ |
+ var g = gen(420); |
+ g.next(); |
+ |
+ debugger; |
+}`); |
+ |
+Protocol.Debugger.enable(); |
+Protocol.Debugger.oncePaused().then(dumpScopeOnPause); |
+Protocol.Runtime.evaluate({ "expression": "testSuspendedGenerator()" }); |
+ |
+var waitScopeObjects = 0; |
+function dumpScopeOnPause(message) |
+{ |
+ var scopeChain = message.params.callFrames[0].scopeChain; |
+ var localScopeObjectIds = []; |
+ for (var scope of scopeChain) { |
+ if (scope.type === "local") |
+ localScopeObjectIds.push(scope.object.objectId); |
+ } |
+ if (localScopeObjectIds.length != 1) { |
+ InspectorTest.completeTest(); |
+ } else { |
+ for (var objectId of localScopeObjectIds) |
+ Protocol.Runtime.getProperties({ "objectId" : objectId }) |
+ .then(fetchGeneratorProperties) |
+ .then(dumpGeneratorScopes); |
+ } |
+} |
+ |
+function fetchGeneratorProperties(msg) { |
+ return Protocol.Runtime.getProperties( |
+ { objectId : msg.result.result[0].value.objectId }); |
+} |
+ |
+function dumpGeneratorScopes(msg) |
+{ |
+ var props = msg.result.internalProperties; |
+ for (var i = 0; i < props.length; i++) { |
+ var prop = props[i]; |
+ if (prop.name == "[[Scopes]]") { |
+ InspectorTest.logMessage(prop); |
+ // Print the innermost scopes. |
+ Protocol.Runtime.getProperties({ objectId : prop.value.objectId }) |
+ .then(msg => { |
+ var scopes = msg.result.result; |
+ InspectorTest.logMessage(scopes); |
jgruber
2016/11/22 14:57:32
If we attempt to get the properties of e.g. the in
kozy
2016/11/22 19:26:37
I think the problem here that you call Debugger.re
|
+ }); |
+ } |
+ } |
+ Protocol.Debugger.resume().then(InspectorTest.completeTest); |
+} |