Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: test/inspector/debugger/suspended-generator-scopes.js

Issue 2516973003: [inspector] Expose scopes for suspended generator objects (Closed)
Patch Set: Add test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/v8-debugger.cc ('k') | test/inspector/debugger/suspended-generator-scopes-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « src/inspector/v8-debugger.cc ('k') | test/inspector/debugger/suspended-generator-scopes-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698