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>
10 // requested line number, insterstatement location, expected control parameter 'step', expected line number
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
;
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));
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
)
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", { });
89 function handleDebuggerPausedUnexpected(messageObject
)
91 InspectorTest
.log("Unexpected debugger pause");
92 InspectorTest
.completeTest();
98 <body onLoad=
"runTest();">