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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 InspectorTest.addScript(
6 `function *gen(a) {
7 var b = 42;
8 yield a;
9 return b;
10 }
11 function testSuspendedGenerator()
12 {
13 var g = gen(420);
14 g.next();
15
16 debugger;
17 }`);
18
19 Protocol.Debugger.enable().then(testSuite);
20
21 function dumpInnermostScope(msg) {
22 var scopes = msg.result.result;
23 var inner_scope = scopes[0].value;
24 return Protocol.Runtime.getProperties({ objectId : inner_scope.objectId })
25 .then(InspectorTest.logMessage);
26 }
27
28 function dumpGeneratorScopes(msg)
29 {
30 var props = msg.result.internalProperties;
31 var promises = props
32 .filter(prop => prop.name == "[[Scopes]]")
33 .map(prop => prop.value.objectId)
34 .map(scopesId => Protocol.Runtime.getProperties({ objectId : scopesId })
35 .then(dumpInnermostScope));
36 return Promise.all(promises);
37 }
38
39 function fetchGeneratorProperties(objectId) {
40 return Protocol.Runtime.getProperties({ objectId : objectId });
41 }
42
43 function extractGeneratorObjectFromScope(scopeId) {
44 return Protocol.Runtime.getProperties({ objectId : scopeId })
45 .then(msg => {
46 var generatorObjectId = msg.result.result[0].value.objectId;
47 return fetchGeneratorProperties(generatorObjectId);
48 });
49 }
50
51 function dumpGeneratorScopesOnPause(msg) {
52 var scopeChain = msg.params.callFrames[0].scopeChain;
53 var promises = scopeChain
54 .filter(scope => scope.type === "local")
55 .map(scope => scope.object.objectId)
56 .map(scopeId => extractGeneratorObjectFromScope(scopeId)
57 .then(dumpGeneratorScopes));
58 return Promise.all(promises).then(Protocol.Debugger.resume);
59 }
60
61 function testSuite() {
62 InspectorTest.runTestSuite([
63
64 function testScopesPaused(next) {
65 Protocol.Debugger.oncePaused()
66 .then(dumpGeneratorScopesOnPause)
67 .then(next);
68 Protocol.Runtime.evaluate({ expression : "testSuspendedGenerator()" });
69 },
70
71 function testScopesNonPaused(next) {
72 Protocol.Runtime.evaluate({ expression : "gen(430)"})
73 .then(msg => fetchGeneratorProperties(msg.result.result.objectId))
74 .then(dumpGeneratorScopes)
75 .then(next);
76 },
77 ]);
78 }
OLDNEW
« 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