OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 print('Checks that debugger agent uses source content to restore breakpoints.'); | |
6 | |
7 Protocol.Debugger.enable(); | |
8 InspectorTest.runTestSuite([ | |
9 function testSameSource(next) { | |
10 var source = 'function foo() {\nboo();\n}'; | |
11 test(source, source, { lineNumber: 1, columnNumber: 0 }, next); | |
12 }, | |
13 | |
14 function testOneLineOffset(next) { | |
15 var source = 'function foo() {\nboo();\n}'; | |
16 var newSource = 'function foo() {\nboo();\nboo();\n}'; | |
17 test(source, newSource, { lineNumber: 1, columnNumber: 0 }, next); | |
18 }, | |
19 | |
20 function testTwoSimilarLinesCloseToOriginalLocation1(next) { | |
21 var source = 'function foo() {\n\n\nboo();\n}'; | |
22 var newSource = 'function foo() {\nboo();\n\nnewCode();\nboo();\n\n\n\nboo() ;\n}'; | |
23 test(source, newSource, { lineNumber: 3, columnNumber: 0 }, next); | |
24 }, | |
25 | |
26 function testTwoSimilarLinesCloseToOriginalLocation2(next) { | |
27 var source = 'function foo() {\n\n\nboo();\n}'; | |
28 var newSource = 'function foo() {\nboo();\nnewLongCode();\nnewCode();\nboo() ;\n\n\n\nboo();\n}'; | |
29 test(source, newSource, { lineNumber: 3, columnNumber: 0 }, next); | |
30 }, | |
31 | |
32 function testHintIgnoreWhiteSpaces(next) { | |
33 var source = 'function foo() {\n\n\n\nboo();\n}'; | |
34 var newSource = 'function foo() {\nfoo();\n\n\nboo();\n}'; | |
35 test(source, newSource, { lineNumber: 1, columnNumber: 0 }, next); | |
36 }, | |
37 | |
38 function testCheckOnlyLimitedOffsets(next) { | |
39 var source = 'function foo() {\nboo();\n}'; | |
40 var longString = Array(1000).join(';'); | |
alph
2017/02/28 00:47:26
';'.repeat(999)
kozy
2017/02/28 01:56:26
Done.
| |
41 var newSource = `function foo() {\nnewCode();\n${longString};\nboo();\n}`; | |
42 test(source, newSource, { lineNumber: 1, columnNumber: 0 }, next); | |
43 } | |
44 ]); | |
45 | |
46 var finishedTests = 0; | |
47 function test(source, newSource, location, next) { | |
48 var sourceURL = `test${++finishedTests}.js`; | |
49 Protocol.Debugger.setBreakpointByUrl({ | |
alph
2017/02/28 00:47:26
await Protocol.Debugger.setBreakpointByUrl(...);
kozy
2017/02/28 01:56:26
done.
| |
50 url: sourceURL, | |
51 lineNumber: location.lineNumber, | |
52 columnNumber: location.columnNumber | |
53 }).then(() => Protocol.Runtime.evaluate({ expression: `${source}\n//# sourceUR L=${sourceURL}` })) | |
54 .then(() => Protocol.Runtime.evaluate({ expression: `${newSource}\n//# sourc eURL=${sourceURL}` })) | |
55 .then(next); | |
56 | |
57 var firstBreakpoint = true; | |
58 Protocol.Debugger.onBreakpointResolved(message => { | |
59 var lineNumber = message.params.location.lineNumber; | |
60 var columnNumber = message.params.location.columnNumber; | |
61 var currentSource = firstBreakpoint ? source : newSource; | |
62 var lines = currentSource.split('\n'); | |
63 lines = lines.map(line => line.substring(0, 77) + (line.length > 77 ? '...' : '')); | |
alph
2017/02/28 00:47:26
nit: line => line.length > 80 ? line.substring(0,
kozy
2017/02/28 01:56:26
Done.
| |
64 lines[lineNumber] = lines[lineNumber].slice(0, columnNumber) + '#' + lines[l ineNumber].slice(columnNumber); | |
65 InspectorTest.log(lines.join('\n')); | |
66 firstBreakpoint = false; | |
67 }); | |
68 } | |
OLD | NEW |