2016-10-02 21:22:49 +00:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that blackboxed ranges are respected while stepping');
|
|
|
|
|
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function blackboxedBoo()
|
|
|
|
{
|
|
|
|
var a = 42;
|
|
|
|
var b = foo();
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
//# sourceURL=blackboxed-script.js`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function notBlackboxedFoo()
|
|
|
|
{
|
|
|
|
var a = 42;
|
|
|
|
var b = blackboxedBoo();
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function blackboxedFoo()
|
|
|
|
{
|
|
|
|
var a = 42;
|
|
|
|
var b = notBlackboxedFoo();
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function notBlackboxedBoo()
|
|
|
|
{
|
|
|
|
var a = 42;
|
|
|
|
var b = blackboxedFoo();
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
//# sourceURL=mixed-source.js`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function testFunction()
|
|
|
|
{
|
|
|
|
notBlackboxedBoo(); // for setup ranges and stepOut
|
|
|
|
notBlackboxedBoo(); // for stepIn
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo()
|
|
|
|
{
|
|
|
|
debugger;
|
|
|
|
return 239;
|
|
|
|
}`);
|
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.oncePaused().then(setBlackboxedScriptRanges);
|
|
|
|
Protocol.Debugger.enable().then(callTestFunction);
|
2016-10-02 21:22:49 +00:00
|
|
|
|
|
|
|
function callTestFunction(response)
|
|
|
|
{
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Runtime.evaluate({ expression: "setTimeout(testFunction, 0);"});
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setBlackboxedScriptRanges(response)
|
|
|
|
{
|
|
|
|
var callFrames = response.params.callFrames;
|
|
|
|
printCallFrames(callFrames);
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.setBlackboxedRanges({
|
2016-10-02 21:22:49 +00:00
|
|
|
scriptId: callFrames[1].location.scriptId,
|
|
|
|
positions: [ { lineNumber: 0, columnNumber: 0 } ] // blackbox ranges for blackboxed.js
|
2016-10-03 23:32:52 +00:00
|
|
|
}).then(setIncorrectRanges.bind(null, callFrames[2].location.scriptId));
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var incorrectPositions = [
|
|
|
|
[ { lineNumber: 0, columnNumber: 0 }, { lineNumber: 0, columnNumber: 0 } ],
|
|
|
|
[ { lineNumber: 0, columnNumber: 1 }, { lineNumber: 0, columnNumber: 0 } ],
|
|
|
|
[ { lineNumber: 0, columnNumber: -1 } ],
|
|
|
|
];
|
|
|
|
|
|
|
|
function setIncorrectRanges(scriptId, response)
|
|
|
|
{
|
|
|
|
if (response.error)
|
|
|
|
InspectorTest.log(response.error.message);
|
|
|
|
var positions = incorrectPositions.shift();
|
|
|
|
if (!positions) {
|
|
|
|
setMixedSourceRanges(scriptId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
InspectorTest.log("Try to set positions: " + JSON.stringify(positions));
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.setBlackboxedRanges({
|
2016-10-02 21:22:49 +00:00
|
|
|
scriptId: scriptId,
|
|
|
|
positions: positions
|
2016-10-03 23:32:52 +00:00
|
|
|
}).then(setIncorrectRanges.bind(null, scriptId));
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setMixedSourceRanges(scriptId)
|
|
|
|
{
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.onPaused(runAction);
|
2017-01-24 01:50:25 +00:00
|
|
|
Protocol.Debugger
|
|
|
|
.setBlackboxedRanges({
|
|
|
|
scriptId: scriptId,
|
|
|
|
positions: [
|
|
|
|
{lineNumber: 6, columnNumber: 0},
|
|
|
|
{lineNumber: 14, columnNumber: 0}
|
|
|
|
] // blackbox ranges for mixed.js
|
|
|
|
})
|
|
|
|
.then(runAction);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print",
|
|
|
|
"stepInto", "print", "stepOver", "stepInto", "print", "stepOver", "stepInto", "print",
|
|
|
|
"stepOver", "stepInto", "print" ];
|
|
|
|
|
|
|
|
function runAction(response)
|
|
|
|
{
|
|
|
|
var action = actions.shift();
|
2016-10-19 02:04:34 +00:00
|
|
|
if (!action) {
|
2016-10-02 21:22:49 +00:00
|
|
|
InspectorTest.completeTest();
|
2016-10-19 02:04:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-10-02 21:22:49 +00:00
|
|
|
|
|
|
|
if (action === "print") {
|
|
|
|
printCallFrames(response.params.callFrames);
|
|
|
|
runAction({});
|
|
|
|
} else {
|
|
|
|
InspectorTest.log("action: " + action);
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger[action]();
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function printCallFrames(callFrames)
|
|
|
|
{
|
|
|
|
var topCallFrame = callFrames[0];
|
|
|
|
if (topCallFrame.functionName.startsWith("blackboxed"))
|
|
|
|
InspectorTest.log("FAIL: blackboxed function in top call frame");
|
|
|
|
for (var callFrame of callFrames)
|
|
|
|
InspectorTest.log(callFrame.functionName + ": " + callFrame.location.lineNumber + ":" + callFrame.location.columnNumber);
|
|
|
|
InspectorTest.log("");
|
|
|
|
}
|