| 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.evaluateInPage( | |
| 6 `function statementsExample() | |
| 7 { | |
| 8 var self = arguments.callee; | |
| 9 | |
| 10 debugger; | |
| 11 | |
| 12 self.step = 1; | |
| 13 | |
| 14 self.step = 2; | |
| 15 | |
| 16 void [ | |
| 17 self.step = 3, | |
| 18 self.step = 4, | |
| 19 self.step = 5, | |
| 20 self.step = 6 | |
| 21 ]; | |
| 22 | |
| 23 self.step = 7; | |
| 24 }`); | |
| 25 | |
| 26 var scenario = [ | |
| 27 // requested line number, expected control parameter 'step', expected line num
ber | |
| 28 [ 8, 1, 8 ], | |
| 29 [ 8, 1, 8 ], | |
| 30 [ 12, 6, 17 ], | |
| 31 [ 13, 6, 17 ], | |
| 32 [ 17, 6, 17 ], | |
| 33 [ 17, 6, 17 ], | |
| 34 ]; | |
| 35 | |
| 36 InspectorTest.sendCommand("Debugger.enable", {}); | |
| 37 | |
| 38 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExample
" }, callbackEvalFunctionObject); | |
| 39 | |
| 40 function callbackEvalFunctionObject(response) | |
| 41 { | |
| 42 var functionObjectId = response.result.result.objectId; | |
| 43 InspectorTest.sendCommand("Runtime.getProperties", { objectId: functionObjectI
d }, callbackFunctionDetails); | |
| 44 } | |
| 45 | |
| 46 function callbackFunctionDetails(response) | |
| 47 { | |
| 48 var result = response.result; | |
| 49 var scriptId; | |
| 50 for (var prop of result.internalProperties) { | |
| 51 if (prop.name === "[[FunctionLocation]]") | |
| 52 scriptId = prop.value.value.scriptId; | |
| 53 } | |
| 54 | |
| 55 nextScenarioStep(0); | |
| 56 | |
| 57 function nextScenarioStep(pos) | |
| 58 { | |
| 59 if (pos < scenario.length) | |
| 60 gotoSinglePassChain(scriptId, scenario[pos][0], scenario[pos][1], scenario
[pos][2], nextScenarioStep.bind(this, pos + 1)); | |
| 61 else | |
| 62 InspectorTest.completeTest(); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 function gotoSinglePassChain(scriptId, lineNumber, expectedResult, expectedLineN
umber, next) | |
| 67 { | |
| 68 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedOne; | |
| 69 | |
| 70 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(stat
ementsExample, 0)" }); | |
| 71 | |
| 72 function handleDebuggerPausedOne(messageObject) | |
| 73 { | |
| 74 InspectorTest.log("Paused on debugger statement"); | |
| 75 | |
| 76 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedTwo; | |
| 77 | |
| 78 InspectorTest.sendCommand("Debugger.continueToLocation", { location: { scrip
tId: scriptId, lineNumber: lineNumber, columnNumber: 0} }, logContinueToLocation
); | |
| 79 | |
| 80 function logContinueToLocation(response) | |
| 81 { | |
| 82 if (response.error) { | |
| 83 InspectorTest.log("Failed to execute continueToLocation " + JSON.stringi
fy(response.error)); | |
| 84 InspectorTest.completeTest(); | |
| 85 } | |
| 86 } | |
| 87 } | |
| 88 function handleDebuggerPausedTwo(messageObject) | |
| 89 { | |
| 90 InspectorTest.log("Paused after continueToLocation"); | |
| 91 var actualLineNumber = messageObject.params.callFrames[0].location.lineNumbe
r; | |
| 92 | |
| 93 InspectorTest.log("Stopped on line " + actualLineNumber + ", expected " + ex
pectedLineNumber + ", requested " + lineNumber + ", (0-based numbers)."); | |
| 94 | |
| 95 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedUnexpect
ed; | |
| 96 | |
| 97 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExa
mple.step" }, callbackStepEvaluate); | |
| 98 } | |
| 99 | |
| 100 function callbackStepEvaluate(response) | |
| 101 { | |
| 102 var resultValue = response.result.result.value; | |
| 103 InspectorTest.log("Control parameter 'step' calculation result: " + resultVa
lue + ", expected: " + expectedResult); | |
| 104 InspectorTest.log(resultValue === expectedResult ? "SUCCESS" : "FAIL"); | |
| 105 InspectorTest.sendCommand("Debugger.resume", { }); | |
| 106 next(); | |
| 107 } | |
| 108 | |
| 109 function handleDebuggerPausedUnexpected(messageObject) | |
| 110 { | |
| 111 InspectorTest.log("Unexpected debugger pause"); | |
| 112 InspectorTest.completeTest(); | |
| 113 } | |
| 114 } | |
| OLD | NEW |