2017-02-27 20:20:39 +00:00
|
|
|
Checks Debugger.getPossibleBreakpoints
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
function testEval() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|eval('// comment only');
|
|
|
|
|C|eval('// comment only\n');
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
// function without return
|
|
|
|
function procedure() {
|
2017-03-06 20:47:55 +00:00
|
|
|
var a = |_|1;
|
|
|
|
var b = |_|2;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testProcedure() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|procedure();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function returnTrue() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return true;|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testIf() {
|
|
|
|
var a;
|
2017-03-07 13:27:55 +00:00
|
|
|
if (true) |_|a = true;
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|if (!a) {
|
|
|
|
|_|a = true;
|
2017-02-27 20:20:39 +00:00
|
|
|
} else {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|a = false;
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|if (|C|returnTrue()) {
|
|
|
|
|_|a = false;
|
2017-02-27 20:20:39 +00:00
|
|
|
} else {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|a = true;
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
2017-03-06 20:47:55 +00:00
|
|
|
function emptyFunction() {|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testEmptyFunction() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|emptyFunction();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function twoArguments(a1, a2) {
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testCallArguments() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|twoArguments(|C|emptyFunction(), |C|emptyFunction());
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testNested() {
|
|
|
|
function nested1() {
|
|
|
|
function nested2() {
|
|
|
|
function nested3() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
|
|
|
|C|nested3();
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return;|R|
|
|
|
|
}
|
2017-07-17 19:02:35 +00:00
|
|
|
return |C|nested2();|R|
|
2017-07-14 17:50:09 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|nested1();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function return42() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return 42;|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function returnCall() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return |C|return42();|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testCallAtReturn() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return |C|returnCall();|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function returnObject() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return ({ foo: () => |_|42|R| });|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testWith() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|with (|C|returnObject()) {
|
|
|
|
|C|foo();
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|with({}) {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return;|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-07-14 17:50:09 +00:00
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testForLoop() {
|
2017-03-06 20:47:55 +00:00
|
|
|
for (var i = |_|0; i |_|< 1; ++|_|i) {}
|
2017-07-17 19:02:35 +00:00
|
|
|
for (var i = |_|0; i |_|< 1; ++|_|i) i;
|
2017-03-06 20:47:55 +00:00
|
|
|
for (var i = |_|0; i |_|< 0; ++|_|i) {}
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testForOfLoop() {
|
2018-01-11 17:24:11 +00:00
|
|
|
for (var |C|k of |_|[]) {}
|
|
|
|
for (var |C|k of |_|[1]) |_|k;
|
2017-03-06 20:47:55 +00:00
|
|
|
var a = |_|[];
|
2018-01-11 17:24:11 +00:00
|
|
|
for (var |C|k of |_|a) {}
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testForInLoop() {
|
2017-03-06 20:47:55 +00:00
|
|
|
var o = |_|{};
|
|
|
|
for (var |_|k in |_|o) {}
|
|
|
|
for (var |_|k in |_|o) |_|k;
|
|
|
|
for (var |_|k in |_|{ a:1 }) {}
|
|
|
|
for (var |_|k in |_|{ a:1 }) |_|k;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testSimpleExpressions() {
|
2017-03-07 13:27:55 +00:00
|
|
|
1 + 2 + 3;
|
2017-03-06 20:47:55 +00:00
|
|
|
var a = |_|1;
|
|
|
|
|_|++a;
|
|
|
|
|_|a--;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
2017-12-06 17:27:18 +00:00
|
|
|
|_|Object.|C|defineProperty(this, 'getterFoo', {
|
2017-03-06 20:47:55 +00:00
|
|
|
get: () => |_|return42|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function testGetter() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|getterFoo();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
2017-12-06 17:27:18 +00:00
|
|
|
var obj = |_|{
|
2017-03-06 20:47:55 +00:00
|
|
|
foo: () => (|_|{
|
|
|
|
boo: () => |_|return42|R|
|
|
|
|
})|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function testChainedCalls() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|obj.|C|foo().|C|boo()|C|();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testChainedWithNative() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|Array.|C|from([1]).|C|concat([2]).|C|map(v => v |_|* 2|R|);
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testPromiseThen() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return Promise.|C|resolve().|C|then(v => v |_|* 2|R|).|C|then(v => v |_|* 2|R|);|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testSwitch() {
|
2017-03-06 20:47:55 +00:00
|
|
|
for (var i = |_|0; i |_|< 3; ++|_|i) {
|
|
|
|
|_|switch(i) {
|
|
|
|
case 0: |_|continue;
|
|
|
|
case 1: |C|return42(); |_|break;
|
2017-07-14 17:50:09 +00:00
|
|
|
default: |_|return;|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
2018-01-16 10:25:57 +00:00
|
|
|
function* idMaker|_|() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|yield 1;
|
|
|
|
|_|yield 2;
|
|
|
|
|_|yield 3;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testGenerator() {
|
2017-03-06 20:47:55 +00:00
|
|
|
var gen = |C|idMaker();
|
|
|
|
|C|return42();
|
2017-07-17 19:02:35 +00:00
|
|
|
gen.|C|next().value;
|
2017-03-06 20:47:55 +00:00
|
|
|
|D|debugger;
|
2017-07-17 19:02:35 +00:00
|
|
|
gen.|C|next().value;
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|return42();
|
2017-07-17 19:02:35 +00:00
|
|
|
gen.|C|next().value;
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|return42();
|
2017-07-17 19:02:35 +00:00
|
|
|
gen.|C|next().value;
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function throwException() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|throw |C|new Error();
|
2017-03-07 13:27:55 +00:00
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testCaughtException() {
|
|
|
|
try {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|throwException()
|
2017-02-27 20:20:39 +00:00
|
|
|
} catch (e) {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return;|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function testClasses() {
|
2017-05-04 17:00:44 +00:00
|
|
|
class Cat {
|
2017-02-27 20:20:39 +00:00
|
|
|
constructor(name) {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|this.name = name;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
speak() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-05-04 17:00:44 +00:00
|
|
|
class Lion extends Cat {
|
2017-02-27 20:20:39 +00:00
|
|
|
constructor(name) {
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|super(name);
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
speak() {
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|super.|C|speak();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|new Lion().|C|speak();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
async function asyncFoo() {
|
2017-05-18 19:45:52 +00:00
|
|
|
|_|await Promise.|C|resolve().|C|then(v => v |_|* 2|R|);
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|return42();
|
|
|
|
|_|await |C|asyncBoo();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
async function asyncBoo() {
|
2017-05-18 19:45:52 +00:00
|
|
|
|_|await Promise.|C|resolve();
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
async function testAsyncAwait() {
|
2017-05-18 19:45:52 +00:00
|
|
|
|_|await |C|asyncFoo();
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|await |C|awaitBoo();
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
// TODO(kozyatinskiy): fix this.
|
|
|
|
async function testPromiseAsyncWithCode() {
|
|
|
|
var nextTest;
|
2017-03-06 20:47:55 +00:00
|
|
|
var testPromise = |C|new Promise(resolve => nextTest |_|= resolve|R|);
|
2017-02-27 20:20:39 +00:00
|
|
|
async function main() {
|
|
|
|
async function foo() {
|
|
|
|
var resolveNested;
|
2017-03-06 20:47:55 +00:00
|
|
|
var p = |C|new Promise(resolve => resolveNested |_|= resolve|R|);
|
|
|
|
|C|setTimeout(resolveNested, 0);
|
2017-07-13 13:53:13 +00:00
|
|
|
|_|await p;
|
2017-03-06 20:47:55 +00:00
|
|
|
|R|}
|
|
|
|
|C|setTimeout(returnCall, 0);
|
2018-01-16 10:25:57 +00:00
|
|
|
|_|await |C|foo();
|
|
|
|
|_|await |C|foo();
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|nextTest();
|
|
|
|
|R|}
|
|
|
|
|C|main();
|
|
|
|
|_|return testPromise;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function returnFunction() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return returnObject;|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
async function testPromiseComplex() {
|
|
|
|
var nextTest;
|
2017-03-06 20:47:55 +00:00
|
|
|
var testPromise = |C|new Promise(resolve => nextTest |_|= resolve|R|);
|
2017-02-27 20:20:39 +00:00
|
|
|
async function main() {
|
|
|
|
async function foo() {
|
2017-05-18 19:45:52 +00:00
|
|
|
|_|await Promise.|C|resolve();
|
2017-03-06 20:47:55 +00:00
|
|
|
|_|return 42;
|
|
|
|
|R|}
|
|
|
|
var x = |_|1;
|
|
|
|
var y = |_|2;
|
2018-01-16 10:25:57 +00:00
|
|
|
|C|returnFunction(|C|emptyFunction(), x++, --y, x => 2 |_|* x|R|, |C|returnCall())|C|().a = |_|await |C|foo((a => 2 |_|*a|R|)|C|(5));
|
2017-03-06 20:47:55 +00:00
|
|
|
|C|nextTest();
|
|
|
|
|R|}
|
|
|
|
|C|main();
|
|
|
|
|_|return testPromise;
|
|
|
|
|R|}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
|
|
|
function twiceDefined() {
|
2017-12-06 17:27:18 +00:00
|
|
|
|_|return a + b;|R|
|
2017-02-27 20:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function twiceDefined() {
|
2017-07-14 17:50:09 +00:00
|
|
|
|_|return a + b;|R|
|
|
|
|
}
|
2017-02-27 20:20:39 +00:00
|
|
|
|
2018-06-18 07:14:06 +00:00
|
|
|
|
[inspector] moved var initialization break location before init expression (reland)
This CL improves break locations for expressions like 'var a = <expr>'. Without CL we use <expr> position as break location for initialization statement, with this CL we use position of first character after '=' as position.
Benefits (see test for details):
- only one break in expressions which includes mix of property lookup and calls, e.g. var p = Promise.resolve().then(x => x * 2),
- removed redundant break location for expressions like: let { x, y } = { x: 1, y: 2}.
TBR=dgozman@chromium.org,rmcilroy@chromium.org,machenbach@chromium.org,marja@chromium.org,kozyatinskiy@chromium.org,devtools-reviews@chromium.org,v8-reviews@googlegroups.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:5909
Change-Id: Ie84fa79afeed09e28cf8478ba610a0cfbfdfc294
Reviewed-on: https://chromium-review.googlesource.com/518116
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45598}
2017-05-30 12:25:55 +00:00
|
|
|
|