2017-02-27 16:53:03 +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('Checks Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
|
2017-02-27 16:53:03 +00:00
|
|
|
|
|
|
|
var source = `
|
|
|
|
function test() {
|
|
|
|
Array.from([1,2]).map(() => 1).filter(() => true);
|
|
|
|
function nested1() {
|
|
|
|
Array.from([1,2]).map(() => 1).filter(() => true);
|
|
|
|
}
|
|
|
|
function nested2() {
|
|
|
|
Array.from([1,2]).map(() => 1).filter(() => true);
|
|
|
|
}
|
|
|
|
nested1();
|
|
|
|
nested2();
|
|
|
|
}
|
|
|
|
//# sourceURL=test.js`;
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup.addScript(source);
|
2017-02-27 16:53:03 +00:00
|
|
|
|
|
|
|
var scriptId;
|
|
|
|
Protocol.Debugger.onceScriptParsed().then(message => {
|
|
|
|
if (message.params.url === 'test.js')
|
|
|
|
scriptId = message.params.scriptId;
|
|
|
|
}).then(() => InspectorTest.runTestSuite(tests));
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
session.setupScriptMap();
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
Protocol.Debugger.onPaused(message => {
|
|
|
|
session.logSourceLocation(message.params.callFrames[0].location);
|
|
|
|
Protocol.Debugger.resume();
|
|
|
|
});
|
2017-02-27 16:53:03 +00:00
|
|
|
|
|
|
|
Protocol.Debugger.enable();
|
|
|
|
var tests = [
|
|
|
|
function testWholeFunction(next) {
|
|
|
|
Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), ignoreNestedFunctions: false })
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
.then(message => session.logBreakLocations(message.result.locations))
|
2017-02-27 16:53:03 +00:00
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testWholeFunctionWithoutNested(next) {
|
|
|
|
Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), ignoreNestedFunctions: true })
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
.then(message => session.logBreakLocations(message.result.locations))
|
2017-02-27 16:53:03 +00:00
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testPartOfFunctionWithoutNested(next) {
|
|
|
|
Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), end: location(2, 18), ignoreNestedFunctions: true })
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
.then(message => session.logBreakLocations(message.result.locations))
|
2017-02-27 16:53:03 +00:00
|
|
|
.then(next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function testNestedFunction(next) {
|
|
|
|
Protocol.Debugger.getPossibleBreakpoints({ start: location(4, 0), ignoreNestedFunctions: true })
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
.then(message => session.logBreakLocations(message.result.locations))
|
2017-02-27 16:53:03 +00:00
|
|
|
.then(setAllBreakpoints)
|
|
|
|
.then(() => InspectorTest.log('Run test() to check breakpoints..'))
|
|
|
|
.then(() => Protocol.Runtime.evaluate({ expression: 'test()' }))
|
|
|
|
.then(next);
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function location(lineNumber, columnNumber) {
|
|
|
|
return { lineNumber: lineNumber, columnNumber: columnNumber, scriptId: scriptId };
|
|
|
|
}
|
|
|
|
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
function setAllBreakpoints(locations) {
|
2017-02-27 16:53:03 +00:00
|
|
|
var promises = [];
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
for (var location of locations)
|
2017-02-27 16:53:03 +00:00
|
|
|
promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpoint));
|
|
|
|
return Promise.all(promises);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkBreakpoint(message) {
|
|
|
|
if (message.error) {
|
|
|
|
InspectorTest.log('FAIL: error in setBreakpoint');
|
|
|
|
InspectorTest.logMessage(message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var id_data = message.result.breakpointId.split(':');
|
|
|
|
if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parseInt(id_data[2]) !== message.result.actualLocation.columnNumber) {
|
|
|
|
InspectorTest.log('FAIL: possible breakpoint was resolved in another location');
|
|
|
|
}
|
|
|
|
}
|