Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: test/inspector/debugger/get-possible-breakpoints.js

Issue 2709263002: [inspector] use BREAK_POSITION_ALIGNED for breakpoints (Closed)
Patch Set: little testcfg tuning Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/debugger-script.js ('k') | test/inspector/debugger/get-possible-breakpoints-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/debugger/get-possible-breakpoints.js
diff --git a/test/inspector/debugger/get-possible-breakpoints.js b/test/inspector/debugger/get-possible-breakpoints.js
index bfa081935d163eb06ef0ba15eabafb64f88b5113..640c3e61eaf9aa6f75141e82f5d781b93b94ddbb 100644
--- a/test/inspector/debugger/get-possible-breakpoints.js
+++ b/test/inspector/debugger/get-possible-breakpoints.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-print("Test for Debugger.getPossibleBreakpoints");
+print('Test for Debugger.getPossibleBreakpoints');
Protocol.Runtime.enable();
Protocol.Debugger.enable();
@@ -10,159 +10,149 @@ Protocol.Debugger.enable();
InspectorTest.runTestSuite([
function getPossibleBreakpointsInRange(next) {
- var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n";
+ var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n';
var scriptId;
compileScript(source)
.then(id => scriptId = id)
- .then(() => InspectorTest.log("Test start.scriptId != end.scriptId."))
- .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + "0" }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test not existing scriptId."))
- .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: "-1" }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end < start."))
+ .then(() => InspectorTest.log('Test start.scriptId != end.scriptId.'))
+ .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + '0' }}))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test not existing scriptId.'))
+ .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: '-1' }}))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test end < start.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test empty range in first line."))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test empty range in first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one character range in first line."))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test one character range in first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 17, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test empty range in not first line."))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test empty range in not first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one character range in not first line."))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test one character range in not first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end is undefined"))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test end is undefined'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()"))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one string"))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test one string'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous."))
+ .then(message => dumpAllLocations(message, source))
+ .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 256, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
+ .then(message => dumpAllLocations(message, source))
.then(next);
},
function getPossibleBreakpointsInArrow(next) {
- var source = "function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }";
+ var source = 'function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }';
var scriptId;
compileScript(source)
.then(id => scriptId = id)
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
+ .then(message => dumpAllLocations(message, source))
.then(next);
},
function arrowFunctionFirstLine(next) {
- Protocol.Debugger.onPaused(message => {
- InspectorTest.log("paused in " + message.params.callFrames[0].functionName);
- InspectorTest.logMessage(message.params.callFrames[0].location);
- Protocol.Debugger.resume();
- });
+ Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source));
var source = `function foo1() { Promise.resolve().then(() => 42) }
function foo2() { Promise.resolve().then(() => 42) }`;
waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lineNumber: 1, columnNumber: 0 })
- .then(InspectorTest.logMessage)
+ .then(message => dumpAllLocations(message, source))
.then(setAllBreakpoints)
- .then(() => Protocol.Runtime.evaluate({ expression: "foo1(); foo2()"}))
+ .then(() => Protocol.Runtime.evaluate({ expression: 'foo1(); foo2()'}))
.then(next);
},
function arrowFunctionOnPause(next) {
- function dumpAndResume(message) {
- InspectorTest.log("paused in " + message.params.callFrames[0].functionName);
- InspectorTest.logMessage(message.params.callFrames[0].location);
- Protocol.Debugger.resume();
- }
-
var source = `debugger; function foo3() { Promise.resolve().then(() => 42) }
function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`;
waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 }, undefined, next)
- .then(InspectorTest.logMessage)
+ .then(message => dumpAllLocations(message, source))
.then(setAllBreakpoints)
- .then(() => Protocol.Debugger.onPaused(dumpAndResume))
+ .then(() => Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source)))
.then(() => Protocol.Debugger.resume());
},
function getPossibleBreakpointsInRangeWithOffset(next) {
- var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n";
+ var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n';
var scriptId;
- compileScript(source, { name: "with-offset.js", line_offset: 1, column_offset: 1 })
+ compileScript(source, { name: 'with-offset.js', line_offset: 1, column_offset: 1 })
.then(id => scriptId = id)
- .then(() => InspectorTest.log("Test empty range in first line."))
+ .then(() => InspectorTest.log('Test empty range in first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one character range in first line."))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test one character range in first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 18, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test empty range in not first line."))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test empty range in not first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one character range in not first line."))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test one character range in not first line.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 17, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end is undefined"))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test end is undefined'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()"))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test one string"))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test one string'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 0, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
- .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous."))
+ .then(message => dumpAllLocations(message, source, 1, 1))
+ .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.'))
.then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 256, scriptId: scriptId }}))
- .then(InspectorTest.logMessage)
+ .then(message => dumpAllLocations(message, source, 1, 1))
.then(next);
},
function withOffset(next) {
- Protocol.Debugger.onPaused(message => {
- InspectorTest.log("paused in " + message.params.callFrames[0].functionName);
- InspectorTest.logMessage(message.params.callFrames[0].location);
- Protocol.Debugger.resume();
- });
+ Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source, 3, 18));
var source = `function foo5() { Promise.resolve().then(() => 42) }
function foo6() { Promise.resolve().then(() => 42) }`;
- waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: "with-offset.js", line_offset: 3, column_offset: 18 })
- .then(InspectorTest.logMessage)
+ waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: 'with-offset.js', line_offset: 3, column_offset: 18 })
+ .then(message => dumpAllLocations(message, source, 3, 18))
.then(setAllBreakpoints)
- .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"}))
+ .then(() => Protocol.Runtime.evaluate({ expression: 'foo5(); foo6()'}))
.then(next);
},
function arrowFunctionReturn(next) {
- waitForPossibleBreakpoints("() => 239\n", { lineNumber: 0, columnNumber: 0 })
- .then(InspectorTest.logMessage)
- .then(() => waitForPossibleBreakpoints("function foo() { function boo() { return 239 } }\n", { lineNumber: 0, columnNumber: 0 }))
- .then(InspectorTest.logMessage)
- .then(() => waitForPossibleBreakpoints("() => { 239 }\n", { lineNumber: 0, columnNumber: 0 }))
- .then(InspectorTest.logMessage)
- // TODO(kozyatinskiy): lineNumber for return position should be 21 instead of 22.
- .then(() => waitForPossibleBreakpoints("function foo() { 239 }\n", { lineNumber: 0, columnNumber: 0 }))
- .then(InspectorTest.logMessage)
+ function checkSource(source, location) {
+ return waitForPossibleBreakpoints(source, location)
+ .then(message => dumpAllLocations(message, source));
+ }
+
+ checkSource('() => 239\n', { lineNumber: 0, columnNumber: 0 })
+ .then(() => checkSource('function foo() { function boo() { return 239 } }\n', { lineNumber: 0, columnNumber: 0 }))
+ .then(() => checkSource('() => { 239 }\n', { lineNumber: 0, columnNumber: 0 }))
+ .then(() => checkSource('function foo() { 239 }\n', { lineNumber: 0, columnNumber: 0 }))
// TODO(kozyatinskiy): lineNumber for return position should be only 9, not 8.
- .then(() => waitForPossibleBreakpoints("() => 239", { lineNumber: 0, columnNumber: 0 }))
- .then(InspectorTest.logMessage)
- // TODO(kozyatinskiy): lineNumber for return position should be only 19, not 20.
- .then(() => waitForPossibleBreakpoints("() => { return 239 }", { lineNumber: 0, columnNumber: 0 }))
- .then(InspectorTest.logMessage)
- .then(next)
+ .then(() => checkSource('() => 239', { lineNumber: 0, columnNumber: 0 }))
+ .then(() => checkSource('() => { return 239 }', { lineNumber: 0, columnNumber: 0 }))
+ .then(next);
+ },
+
+ function argumentsAsCalls(next) {
+ var source = 'function foo(){}\nfunction boo(){}\nfunction main(f1,f2){}\nmain(foo(), boo());\n';
+ waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 })
+ .then(message => dumpAllLocations(message, source))
+ .then(next);
}
]);
function compileScript(source, origin) {
var promise = Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId);
- if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 };
+ if (!origin) origin = { name: '', line_offset: 0, column_offset: 0 };
compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset, false);
return promise;
}
@@ -184,20 +174,60 @@ function waitForPossibleBreakpointsOnPause(source, start, end, next) {
function setAllBreakpoints(message) {
var promises = [];
for (var location of message.result.locations)
- promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpointAndDump));
+ promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpoint));
return Promise.all(promises);
}
-function checkBreakpointAndDump(message) {
+function checkBreakpoint(message) {
if (message.error) {
- InspectorTest.log("FAIL: error in setBreakpoint");
+ InspectorTest.log('FAIL: error in setBreakpoint');
InspectorTest.logMessage(message);
return;
}
- var id_data = message.result.breakpointId.split(":");
+ 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");
+ InspectorTest.log('FAIL: possible breakpoint was resolved in another location');
+ }
+}
+
+function dumpAllLocations(message, source, lineOffset, columnOffset) {
+ if (message.error) {
InspectorTest.logMessage(message);
+ return;
+ }
+
+ lineOffset = lineOffset || 0;
+ columnOffset = columnOffset || 0;
+
+ var sourceLines = source.split('\n')
+ var lineOffsets = Array(sourceLines.length).fill(0);
+ for (var location of message.result.locations) {
+ var lineNumber = location.lineNumber - lineOffset;
+ var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset;
+ var line = sourceLines[lineNumber] || '';
+ var offset = lineOffsets[lineNumber];
+ line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber + offset);
+ ++lineOffsets[lineNumber];
+ sourceLines[lineNumber] = line;
}
- InspectorTest.logMessage(message);
+ InspectorTest.log(sourceLines.join('\n'));
+ return message;
+}
+
+function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnOffset) {
+ lineOffset = lineOffset || 0;
+ columnOffset = columnOffset || 0;
+
+ InspectorTest.log('paused in ' + message.params.callFrames[0].functionName);
+ var location = message.params.callFrames[0].location;
+ var sourceLines = source.split('\n')
+
+ var lineNumber = location.lineNumber - lineOffset;
+ var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset;
+
+ var line = sourceLines[lineNumber];
+ line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber);
+ sourceLines[lineNumber] = line;
+ InspectorTest.log(sourceLines.join('\n'));
+ Protocol.Debugger.resume();
}
« no previous file with comments | « src/inspector/debugger-script.js ('k') | test/inspector/debugger/get-possible-breakpoints-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698