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 blackboxing by patterns');
|
|
|
|
|
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function bar()
|
|
|
|
{
|
|
|
|
return 42;
|
|
|
|
}`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function foo()
|
|
|
|
{
|
|
|
|
var a = bar();
|
|
|
|
return a + 1;
|
|
|
|
}
|
|
|
|
//# sourceURL=foo.js`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function qwe()
|
|
|
|
{
|
|
|
|
var a = foo();
|
|
|
|
return a + 1;
|
|
|
|
}
|
|
|
|
//# sourceURL=qwe.js`);
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(
|
2016-10-02 21:22:49 +00:00
|
|
|
`function baz()
|
|
|
|
{
|
|
|
|
var a = qwe();
|
|
|
|
return a + 1;
|
|
|
|
}
|
|
|
|
//# sourceURL=baz.js`);
|
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.enable();
|
|
|
|
Protocol.Debugger.setBlackboxPatterns({ patterns: [ "foo([" ] }).then(dumpError);
|
2016-10-02 21:22:49 +00:00
|
|
|
|
|
|
|
function dumpError(message)
|
|
|
|
{
|
|
|
|
InspectorTest.log(message.error.message);
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger.onPaused(dumpStackAndRunNextCommand);
|
|
|
|
Protocol.Debugger.setBlackboxPatterns({ patterns: [ "baz\.js", "foo\.js" ] });
|
|
|
|
Protocol.Runtime.evaluate({ "expression": "debugger;baz()" });
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var commands = [ "stepInto", "stepInto", "stepInto", "stepOut", "stepInto", "stepInto" ];
|
|
|
|
function dumpStackAndRunNextCommand(message)
|
|
|
|
{
|
|
|
|
InspectorTest.log("Paused in");
|
|
|
|
var callFrames = message.params.callFrames;
|
|
|
|
for (var callFrame of callFrames)
|
|
|
|
InspectorTest.log((callFrame.functionName || "(...)") + ":" + (callFrame.location.lineNumber + 1));
|
|
|
|
var command = commands.shift();
|
|
|
|
if (!command) {
|
|
|
|
InspectorTest.completeTest();
|
|
|
|
return;
|
|
|
|
}
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Debugger[command]();
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|