Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / debugger / continueToLocation.html
blob8518caf0f865a255458538ae55970eaf7c89c01f
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script type="text/javascript" src="resources/statements.js"></script>
5 <script>
7 function test()
9 var scenario = [
10 // requested line number, insterstatement location, expected control parameter 'step', expected line number
11 [ 8, false, 1, 8 ],
12 [ 8, true, 1, 8 ],
13 [ 12, true, 3, 12 ],
14 [ 13, true, 4, 13 ],
15 [ 12, false, 6, 17 ],
16 [ 17, false, 6, 17 ],
17 [ 17, true, 6, 17 ],
20 InspectorTest.sendCommand("Debugger.enable", {});
22 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExample" }, callbackEvalFunctionObject);
24 function callbackEvalFunctionObject(response)
26 var functionObjectId = response.result.result.objectId;
27 InspectorTest.sendCommand("Debugger.getFunctionDetails", { functionId: functionObjectId }, callbackFunctionDetails);
30 function callbackFunctionDetails(response)
32 var result = response.result;
33 var scriptId = result.details.location.scriptId;
35 nextScenarioStep(0);
37 function nextScenarioStep(pos)
39 if (pos < scenario.length)
40 gotoSinglePassChain(scriptId, scenario[pos][0], scenario[pos][1], scenario[pos][2], scenario[pos][3], nextScenarioStep.bind(this, pos + 1));
41 else
42 InspectorTest.completeTest();
46 function gotoSinglePassChain(scriptId, lineNumber, interstatement, expectedResult, expectedLineNumber, next)
48 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedOne;
50 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "setTimeout(statementsExample, 0)" });
52 function handleDebuggerPausedOne(messageObject)
54 InspectorTest.log("Paused on debugger statement");
56 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedTwo;
58 InspectorTest.sendCommand("Debugger.continueToLocation", { location: { scriptId: scriptId, lineNumber: lineNumber, columnNumber: 0}, interstatementLocation: interstatement }, logContinueToLocation);
60 function logContinueToLocation(response)
62 if (response.error) {
63 InspectorTest.log("Failed to execute continueToLocation " + JSON.stringify(response.error));
64 InspectorTest.completeTest();
68 function handleDebuggerPausedTwo(messageObject)
70 InspectorTest.log("Paused after continueToLocation (insterstatement=" + interstatement + ")");
71 var actualLineNumber = messageObject.params.callFrames[0].location.lineNumber;
73 InspectorTest.log("Stopped on line " + actualLineNumber + ", expected " + expectedLineNumber + ", requested " + lineNumber + ", (0-based numbers).");
75 InspectorTest.eventHandler["Debugger.paused"] = handleDebuggerPausedUnexpected;
77 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "statementsExample.step" }, callbackStepEvaluate);
80 function callbackStepEvaluate(response)
82 var resultValue = response.result.result.value;
83 InspectorTest.log("Control parameter 'step' calculation result: " + resultValue + ", expected: " + expectedResult);
84 InspectorTest.log(resultValue == expectedResult ? "SUCCESS" : "FAIL");
85 InspectorTest.sendCommand("Debugger.resume", { });
86 next();
89 function handleDebuggerPausedUnexpected(messageObject)
91 InspectorTest.log("Unexpected debugger pause");
92 InspectorTest.completeTest();
96 </script>
97 </head>
98 <body onLoad="runTest();">
99 </body>
100 </html>