Index: test/inspector/debugger/get-possible-breakpoints-master-test.js |
diff --git a/test/inspector/debugger/get-possible-breakpoints-master-test.js b/test/inspector/debugger/get-possible-breakpoints-master-test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fb946b4b1ef6536faf82b68e8cc89615db624335 |
--- /dev/null |
+++ b/test/inspector/debugger/get-possible-breakpoints-master-test.js |
@@ -0,0 +1,132 @@ |
+// Copyright 2017 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var source = ` |
+function test() { |
+ // for loops |
+ for (var i = 0; i < 128; ++i) { |
+ } |
+ for (var a of array) { |
+ } |
+ for (var a of [1,2,3]) { |
dgozman
2017/02/23 02:03:29
for (var a in {x:2})
kozy
2017/02/27 17:37:58
Done.
|
+ } |
+ for (var i = boo1(); i != boo2(); i += boo3()) { |
+ } |
+ // switch |
+ switch(val) { |
+ case 1: break; |
+ case 2: return; |
+ } |
+ switch(boo1()) { |
+ default: break; |
+ } |
+ // nested functions |
+ function nested1() {} |
dgozman
2017/02/23 02:03:29
Let's do double-nested as well.
kozy
2017/02/27 17:37:58
Done.
|
+ function nested2() { return 42; } |
dgozman
2017/02/23 02:03:29
function nested3() { return; }
kozy
2017/02/27 17:37:58
Done.
|
+ // arrow function + assignment |
+ var a = () => 42; |
+ // var |
+ var b1 = 2; |
+ var b2 = 1 + 2; |
+ var b3 = ++b2; |
+ var b4 = boo4() + boo5(); |
+ // let |
+ let a1 = 1; |
+ let a2 = a1 + 2; |
+ let a3 = boo3() + boo4(); |
+ // const |
+ const c1 = 1; |
+ // while loops |
+ while (i < boo5()) { |
+ boo6(); |
+ break; |
+ } |
+ // continue |
+ while (i) { |
+ ++i; |
+ continue; |
+ } |
+ // debugger |
+ debugger; |
+ // do |
dgozman
2017/02/23 02:03:29
Forgot about if and with constructions, and also g
kozy
2017/02/27 17:37:58
Done.
|
+ do { |
+ boo7(); |
+ } while(boo5() + boo6()); |
+ // try |
+ try { |
+ throw new Error(); |
+ } catch (e) { |
+ boo2(); |
+ } finally { |
+ boo1(); |
+ } |
+ // obj literal |
+ var obj = { |
+ prop: 2 |
+ }; |
+ // arrow functions |
+ Promise.resolve().then(() => 42) |
+ .then(a => a++) |
+ .then(a => a()) |
+ .then(a => { boo1(); boo2(); }); |
+ // classes |
+ class Cat { |
+ constructor(name) { |
+ this.name = name; |
+ } |
+ |
+ speak() { |
+ } |
+ } |
+ class Lion extends Cat { |
+ constructor(name) { |
+ super(name); |
+ } |
+ |
+ speak() { |
+ super.speak(); |
+ } |
+ } |
+ // other expressions |
+ obj.a.b().c = obj.a().b.c(); |
+ 1 + 2; |
+ ({}).a = 42; |
+ ++a; |
+ boo() + foo(); |
+ // async await |
+ async function async1() { |
+ await Promise.resolve().then(() => 42); |
+ await async2(); |
+ } |
+ async function async2() { |
+ return 42; |
+ } |
+} |
dgozman
2017/02/23 02:03:29
Let's also have something complex like
foo(boo1()
kozy
2017/02/27 17:37:58
Done.
dgozman
2017/02/27 18:01:10
Forgot about this or did I miss it?
kozy
2017/02/27 18:54:19
lost during migration to test from step-into :( ad
|
+//# sourceURL=test.js`; |
+InspectorTest.addScript(source); |
+ |
+Protocol.Debugger.onceScriptParsed() |
+ .then(message => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber : 0, scriptId: message.params.scriptId }})) |
+ .then(dumpAllLocations) |
+ .then(InspectorTest.completeTest); |
+Protocol.Debugger.enable(); |
+ |
+function dumpAllLocations(message) { |
+ if (message.error) { |
+ InspectorTest.logMessage(message); |
+ return; |
+ } |
+ var lines = source.split('\n'); |
+ var locations = message.result.locations.sort((loc1, loc2) => { |
+ if (loc2.lineNumber !== loc1.lineNumber) return loc2.lineNumber - loc1.lineNumber; |
+ return loc2.columnNumber - loc1.columnNumber; |
+ }); |
+ for (var location of locations) { |
+ var line = lines[location.lineNumber]; |
+ line = line.slice(0, location.columnNumber) + '#' + line.slice(location.columnNumber); |
+ lines[location.lineNumber] = line; |
+ } |
+ InspectorTest.log(lines.join('\n')); |
+ return message; |
+} |