OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // Flags: --expose-gc | |
5 | 4 |
6 print("Test for Debugger.getPossibleBreakpoints"); | 5 print("Test for Debugger.getPossibleBreakpoints"); |
7 | 6 |
8 Protocol.Runtime.enable(); | 7 Protocol.Runtime.enable(); |
9 Protocol.Debugger.enable(); | 8 Protocol.Debugger.enable(); |
10 | 9 |
11 InspectorTest.runTestSuite([ | 10 InspectorTest.runTestSuite([ |
| 11 |
12 function getPossibleBreakpointsInRange(next) { | 12 function getPossibleBreakpointsInRange(next) { |
13 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; | 13 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; |
14 var scriptId; | 14 var scriptId; |
15 compileScript(source) | 15 compileScript(source) |
16 .then(id => scriptId = id) | 16 .then(id => scriptId = id) |
17 .then(() => InspectorTest.log("Test start.scriptId != end.scriptId.")) | 17 .then(() => InspectorTest.log("Test start.scriptId != end.scriptId.")) |
18 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId + "0" }})) | 18 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId + "0" }})) |
19 .then(InspectorTest.logMessage) | 19 .then(InspectorTest.logMessage) |
20 .then(() => InspectorTest.log("Test not existing scriptId.")) | 20 .then(() => InspectorTest.log("Test not existing scriptId.")) |
21 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: "-1" }})) | 21 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: "-1" }})) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Protocol.Debugger.resume(); | 131 Protocol.Debugger.resume(); |
132 }); | 132 }); |
133 | 133 |
134 var source = `function foo5() { Promise.resolve().then(() => 42) } | 134 var source = `function foo5() { Promise.resolve().then(() => 42) } |
135 function foo6() { Promise.resolve().then(() => 42) }`; | 135 function foo6() { Promise.resolve().then(() => 42) }`; |
136 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undef
ined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) | 136 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undef
ined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) |
137 .then(InspectorTest.logMessage) | 137 .then(InspectorTest.logMessage) |
138 .then(setAllBreakpoints) | 138 .then(setAllBreakpoints) |
139 .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) | 139 .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) |
140 .then(next); | 140 .then(next); |
| 141 }, |
| 142 |
| 143 function arrowFunctionReturn(next) { |
| 144 waitForPossibleBreakpoints("() => 239\n", { lineNumber: 0, columnNumber: 0 }
) |
| 145 .then(InspectorTest.logMessage) |
| 146 .then(() => waitForPossibleBreakpoints("function foo() { function boo() {
return 239 } }\n", { lineNumber: 0, columnNumber: 0 })) |
| 147 .then(InspectorTest.logMessage) |
| 148 .then(() => waitForPossibleBreakpoints("() => { 239 }\n", { lineNumber: 0,
columnNumber: 0 })) |
| 149 .then(InspectorTest.logMessage) |
| 150 // TODO(kozyatinskiy): lineNumber for return position should be 21 instead
of 22. |
| 151 .then(() => waitForPossibleBreakpoints("function foo() { 239 }\n", { lineN
umber: 0, columnNumber: 0 })) |
| 152 .then(InspectorTest.logMessage) |
| 153 // TODO(kozyatinskiy): lineNumber for return position should be only 9, no
t 8. |
| 154 .then(() => waitForPossibleBreakpoints("() => 239", { lineNumber: 0, colum
nNumber: 0 })) |
| 155 .then(InspectorTest.logMessage) |
| 156 // TODO(kozyatinskiy): lineNumber for return position should be only 19, n
ot 20. |
| 157 .then(() => waitForPossibleBreakpoints("() => { return 239 }", { lineNumbe
r: 0, columnNumber: 0 })) |
| 158 .then(InspectorTest.logMessage) |
| 159 .then(next) |
141 } | 160 } |
142 | |
143 ]); | 161 ]); |
144 | 162 |
145 function compileScript(source, origin) { | 163 function compileScript(source, origin) { |
146 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); | 164 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); |
147 if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; | 165 if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; |
148 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset); | 166 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset); |
149 return promise; | 167 return promise; |
150 } | 168 } |
151 | 169 |
152 function waitForPossibleBreakpoints(source, start, end, origin) { | 170 function waitForPossibleBreakpoints(source, start, end, origin) { |
(...skipping 23 matching lines...) Expand all Loading... |
176 InspectorTest.logMessage(message); | 194 InspectorTest.logMessage(message); |
177 return; | 195 return; |
178 } | 196 } |
179 var id_data = message.result.breakpointId.split(":"); | 197 var id_data = message.result.breakpointId.split(":"); |
180 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { | 198 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { |
181 InspectorTest.log("FAIL: possible breakpoint was resolved in another locatio
n"); | 199 InspectorTest.log("FAIL: possible breakpoint was resolved in another locatio
n"); |
182 InspectorTest.logMessage(message); | 200 InspectorTest.logMessage(message); |
183 } | 201 } |
184 InspectorTest.logMessage(message); | 202 InspectorTest.logMessage(message); |
185 } | 203 } |
OLD | NEW |