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

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

Issue 2516973003: [inspector] Expose scopes for suspended generator objects (Closed)
Patch Set: Address comments 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..f158e75f1158fa4c536229263281b47b98216f6e
--- /dev/null
+++ b/test/inspector/debugger/suspended-generator-scopes.js
@@ -0,0 +1,78 @@
+// 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().then(testSuite);
+
+function dumpInnermostScope(msg) {
+ var scopes = msg.result.result;
+ var inner_scope = scopes[0].value;
+ return Protocol.Runtime.getProperties({ objectId : inner_scope.objectId })
+ .then(InspectorTest.logMessage);
+}
+
+function dumpGeneratorScopes(msg)
+{
+ var props = msg.result.internalProperties;
+ var promises = props
+ .filter(prop => prop.name == "[[Scopes]]")
+ .map(prop => prop.value.objectId)
+ .map(scopesId => Protocol.Runtime.getProperties({ objectId : scopesId })
+ .then(dumpInnermostScope));
+ return Promise.all(promises);
+}
+
+function fetchGeneratorProperties(objectId) {
+ return Protocol.Runtime.getProperties({ objectId : objectId });
+}
+
+function extractGeneratorObjectFromScope(scopeId) {
+ return Protocol.Runtime.getProperties({ objectId : scopeId })
+ .then(msg => {
+ var generatorObjectId = msg.result.result[0].value.objectId;
+ return fetchGeneratorProperties(generatorObjectId);
+ });
+}
+
+function dumpGeneratorScopesOnPause(msg) {
+ var scopeChain = msg.params.callFrames[0].scopeChain;
+ var promises = scopeChain
+ .filter(scope => scope.type === "local")
+ .map(scope => scope.object.objectId)
+ .map(scopeId => extractGeneratorObjectFromScope(scopeId)
+ .then(dumpGeneratorScopes));
+ return Promise.all(promises).then(Protocol.Debugger.resume);
+}
+
+function testSuite() {
+ InspectorTest.runTestSuite([
+
+ function testScopesPaused(next) {
+ Protocol.Debugger.oncePaused()
+ .then(dumpGeneratorScopesOnPause)
+ .then(next);
+ Protocol.Runtime.evaluate({ expression : "testSuspendedGenerator()" });
+ },
+
+ function testScopesNonPaused(next) {
+ Protocol.Runtime.evaluate({ expression : "gen(430)"})
+ .then(msg => fetchGeneratorProperties(msg.result.result.objectId))
+ .then(dumpGeneratorScopes)
+ .then(next);
+ },
+ ]);
+}
« 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