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

Side by Side Diff: test/inspector/debugger/get-possible-breakpoints-ignore-nested.js

Issue 2710953004: [inspector] added restrictToFunction flag for getPossibleBreakpoints (Closed)
Patch Set: 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(() => Protocol.Runtime.evaluate({ expression: 'test()' }))
56 .then(next);
57 }
58 ];
59
60 function location(lineNumber, columnNumber) {
61 return { lineNumber: lineNumber, columnNumber: columnNumber, scriptId: scriptI d };
62 }
63
64 function setAllBreakpoints(message) {
65 var promises = [];
66 for (var location of message.result.locations)
67 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c heckBreakpoint));
68 return Promise.all(promises);
69 }
70
71 function checkBreakpoint(message) {
72 if (message.error) {
73 InspectorTest.log('FAIL: error in setBreakpoint');
74 InspectorTest.logMessage(message);
75 return;
76 }
77 var id_data = message.result.breakpointId.split(':');
78 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse Int(id_data[2]) !== message.result.actualLocation.columnNumber) {
79 InspectorTest.log('FAIL: possible breakpoint was resolved in another locatio n');
80 }
81 }
82
83 function dumpAllLocations(message) {
84 if (message.error) {
85 InspectorTest.logMessage(message);
86 return;
87 }
88
89 var sourceLines = source.split('\n')
90 var lineOffsets = Array(sourceLines.length).fill(0);
91 for (var location of message.result.locations) {
92 var lineNumber = location.lineNumber;
93 var columnNumber = location.columnNumber;
94 var line = sourceLines[lineNumber] || '';
95 var offset = lineOffsets[lineNumber];
96 line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber + offset);
97 ++lineOffsets[lineNumber];
98 sourceLines[lineNumber] = line;
99 }
100 InspectorTest.log(sourceLines.join('\n'));
101 return message;
102 }
103
104 function dumpBreakLocationInSourceAndResume(message) {
105 InspectorTest.logCallFrames([ message.params.callFrames[0] ]);
106
107 var location = message.params.callFrames[0].location;
108 var sourceLines = source.split('\n')
109
110 var lineNumber = location.lineNumber
111 var columnNumber = location.columnNumber;
112
113 var line = sourceLines[lineNumber];
114 line = line.slice(0, columnNumber) + '#' + line.slice(columnNumber);
115 sourceLines[lineNumber] = line;
116 InspectorTest.log(sourceLines.join('\n'));
117 InspectorTest.log('');
118 Protocol.Debugger.resume();
119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698