| Index: test/inspector/debugger/restore-provisional-breakpoint-by-line.js
|
| diff --git a/test/inspector/debugger/restore-provisional-breakpoint-by-line.js b/test/inspector/debugger/restore-provisional-breakpoint-by-line.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..272ba268c55ac2a0de69d0c7d8d6d2699deb4ba5
|
| --- /dev/null
|
| +++ b/test/inspector/debugger/restore-provisional-breakpoint-by-line.js
|
| @@ -0,0 +1,91 @@
|
| +// 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.
|
| +
|
| +var source = `
|
| +console.log(239);
|
| +function test() {
|
| + return 42;
|
| +}`;
|
| +
|
| +var longPrefix = new Array(512).join(';');
|
| +var sourceWithLongLines = `
|
| +function test() {
|
| + ${longPrefix}console.log(1);
|
| + ${longPrefix}console.log(2);
|
| + return 42;
|
| +}`;
|
| +
|
| +var sourceWithLongLinesEdited = `
|
| +function test() {
|
| + ${longPrefix}console.log(3);
|
| + ${longPrefix}console.log(1);
|
| + ${longPrefix}console.log(2);
|
| + return 42;
|
| +}`;
|
| +
|
| +InspectorTest.setupScriptMap();
|
| +Protocol.Debugger.enable();
|
| +
|
| +InspectorTest.runTestSuite([
|
| + function trivial(next) {
|
| + runTest({
|
| + lineNumber: 8,
|
| + url: 'test1.js',
|
| + sourceBefore: source,
|
| + sourceAfter: generateNewLines(9) + source,
|
| + lineOffset: 5,
|
| + columnOffset: 4 }).then(next);
|
| + },
|
| +
|
| + function dontCheckMoreThenNLines(next) {
|
| + runTest({
|
| + lineNumber: 8,
|
| + url: 'test2.js',
|
| + sourceBefore: source,
|
| + sourceAfter: generateNewLines(17) + source,
|
| + lineOffset: 5,
|
| + columnOffset: 4 }).then(next);
|
| + },
|
| +
|
| + function dontStoreLongStrings(next) {
|
| + runTest({
|
| + lineNumber: 14,
|
| + url: 'test3.js',
|
| + sourceBefore: sourceWithLongLines,
|
| + sourceAfter: sourceWithLongLinesEdited,
|
| + lineOffset: 12,
|
| + columnOffset: 0 }).then(next);
|
| + }
|
| +]);
|
| +
|
| +function runTest(test) {
|
| + let isBefore = true;
|
| + Protocol.Debugger.onPaused(message => {
|
| + InspectorTest.logCallFrames([ message.params.callFrames[0] ]);
|
| + var source = isBefore ? test.sourceBefore : test.sourceAfter;
|
| + source += '\n//# sourceURL=' + test.url;
|
| + isBefore = false;
|
| + var lineNumber = message.params.callFrames[0].location.lineNumber - test.lineOffset;
|
| + var lineText = source.split('\n')[lineNumber];
|
| + InspectorTest.log('break at\'' + lineText.substr(Math.max(lineText.length - 32, 0)) + '\'');
|
| + Protocol.Debugger.resume();
|
| + });
|
| + Protocol.Debugger.onBreakpointResolved(InspectorTest.logMessage);
|
| +
|
| + let breakpointId;
|
| + InspectorTest.addScript(test.sourceBefore + '\n//# sourceURL=' + test.url, test.lineOffset, test.columnOffset);
|
| + return InspectorTest.waitPendingTasks()
|
| + .then(() => Protocol.Debugger.setBreakpointByUrl({ lineNumber: test.lineNumber, url: test.url }))
|
| + .then(InspectorTest.logMessage)
|
| + .then(message => breakpointId = message.result.breakpointId)
|
| + .then(() => Protocol.Runtime.evaluate({ expression: 'test()' }))
|
| + .then(() => InspectorTest.addScript(test.sourceAfter + '\n//# sourceURL=' + test.url, test.lineOffset, test.columnOffset ))
|
| + .then(() => InspectorTest.waitPendingTasks())
|
| + .then(() => Protocol.Runtime.evaluate({ expression: 'test()' }))
|
| + .then(() => Protocol.Debugger.removeBreakpoint({ breakpointId: breakpointId }))
|
| +}
|
| +
|
| +function generateNewLines(n) {
|
| + return new Array(n + 1).join('\n');
|
| +}
|
|
|