OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 InspectorTest.evaluateInPage( | 5 InspectorTest.addScript( |
6 `function testFunction() | 6 `function testFunction() |
7 { | 7 { |
8 for (var a of [1]) { | 8 for (var a of [1]) { |
9 ++a; | 9 ++a; |
10 debugger; | 10 debugger; |
11 } | 11 } |
12 }`); | 12 }`); |
13 | 13 |
14 InspectorTest.sendCommandOrDie("Debugger.enable", {}); | 14 Protocol.Debugger.enable(); |
15 InspectorTest.eventHandler["Debugger.paused"] = dumpScopeOnPause; | 15 Protocol.Debugger.oncePaused().then(dumpScopeOnPause); |
16 InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": "testFunction
()" }); | 16 Protocol.Runtime.evaluate({ "expression": "testFunction()" }); |
17 | 17 |
18 var waitScopeObjects = 0; | 18 var waitScopeObjects = 0; |
19 function dumpScopeOnPause(message) | 19 function dumpScopeOnPause(message) |
20 { | 20 { |
21 var scopeChain = message.params.callFrames[0].scopeChain; | 21 var scopeChain = message.params.callFrames[0].scopeChain; |
22 var localScopeObjectIds = []; | 22 var localScopeObjectIds = []; |
23 for (var scope of scopeChain) { | 23 for (var scope of scopeChain) { |
24 if (scope.type === "local") | 24 if (scope.type === "local") |
25 localScopeObjectIds.push(scope.object.objectId); | 25 localScopeObjectIds.push(scope.object.objectId); |
26 } | 26 } |
27 waitScopeObjects = localScopeObjectIds.length; | 27 waitScopeObjects = localScopeObjectIds.length; |
28 if (!waitScopeObjects) { | 28 if (!waitScopeObjects) { |
29 InspectorTest.completeTest(); | 29 InspectorTest.completeTest(); |
30 } else { | 30 } else { |
31 for (var objectId of localScopeObjectIds) | 31 for (var objectId of localScopeObjectIds) |
32 InspectorTest.sendCommandOrDie("Runtime.getProperties", { "objectId" : obj
ectId }, dumpProperties); | 32 Protocol.Runtime.getProperties({ "objectId" : objectId }).then(dumpPropert
ies); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 function dumpProperties(message) | 36 function dumpProperties(message) |
37 { | 37 { |
38 InspectorTest.logObject(message); | 38 InspectorTest.logMessage(message); |
39 --waitScopeObjects; | 39 --waitScopeObjects; |
40 if (!waitScopeObjects) | 40 if (!waitScopeObjects) |
41 InspectorTest.sendCommandOrDie("Debugger.resume", {}, () => InspectorTest.co
mpleteTest()); | 41 Protocol.Debugger.resume().then(InspectorTest.completeTest); |
42 } | 42 } |
OLD | NEW |