v8/test/inspector/debugger/break-location-function-calls.js
Alexey Kozyatinskiy 9fef8fd21f [inspector] fixed getPossibleBreakpoints
BytecodeArrayBreakIterator doesn't iterate through locations in position() order. SkipToPosition is looking for closest break_index to passed one. So we should iterate through all breakable locations in function to get all of them.

R=jgruber@chromium.org

Bug: v8:6469
Change-Id: Ida0b849e9df40458a13e0a0f7af6a00349088228
Reviewed-on: https://chromium-review.googlesource.com/527135
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45765}
2017-06-07 13:25:52 +00:00

83 lines
2.7 KiB
JavaScript

// Copyright 2017 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Break locations around function calls');
contextGroup.addScript(`
function foo1() {}
function foo2() {}
function foo3() {}
//# sourceURL=test.js`);
InspectorTest.logProtocolCommandCalls('Debugger.stepInto');
session.setupScriptMap();
InspectorTest.runAsyncTestSuite([
async function testFunctionCallAsArgument() {
await testExpression('foo2(foo1())');
},
async function testFunctionCallAsArgument() {
await testExpression('foo2(foo1());');
},
async function testFunctionCallAsArguments() {
await testExpression('foo3(foo1(), foo2());');
},
async function testFunctionCallInBinaryExpression() {
await testExpression('foo3(foo1() + foo2());');
},
]);
async function logPauseLocation() {
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logSourceLocation(callFrames[0].location);
}
async function testExpression(expression) {
await Protocol.Debugger.enable();
let wrapper = `function test() {
${expression}
}
//# sourceURL=test-function.js`;
Protocol.Runtime.evaluate({expression: wrapper});
let {params:{scriptId}} = await Protocol.Debugger.onceScriptParsed();
let {result:{locations}} = await Protocol.Debugger.getPossibleBreakpoints({
start: {lineNumber: 0, columnNumber : 0, scriptId}});
locations = locations.filter(location => location.lineNumber === 1);
InspectorTest.log('Break locations in expression:');
await session.logBreakLocations(locations);
for (let location of locations) {
InspectorTest.log('Breakpoint at:');
await session.logSourceLocation(location);
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpoint({
location});
let evaluate = Protocol.Runtime.evaluate({
expression: 'test();\n//# sourceURL=expr.js'});
InspectorTest.log('Break at:');
await logPauseLocation();
Protocol.Debugger.stepInto();
await logPauseLocation();
await Protocol.Debugger.removeBreakpoint({breakpointId});
Protocol.Debugger.resume();
await evaluate;
}
InspectorTest.log('Breakpoint at expression line.')
let {result:{breakpointId}} = await Protocol.Debugger.setBreakpointByUrl({
lineNumber: 1, url: 'test-function.js'});
let evaluate = Protocol.Runtime.evaluate({
expression: 'test();\n//# sourceURL=expr.js'});
await logPauseLocation();
Protocol.Debugger.stepInto();
await logPauseLocation();
await Protocol.Debugger.removeBreakpoint({breakpointId});
Protocol.Debugger.resume();
await evaluate;
await Protocol.Debugger.disable();
}