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([ |
12 function getPossibleBreakpointsInRange(next) { | 11 function getPossibleBreakpointsInRange(next) { |
13 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; | 12 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; |
14 var scriptId; | 13 var scriptId; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Protocol.Debugger.resume(); | 130 Protocol.Debugger.resume(); |
132 }); | 131 }); |
133 | 132 |
134 var source = `function foo5() { Promise.resolve().then(() => 42) } | 133 var source = `function foo5() { Promise.resolve().then(() => 42) } |
135 function foo6() { Promise.resolve().then(() => 42) }`; | 134 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 }) | 135 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undef
ined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) |
137 .then(InspectorTest.logMessage) | 136 .then(InspectorTest.logMessage) |
138 .then(setAllBreakpoints) | 137 .then(setAllBreakpoints) |
139 .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) | 138 .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) |
140 .then(next); | 139 .then(next); |
| 140 }, |
| 141 |
| 142 function getPossibleBreakpointsForFunctionWithConstArray(next) { |
| 143 compileScript("function foo() { return []; }", { name: "with-offset.js", lin
e_offset: 0, column_offset: 0 }) |
| 144 .then((scriptId) => Protocol.Debugger.getPossibleBreakpoints({ start: { li
neNumber: 0, columnNumber: 0, scriptId: scriptId }})) |
| 145 .then(InspectorTest.logMessage) |
| 146 .then(next); |
141 } | 147 } |
142 | |
143 ]); | 148 ]); |
144 | 149 |
145 function compileScript(source, origin) { | 150 function compileScript(source, origin) { |
146 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); | 151 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); |
147 if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; | 152 if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; |
148 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset); | 153 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset); |
149 return promise; | 154 return promise; |
150 } | 155 } |
151 | 156 |
152 function waitForPossibleBreakpoints(source, start, end, origin) { | 157 function waitForPossibleBreakpoints(source, start, end, origin) { |
(...skipping 23 matching lines...) Expand all Loading... |
176 InspectorTest.logMessage(message); | 181 InspectorTest.logMessage(message); |
177 return; | 182 return; |
178 } | 183 } |
179 var id_data = message.result.breakpointId.split(":"); | 184 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) { | 185 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"); | 186 InspectorTest.log("FAIL: possible breakpoint was resolved in another locatio
n"); |
182 InspectorTest.logMessage(message); | 187 InspectorTest.logMessage(message); |
183 } | 188 } |
184 InspectorTest.logMessage(message); | 189 InspectorTest.logMessage(message); |
185 } | 190 } |
OLD | NEW |