Chromium Code Reviews| OLD | NEW |
|---|---|
| (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(); | |
| 20 Protocol.Debugger.oncePaused().then(dumpScopeOnPause); | |
| 21 Protocol.Runtime.evaluate({ "expression": "testSuspendedGenerator()" }); | |
| 22 | |
| 23 var waitScopeObjects = 0; | |
| 24 function dumpScopeOnPause(message) | |
| 25 { | |
| 26 var scopeChain = message.params.callFrames[0].scopeChain; | |
| 27 var localScopeObjectIds = []; | |
| 28 for (var scope of scopeChain) { | |
| 29 if (scope.type === "local") | |
| 30 localScopeObjectIds.push(scope.object.objectId); | |
| 31 } | |
| 32 if (localScopeObjectIds.length != 1) { | |
| 33 InspectorTest.completeTest(); | |
| 34 } else { | |
| 35 for (var objectId of localScopeObjectIds) | |
| 36 Protocol.Runtime.getProperties({ "objectId" : objectId }) | |
| 37 .then(fetchGeneratorProperties) | |
| 38 .then(dumpGeneratorScopes); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 function fetchGeneratorProperties(msg) { | |
| 43 return Protocol.Runtime.getProperties( | |
| 44 { objectId : msg.result.result[0].value.objectId }); | |
| 45 } | |
| 46 | |
| 47 function dumpGeneratorScopes(msg) | |
| 48 { | |
| 49 var props = msg.result.internalProperties; | |
| 50 for (var i = 0; i < props.length; i++) { | |
| 51 var prop = props[i]; | |
| 52 if (prop.name == "[[Scopes]]") { | |
| 53 InspectorTest.logMessage(prop); | |
| 54 // Print the innermost scopes. | |
| 55 Protocol.Runtime.getProperties({ objectId : prop.value.objectId }) | |
| 56 .then(msg => { | |
| 57 var scopes = msg.result.result; | |
| 58 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
| |
| 59 }); | |
| 60 } | |
| 61 } | |
| 62 Protocol.Debugger.resume().then(InspectorTest.completeTest); | |
| 63 } | |
| OLD | NEW |