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

Side by Side Diff: test/inspector/debugger/get-possible-breakpoints-restrict-to-function.js

Issue 2710953004: [inspector] added restrictToFunction flag for getPossibleBreakpoints (Closed)
Patch Set: addressed comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 Debugger.getPossibleBreakpoints with ignoreNestedFunctions');
6
7 var source = `
8 function test() {
9 Array.from([1,2]).map(() => 1).filter(() => true);
10 function nested1() {
11 Array.from([1,2]).map(() => 1).filter(() => true);
12 }
13 function nested2() {
14 Array.from([1,2]).map(() => 1).filter(() => true);
15 }
16 nested1();
17 nested2();
18 }
19 //# sourceURL=test.js`;
20 InspectorTest.addScript(source);
21
22 var scriptId;
23 Protocol.Debugger.onceScriptParsed().then(message => {
24 if (message.params.url === 'test.js')
25 scriptId = message.params.scriptId;
26 }).then(() => InspectorTest.runTestSuite(tests));
27
28 InspectorTest.setupScriptMap();
29 Protocol.Debugger.onPaused(dumpBreakLocationInSourceAndResume);
30
31 Protocol.Debugger.enable();
32 var tests = [
33 function testWholeFunction(next) {
34 Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), ignoreNes tedFunctions: false })
35 .then(dumpAllLocations)
36 .then(next);
37 },
38
39 function testWholeFunctionWithoutNested(next) {
40 Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), ignoreNes tedFunctions: true })
41 .then(dumpAllLocations)
42 .then(next);
43 },
44
45 function testPartOfFunctionWithoutNested(next) {
46 Protocol.Debugger.getPossibleBreakpoints({ start: location(1, 18), end: loca tion(2, 18), ignoreNestedFunctions: true })
47 .then(dumpAllLocations)
48 .then(next);
49 },
50
51 function testNestedFunction(next) {
52 Protocol.Debugger.getPossibleBreakpoints({ start: location(4, 0), ignoreNest edFunctions: true })
53 .then(dumpAllLocations)
54 .then(setAllBreakpoints)
55 .then(() => InspectorTest.log('Run test() to check breakpoints..'))
56 .then(() => Protocol.Runtime.evaluate({ expression: 'test()' }))
57 .then(next);
58 }
59 ];
60
61 function location(lineNumber, columnNumber) {
62 return { lineNumber: lineNumber, columnNumber: columnNumber, scriptId: scriptI d };
63 }
64
65 function setAllBreakpoints(message) {
66 var promises = [];
67 for (var location of message.result.locations)
68 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c heckBreakpoint));
69 return Promise.all(promises);
70 }
71
72 function checkBreakpoint(message) {
73 if (message.error) {
74 InspectorTest.log('FAIL: error in setBreakpoint');
75 InspectorTest.logMessage(message);
76 return;
77 }
78 var id_data = message.result.breakpointId.split(':');
79 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse Int(id_data[2]) !== message.result.actualLocation.columnNumber) {
80 InspectorTest.log('FAIL: possible breakpoint was resolved in another locatio n');
81 }
82 }
83
84 function dumpAllLocations(message) {
85 if (message.error) {
86 InspectorTest.logMessage(message);
87 return;
88 }
89
90 var sourceLines = source.split('\n')
91 var lineOffsets = Array(sourceLines.length).fill(0);
92 for (var location of message.result.locations) {
93 var lineNumber = location.lineNumber;
94 var columnNumber = location.columnNumber;
95 var line = sourceLines[lineNumber] || '';
96 var offset = lineOffsets[lineNumber];
97 line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber + offset);
98 ++lineOffsets[lineNumber];
99 sourceLines[lineNumber] = line;
100 }
101 InspectorTest.log(sourceLines.join('\n'));
102 return message;
103 }
104
105 function dumpBreakLocationInSourceAndResume(message) {
106 InspectorTest.logCallFrames([ message.params.callFrames[0] ]);
107
108 var location = message.params.callFrames[0].location;
109 var sourceLines = source.split('\n')
110
111 var lineNumber = location.lineNumber
112 var columnNumber = location.columnNumber;
113
114 var line = sourceLines[lineNumber];
115 line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber);
116 sourceLines[lineNumber] = line;
117 InspectorTest.log(sourceLines.join('\n'));
118 InspectorTest.log('');
119 Protocol.Debugger.resume();
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698