diff options
Diffstat (limited to 'deps/v8/test/inspector/debugger')
42 files changed, 2584 insertions, 1249 deletions
diff --git a/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt b/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt index a92c9a00fb..2a538879ae 100644 --- a/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt +++ b/deps/v8/test/inspector/debugger/async-instrumentation-expected.txt @@ -1,7 +1,7 @@ Checks async instrumentation enabled in the middle. Running test: beforeAsyncTaskScheduled -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) @@ -19,7 +19,7 @@ test (test.js:20:2) Running test: afterAsyncTaskScheduled -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) @@ -31,7 +31,7 @@ foo (test.js:12:2) Running test: afterAsyncTaskStarted -test (test.js:19:2) +test (test.js:16:2) (anonymous) (expr1.js:0:0) test (test.js:21:2) diff --git a/deps/v8/test/inspector/debugger/async-instrumentation.js b/deps/v8/test/inspector/debugger/async-instrumentation.js index b61e28a2c4..777dec3a9c 100644 --- a/deps/v8/test/inspector/debugger/async-instrumentation.js +++ b/deps/v8/test/inspector/debugger/async-instrumentation.js @@ -13,10 +13,10 @@ function foo() { } function test() { + debugger; var resolve1; var p1 = new Promise(resolve => resolve1 = resolve); var p2 = p1.then(foo); - debugger; resolve1(); // asyncTaskScheduled debugger; return p2; diff --git a/deps/v8/test/inspector/debugger/async-stack-await-expected.txt b/deps/v8/test/inspector/debugger/async-stack-await-expected.txt index 1fda6b0d4b..506b9a268a 100644 --- a/deps/v8/test/inspector/debugger/async-stack-await-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stack-await-expected.txt @@ -1,33 +1,34 @@ Checks that async stacks works for async/await foo2 (test.js:15:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo2 (test.js:17:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo1 (test.js:9:2) foo2 (test.js:18:8) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:19:43)-- +-- Promise.resolve (test.js:19:16)-- foo2 (test.js:19:30) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) foo2 (test.js:20:2) --- async function -- +-- async function (test.js:13:19)-- foo2 (test.js:13:19) test (test.js:24:8) (anonymous) (expr.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stack-await.js b/deps/v8/test/inspector/debugger/async-stack-await.js index a7eb741904..50f423d044 100644 --- a/deps/v8/test/inspector/debugger/async-stack-await.js +++ b/deps/v8/test/inspector/debugger/async-stack-await.js @@ -28,12 +28,7 @@ async function test() { InspectorTest.setupScriptMap(); Protocol.Debugger.onPaused(message => { InspectorTest.logCallFrames(message.params.callFrames); - var asyncStackTrace = message.params.asyncStackTrace; - while (asyncStackTrace) { - InspectorTest.log(`-- ${asyncStackTrace.description} --`); - InspectorTest.logCallFrames(asyncStackTrace.callFrames); - asyncStackTrace = asyncStackTrace.parent; - } + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); InspectorTest.log(''); Protocol.Debugger.resume(); }); diff --git a/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt b/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt new file mode 100644 index 0000000000..6e61d1aca4 --- /dev/null +++ b/deps/v8/test/inspector/debugger/async-stack-created-frame-expected.txt @@ -0,0 +1,100 @@ +Checks created frame for async call chain + +Running test: testPromise +foo1 (test.js:10:2) +-- Promise.resolve (test.js:20:14)-- +promise (test.js:21:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseThen +foo1 (test.js:10:2) +-- Promise.resolve (test.js:28:14)-- +promiseThen (test.js:30:2) +(anonymous) (expr.js:0:0) + +foo2 (test.js:14:2) +-- Promise.resolve (test.js:29:14)-- +-- Promise.resolve (test.js:28:14)-- +promiseThen (test.js:30:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseThenThen +foo1 (test.js:10:2) +-- Promise.resolve (test.js:37:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + +foo1 (test.js:10:2) +-- Promise.resolve (test.js:38:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + +foo2 (test.js:14:2) +-- Promise.resolve (test.js:37:25)-- +-- Promise.resolve (test.js:37:14)-- +promiseThenThen (test.js:39:2) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseResolve +foo1 (test.js:10:2) +-- Promise.resolve (test.js:44:27)-- +promiseResolve (test.js:44:17) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseReject +foo1 (test.js:10:2) +-- Promise.reject (test.js:48:31)-- +promiseReject (test.js:48:17) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseAll +foo1 (test.js:10:2) +-- Promise.resolve (test.js:52:44)-- +-- Promise.resolve (test.js:52:17)-- +promiseAll (test.js:52:31) +(anonymous) (expr.js:0:0) + + +Running test: testPromiseRace +foo1 (test.js:10:2) +-- Promise.resolve (test.js:56:45)-- +-- Promise.resolve (test.js:56:17)-- +promiseRace (test.js:56:32) +(anonymous) (expr.js:0:0) + + +Running test: testThenableJob1 +foo1 (test.js:10:2) +-- Promise.resolve (test.js:60:72)-- +-- Promise.resolve (test.js:60:56)-- +Promise.resolve.then (test.js:60:46) +-- Promise.resolve (test.js:60:27)-- +thenableJob1 (test.js:60:17) +(anonymous) (expr.js:0:0) + + +Running test: testThenableJob2 +foo1 (test.js:10:2) +-- Promise.resolve (test.js:64:57)-- +Promise.resolve.then (test.js:64:46) +-- Promise.resolve (test.js:64:27)-- +thenableJob2 (test.js:64:17) +(anonymous) (expr.js:0:0) + + +Running test: testSetTimeouts +foo1 (test.js:10:2) +setTimeout (test.js:72:25) +-- setTimeout -- +setTimeout (test.js:72:6) +-- setTimeout -- +setTimeout (test.js:71:4) +-- setTimeout -- +setTimeouts (test.js:70:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/async-stack-created-frame.js b/deps/v8/test/inspector/debugger/async-stack-created-frame.js new file mode 100644 index 0000000000..e7430d7cfd --- /dev/null +++ b/deps/v8/test/inspector/debugger/async-stack-created-frame.js @@ -0,0 +1,178 @@ +// 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. + +print('Checks created frame for async call chain'); + +InspectorTest.addScript( + ` +function foo1() { + debugger; +} + +function foo2() { + debugger; +} + +function promise() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1); + resolve(); + return p2; +} + +function promiseThen() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1); + var p3 = p2.then(foo2); + resolve(); + return p3; +} + +function promiseThenThen() { + var resolve; + var p1 = new Promise(r => resolve = r); + var p2 = p1.then(foo1).then(foo2); + var p3 = p1.then(foo1); + resolve(); + return p2; +} + +function promiseResolve() { + return Promise.resolve().then(foo1); +} + +function promiseReject() { + return Promise.reject().catch(foo1); +} + +function promiseAll() { + return Promise.all([ Promise.resolve() ]).then(foo1); +} + +function promiseRace() { + return Promise.race([ Promise.resolve() ]).then(foo1); +} + +function thenableJob1() { + return Promise.resolve().then(() => Promise.resolve().then(() => 42)).then(foo1); +} + +function thenableJob2() { + return Promise.resolve().then(() => Promise.resolve()).then(foo1); +} + +function setTimeouts() { + var resolve; + var p = new Promise(r => resolve = r); + setTimeout(() => + setTimeout(() => + setTimeout(() => { foo1(); resolve(); }, 0), 0), 0); + return p; +} + +//# sourceURL=test.js`, + 8, 4); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); +Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128}); + +InspectorTest.runTestSuite([ + function testPromise(next) { + Protocol.Runtime + .evaluate( + {expression: 'promise()//# sourceURL=expr.js', awaitPromise: true}) + .then(next); + }, + + function testPromiseThen(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseThen()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseThenThen(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseThenThen()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseResolve(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseResolve()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseReject(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseReject()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseAll(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseAll()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testPromiseRace(next) { + Protocol.Runtime + .evaluate({ + expression: 'promiseRace()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testThenableJob1(next) { + Protocol.Runtime + .evaluate({ + expression: 'thenableJob1()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testThenableJob2(next) { + Protocol.Runtime + .evaluate({ + expression: 'thenableJob2()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + }, + + function testSetTimeouts(next) { + Protocol.Runtime + .evaluate({ + expression: 'setTimeouts()//# sourceURL=expr.js', + awaitPromise: true + }) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt b/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt index dfa5951909..a948803f28 100644 --- a/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stack-for-promise-expected.txt @@ -2,13 +2,14 @@ Checks that async chains for promises are correct. Running test: testPromise foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:19:14)-- promise (test.js:20:2) (anonymous) (testPromise.js:0:0) Running test: testPromiseResolvedBySetTimeout foo1 (test.js:9:2) +-- Promise.resolve (test.js:27:14)-- -- setTimeout -- promiseResolvedBySetTimeout (test.js:28:2) (anonymous) (testPromiseResolvedBySetTimeout.js:0:0) @@ -16,96 +17,103 @@ promiseResolvedBySetTimeout (test.js:28:2) Running test: testPromiseAll foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:37:35)-- +-- Promise.resolve (test.js:37:19)-- promiseAll (test.js:39:2) (anonymous) (testPromiseAll.js:0:0) Running test: testPromiseAllReverseOrder foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:48:35)-- +-- Promise.resolve (test.js:48:19)-- promiseAllReverseOrder (test.js:50:2) (anonymous) (testPromiseAllReverseOrder.js:0:0) Running test: testPromiseRace foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:59:36)-- +-- Promise.resolve (test.js:59:19)-- promiseRace (test.js:60:2) (anonymous) (testPromiseRace.js:0:0) Running test: testTwoChainedCallbacks foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:68:14)-- twoChainedCallbacks (test.js:69:2) (anonymous) (testTwoChainedCallbacks.js:0:0) foo2 (test.js:13:2) --- Promise.resolve -- +-- Promise.resolve (test.js:68:25)-- +-- Promise.resolve (test.js:68:14)-- twoChainedCallbacks (test.js:69:2) (anonymous) (testTwoChainedCallbacks.js:0:0) Running test: testPromiseResolve foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:74:27)-- promiseResolve (test.js:74:17) (anonymous) (testPromiseResolve.js:0:0) foo2 (test.js:13:2) --- Promise.resolve -- +-- Promise.resolve (test.js:74:38)-- +-- Promise.resolve (test.js:74:27)-- promiseResolve (test.js:74:17) (anonymous) (testPromiseResolve.js:0:0) Running test: testThenableJobResolvedInSetTimeout foo1 (test.js:9:2) +-- Promise.resolve (test.js:86:40)-- -- setTimeout -- thenableJob (test.js:81:4) p1.then (test.js:86:25) --- Promise.resolve -- +-- Promise.resolve (test.js:86:14)-- thenableJobResolvedInSetTimeout (test.js:87:2) (anonymous) (testThenableJobResolvedInSetTimeout.js:0:0) Running test: testThenableJobResolvedInSetTimeoutWithStack foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:104:40)-- inner (test.js:94:6) -- setTimeout -- thenableJob (test.js:99:4) p1.then (test.js:104:25) --- Promise.resolve -- +-- Promise.resolve (test.js:104:14)-- thenableJobResolvedInSetTimeoutWithStack (test.js:105:2) (anonymous) (testThenableJobResolvedInSetTimeoutWithStack.js:0:0) Running test: testThenableJobResolvedByPromise foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:118:40)-- +-- Promise.resolve (test.js:113:22)-- thenableJob (test.js:113:12) p1.then (test.js:118:25) --- Promise.resolve -- +-- Promise.resolve (test.js:118:14)-- thenableJobResolvedByPromise (test.js:119:2) (anonymous) (testThenableJobResolvedByPromise.js:0:0) Running test: testThenableJobResolvedByPromiseWithStack foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:136:40)-- inner (test.js:126:6) --- Promise.resolve -- +-- Promise.resolve (test.js:131:22)-- thenableJob (test.js:131:12) p1.then (test.js:136:25) --- Promise.resolve -- +-- Promise.resolve (test.js:136:14)-- thenableJobResolvedByPromiseWithStack (test.js:137:2) (anonymous) (testThenableJobResolvedByPromiseWithStack.js:0:0) Running test: testLateThenCallback foo1 (test.js:9:2) --- Promise.resolve -- +-- Promise.resolve (test.js:145:12)-- lateThenCallback (test.js:144:2) (anonymous) (testLateThenCallback.js:0:0) @@ -113,43 +121,54 @@ lateThenCallback (test.js:144:2) Running test: testComplex inner1 (test.js:154:6) foo1 (test.js:156:4) --- Promise.resolve -- +-- Promise.resolve (test.js:202:5)-- inner2 (test.js:162:6) --- Promise.resolve -- +-- Promise.resolve (test.js:165:22)-- foo2 (test.js:165:12) --- Promise.resolve -- +-- Promise.resolve (test.js:201:5)-- inner3 (test.js:172:6) -- setTimeout -- foo3 (test.js:175:4) --- Promise.resolve -- +-- Promise.resolve (test.js:200:5)-- +-- Promise.resolve (test.js:199:5)-- +-- Promise.resolve (test.js:188:7)-- +-- Promise.resolve (test.js:187:19)-- foo5 (test.js:187:52) --- Promise.resolve -- +-- Promise.resolve (test.js:198:5)-- +-- Promise.resolve (test.js:193:7)-- +-- Promise.resolve (test.js:192:19)-- foo6 (test.js:192:34) --- Promise.resolve -- +-- Promise.resolve (test.js:197:5)-- complex (test.js:196:18) (anonymous) (testComplex.js:0:0) p.then (test.js:207:8) --- Promise.resolve -- +-- Promise.resolve (test.js:206:8)-- +-- Promise.resolve (test.js:202:5)-- inner2 (test.js:162:6) --- Promise.resolve -- +-- Promise.resolve (test.js:165:22)-- foo2 (test.js:165:12) --- Promise.resolve -- +-- Promise.resolve (test.js:201:5)-- inner3 (test.js:172:6) -- setTimeout -- foo3 (test.js:175:4) --- Promise.resolve -- +-- Promise.resolve (test.js:200:5)-- +-- Promise.resolve (test.js:199:5)-- +-- Promise.resolve (test.js:188:7)-- +-- Promise.resolve (test.js:187:19)-- foo5 (test.js:187:52) --- Promise.resolve -- +-- Promise.resolve (test.js:198:5)-- +-- Promise.resolve (test.js:193:7)-- +-- Promise.resolve (test.js:192:19)-- foo6 (test.js:192:34) --- Promise.resolve -- +-- Promise.resolve (test.js:197:5)-- complex (test.js:196:18) (anonymous) (testComplex.js:0:0) Running test: testReject foo1 (test.js:9:2) --- Promise.reject -- +-- Promise.reject (test.js:217:31)-- reject (test.js:217:17) (anonymous) (testReject.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stack-for-promise.js b/deps/v8/test/inspector/debugger/async-stack-for-promise.js index 705bb19086..a627747a55 100644 --- a/deps/v8/test/inspector/debugger/async-stack-for-promise.js +++ b/deps/v8/test/inspector/debugger/async-stack-for-promise.js @@ -222,12 +222,7 @@ function reject() { InspectorTest.setupScriptMap(); Protocol.Debugger.onPaused(message => { InspectorTest.logCallFrames(message.params.callFrames); - var asyncStackTrace = message.params.asyncStackTrace; - while (asyncStackTrace) { - InspectorTest.log(`-- ${asyncStackTrace.description} --`); - InspectorTest.logCallFrames(asyncStackTrace.callFrames); - asyncStackTrace = asyncStackTrace.parent; - } + InspectorTest.logAsyncStackTrace(message.params.asyncStackTrace); InspectorTest.log(''); Protocol.Debugger.resume(); }); diff --git a/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt b/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt index 16270656c6..8dd1456990 100644 --- a/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt +++ b/deps/v8/test/inspector/debugger/async-stacks-limit-expected.txt @@ -4,7 +4,7 @@ Running test: testZeroLimit foo1 (test.js:11:2) -Running test: testOneLimit +Running test: testTwoLimit foo1 (test.js:11:2) -- Promise.resolve -- promise (test.js:23:2) @@ -17,11 +17,14 @@ foo1 (test.js:11:2) foo2 (test.js:15:2) -Running test: testTwoLimitTwoPromises +Running test: testFourLimitTwoPromises +foo1 (test.js:11:2) + +foo2 (test.js:15:2) + + +Running test: testSixLimitTwoPromises foo1 (test.js:11:2) --- Promise.resolve -- -twoPromises (test.js:34:2) -(anonymous) (expr.js:0:0) foo2 (test.js:15:2) -- Promise.resolve -- @@ -29,7 +32,7 @@ twoPromises (test.js:35:2) (anonymous) (expr.js:0:0) -Running test: testOneLimitTwoSetTimeouts +Running test: testTwoLimitTwoSetTimeouts foo1 (test.js:11:2) foo2 (test.js:15:2) @@ -38,7 +41,7 @@ twoSetTimeout (test.js:41:2) (anonymous) (expr.js:0:0) -Running test: testTwoLimitTwoSetTimeouts +Running test: testThreeLimitTwoSetTimeouts foo1 (test.js:11:2) -- setTimeout -- twoSetTimeout (test.js:40:2) @@ -84,54 +87,54 @@ foo10 (:0:18) foo11 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo12 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo13 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo14 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo15 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo16 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo17 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo18 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) foo19 (:0:18) (anonymous) (:0:29) -- setTimeout -- -twentySetTimeout (test.js:55:4) +twentySetTimeout (test.js:49:4) (anonymous) (expr.js:0:0) diff --git a/deps/v8/test/inspector/debugger/async-stacks-limit.js b/deps/v8/test/inspector/debugger/async-stacks-limit.js index b028b74aae..d3c47dbfd4 100644 --- a/deps/v8/test/inspector/debugger/async-stacks-limit.js +++ b/deps/v8/test/inspector/debugger/async-stacks-limit.js @@ -42,12 +42,6 @@ function twoSetTimeout() { return new Promise(resolve => resolveTest = resolve); } -function threeSetTimeout() { - setTimeout(foo1, 0); - setTimeout(foo2, 0); - return new Promise(resolve => resolveTest = resolve); -} - function twentySetTimeout() { var resolve1; var p1 = new Promise(resolve => resolve1 = resolve); @@ -85,14 +79,16 @@ InspectorTest.runTestSuite([ .then(next); }, - function testOneLimit(next) { - Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) - .then(() => Protocol.Runtime.evaluate({ - expression: 'promise()//# sourceURL=expr.js', awaitPromise: true - })) - .then(() => cancelAllAsyncTasks()) - .then(next); + function testTwoLimit(next) { + // we need one stack for parent task and one for next task. + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'promise()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); }, function testOneLimitTwoPromises(next) { @@ -108,19 +104,31 @@ InspectorTest.runTestSuite([ .then(next); }, - function testTwoLimitTwoPromises(next) { - Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) - .then(() => Protocol.Runtime.evaluate({ - expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true - })) - .then(() => cancelAllAsyncTasks()) - .then(next); + function testFourLimitTwoPromises(next) { + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(4)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'twoPromises()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); }, - function testOneLimitTwoSetTimeouts(next) { + function testSixLimitTwoPromises(next) { + Protocol.Runtime + .evaluate({expression: 'setMaxAsyncTaskStacks(6)//# sourceURL=expr.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'twoPromises()//# sourceURL=expr.js', + awaitPromise: true + })) + .then(() => cancelAllAsyncTasks()) + .then(next); + }, + + function testTwoLimitTwoSetTimeouts(next) { Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) + expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) .then(() => Protocol.Runtime.evaluate({ expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true })) @@ -128,9 +136,9 @@ InspectorTest.runTestSuite([ .then(next); }, - function testTwoLimitTwoSetTimeouts(next) { + function testThreeLimitTwoSetTimeouts(next) { Protocol.Runtime.evaluate({ - expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) + expression: 'setMaxAsyncTaskStacks(3)//# sourceURL=expr.js'}) .then(() => Protocol.Runtime.evaluate({ expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true })) diff --git a/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt b/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt new file mode 100644 index 0000000000..26b35c5b26 --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-script-parsed-expected.txt @@ -0,0 +1,55 @@ +Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module + +Running test: testLoadedModulesOnDebuggerEnable +{ + method : Debugger.scriptParsed + params : { + endColumn : 1 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : F8E59942466284E2766FD161CA6FFD024048A807 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module1.js + } +} + +Running test: testScriptEventsWhenDebuggerIsEnabled +{ + method : Debugger.scriptParsed + params : { + endColumn : 1 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : F8E59942466284E2766FD161CA6FFD024048A807 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module2.js + } +} +{ + method : Debugger.scriptFailedToParse + params : { + endColumn : 1 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module-with-syntax-error-2.js + } +} diff --git a/deps/v8/test/inspector/debugger/es6-module-script-parsed.js b/deps/v8/test/inspector/debugger/es6-module-script-parsed.js new file mode 100644 index 0000000000..c822a3db1c --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-script-parsed.js @@ -0,0 +1,28 @@ +// 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. + +print('Debugger.scriptParsed and Debugger.scriptFailedToParse with ES6 module'); + +let moduleSource = ` +export function foo() { + return 42; +}`; + +InspectorTest.addModule(moduleSource, 'module1.js'); +InspectorTest.addModule('}', 'module-with-syntax-error-1.js'); + +Protocol.Debugger.onScriptParsed(InspectorTest.logMessage); +Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage); + +InspectorTest.runTestSuite([ + function testLoadedModulesOnDebuggerEnable(next) { + Protocol.Debugger.enable().then(next); + }, + + function testScriptEventsWhenDebuggerIsEnabled(next) { + InspectorTest.addModule(moduleSource, 'module2.js'); + InspectorTest.addModule('}', 'module-with-syntax-error-2.js'); + InspectorTest.waitPendingTasks().then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt b/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt new file mode 100644 index 0000000000..cd0ef1fa6e --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-set-script-source-expected.txt @@ -0,0 +1,8 @@ +Checks that Debugger.setScriptSource doesn't crash with modules +{ + error : { + code : -32000 + message : Editing module's script is not supported. + } + id : <messageId> +} diff --git a/deps/v8/test/inspector/debugger/es6-module-set-script-source.js b/deps/v8/test/inspector/debugger/es6-module-set-script-source.js new file mode 100644 index 0000000000..747c189f5a --- /dev/null +++ b/deps/v8/test/inspector/debugger/es6-module-set-script-source.js @@ -0,0 +1,33 @@ +// 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. + +print('Checks that Debugger.setScriptSource doesn\'t crash with modules'); + +var module1 = ` +export function foo() { + return 42; +}`; + +var editedModule1 = ` +export function foo() { + return 239; +}`; + +var module2 = ` +import { foo } from 'module1'; +console.log(foo()); +`; + +var module1Id; +Protocol.Debugger.onScriptParsed(message => { + if (message.params.url === 'module1') + module1Id = message.params.scriptId; +}); +Protocol.Debugger.enable() + .then(() => InspectorTest.addModule(module1, 'module1')) + .then(() => InspectorTest.addModule(module2, 'module2')) + .then(() => InspectorTest.waitPendingTasks()) + .then(() => Protocol.Debugger.setScriptSource({ scriptId: module1Id, scriptSource: editedModule1 })) + .then(InspectorTest.logMessage) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/framework-break-expected.txt b/deps/v8/test/inspector/debugger/framework-break-expected.txt new file mode 100644 index 0000000000..4339645cc8 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-break-expected.txt @@ -0,0 +1,70 @@ +Checks that breaks in framework code correctly processed. + +Running test: testConsoleAssert +> all frames in framework: +> mixed, top frame in framework: +frameworkAssert (framework.js:10:10) +(anonymous) (user.js:0:0) + + +Running test: testCaughtException +> all frames in framework: +> mixed, top frame in framework: + +Running test: testUncaughtException +> all frames in framework: +> mixed, top frame in framework: +throwUncaughtError (framework.js:21:2) +(anonymous) (user.js:0:0) + + +Running test: testUncaughtExceptionWithInlinedFrame +> mixed top frame in framework: +throwUserException (user.js:66:2) +inlinedWrapper (framework.js:56:4) +throwInlinedUncaughtError (framework.js:59:2) +(anonymous) (framework.js:0:0) + + +Running test: testBreakpoint +> all frames in framework: +breakpoint (framework.js:25:2) +(anonymous) (framework.js:0:0) + +> mixed, top frame in framework: +breakpoint (framework.js:25:2) +(anonymous) (user.js:0:0) + + +Running test: testDebuggerStatement +> all frames in framework: +> mixed, top frame in framework: + +Running test: testSyncDOMBreakpoint +> all frames in framework: +> mixed, top frame in framework: +syncDOMBreakpoint (framework.js:33:2) +(anonymous) (user.js:0:0) + + +Running test: testSyncDOMBreakpointWithInlinedUserFrame +> mixed, top frame in framework: +syncDOMBreakpoint (framework.js:33:2) +userFunction (user.js:70:2) +inlinedWrapper (framework.js:64:4) +syncDOMBreakpointWithInlinedUserFrame (framework.js:67:2) +(anonymous) (framework.js:0:0) + + +Running test: testAsyncDOMBreakpoint +> all frames in framework: +(anonymous) (user.js:0:0) + + +Running test: testCaughtSyntaxError +> all frames in framework: +> mixed, top frame in framework: + +Running test: testCaughtJSONParseError +> all frames in framework: +> mixed, top frame in framework: diff --git a/deps/v8/test/inspector/debugger/framework-break.js b/deps/v8/test/inspector/debugger/framework-break.js new file mode 100644 index 0000000000..42cdcf7624 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-break.js @@ -0,0 +1,234 @@ +// 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. +// Flags: --allow-natives-syntax + +print('Checks that breaks in framework code correctly processed.'); + +InspectorTest.addScript(` +function frameworkAssert() { + console.assert(false); +} + +function throwCaughtError() { + try { + throw new Error(); + } catch (e) { + } +} + +function throwUncaughtError() { + throw new Error(); +} + +function breakpoint() { + return 239; +} + +function debuggerStatement() { + debugger; +} + +function syncDOMBreakpoint() { + breakProgram('', ''); +} + +function asyncDOMBreakpoint() { + return 42; +} + +function throwCaughtSyntaxError() { + try { + eval('}'); + } catch (e) { + } +} + +function throwFromJSONParse() { + try { + JSON.parse('ping'); + } catch (e) { + } +} + +function throwInlinedUncaughtError() { + function inlinedWrapper() { + throwUserException(); + } + %OptimizeFunctionOnNextCall(inlinedWrapper); + inlinedWrapper(); +} + +function syncDOMBreakpointWithInlinedUserFrame() { + function inlinedWrapper() { + userFunction(); + } + %OptimizeFunctionOnNextCall(inlinedWrapper); + inlinedWrapper(); +} + +//# sourceURL=framework.js`, 8, 26); + +InspectorTest.addScript(` +function throwUserException() { + throw new Error(); +} + +function userFunction() { + syncDOMBreakpoint(); +} + +//# sourceURL=user.js`, 64, 26) + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); +Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); + +InspectorTest.runTestSuite([ + function testConsoleAssert(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'frameworkAssert()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'frameworkAssert()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testCaughtException(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtError()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtError()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testUncaughtException(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwUncaughtError()//# sourceURL=user.js\', 0)'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testUncaughtExceptionWithInlinedFrame(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> mixed top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'setTimeout(\'throwInlinedUncaughtError()//# sourceURL=framework.js\', 0)//# sourceURL=framework.js'})) + .then(() => Protocol.Runtime.evaluate({ expression: "new Promise(resolve => setTimeout(resolve, 0))", awaitPromise: true})) + .then(next); + }, + + function testBreakpoint(next) { + Protocol.Debugger.setBreakpointByUrl({lineNumber: 25, url: 'framework.js'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'breakpoint()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'breakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testDebuggerStatement(next) { + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate({expression: 'debuggerStatement()//# sourceURL=framework.js'}) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'debuggerStatement()//# sourceURL=user.js'})) + .then(next); + }, + + function testSyncDOMBreakpoint(next) { + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate({expression: 'syncDOMBreakpoint()//# sourceURL=framework.js'}) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'syncDOMBreakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testSyncDOMBreakpointWithInlinedUserFrame(next) { + InspectorTest.log('> mixed, top frame in framework:'); + Protocol.Runtime + .evaluate({expression: 'syncDOMBreakpointWithInlinedUserFrame()//# sourceURL=framework.js'}) + .then(next); + }, + + function testAsyncDOMBreakpoint(next) { + schedulePauseOnNextStatement('', ''); + InspectorTest.log('> all frames in framework:'); + Protocol.Runtime + .evaluate( + {expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'}) + .then(() => cancelPauseOnNextStatement()) + .then( + () => Protocol.Runtime.evaluate( + {expression: '42//# sourceURL=user.js'})) + .then(() => schedulePauseOnNextStatement('', '')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'})) + .then(next); + }, + + function testCaughtSyntaxError(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then(() => Protocol.Runtime.evaluate({ + expression: 'throwCaughtSyntaxError()//# sourceURL=framework.js' + })) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwCaughtSyntaxError()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + }, + + function testCaughtJSONParseError(next) { + Protocol.Debugger.setPauseOnExceptions({state: 'all'}) + .then(() => InspectorTest.log('> all frames in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwFromJSONParse()//# sourceURL=framework.js'})) + .then(() => InspectorTest.log('> mixed, top frame in framework:')) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'throwFromJSONParse()//# sourceURL=user.js'})) + .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt new file mode 100644 index 0000000000..a7ab22229e --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break-expected.txt @@ -0,0 +1,41 @@ +Checks nested scheduled break in framework code. +break reason: framework-break +break aux data: { + "data": "data for framework-break" +} +doFrameworkBreak (framework.js:20:2) +doFrameworkWork (framework.js:15:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + +break reason: ambiguous +break aux data: { + "reasons": [ + { + "reason": "top-scheduled-break" + }, + { + "reason": "top-framework-scheduled-break", + "auxData": { + "data": "data for top-framework-scheduled-break" + } + } + ] +} +callback (user.js:31:17) +doFrameworkWork (framework.js:16:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + +break reason: user-break +break aux data: { + "data": "data for user-break" +} +callback (user.js:32:2) +doFrameworkWork (framework.js:16:2) +frameworkCall (framework.js:9:2) +testFunction (user.js:27:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js new file mode 100644 index 0000000000..922cdd9fa9 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-nested-scheduled-break.js @@ -0,0 +1,49 @@ +// 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. + +print('Checks nested scheduled break in framework code.'); + +InspectorTest.addScript(` +function frameworkCall(callback) { + callWithScheduledBreak(doFrameworkWork.bind(null, callback), + 'top-framework-scheduled-break', + JSON.stringify({ data: 'data for top-framework-scheduled-break' })); +} + +function doFrameworkWork(callback) { + callWithScheduledBreak(doFrameworkBreak, 'should-not-be-a-reason', ''); + callback(); +} + +function doFrameworkBreak() { + breakProgram('framework-break', JSON.stringify({ data: 'data for framework-break' })); +} + +//# sourceURL=framework.js`, 7, 26); + +InspectorTest.addScript(` +function testFunction() { + callWithScheduledBreak(frameworkCall.bind(null, callback), + 'top-scheduled-break', ''); +} + +function callback() { + breakProgram('user-break', JSON.stringify({ data: 'data for user-break' })); + return 42; +} + +//# sourceURL=user.js`, 25, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.log('break reason: ' + message.params.reason); + InspectorTest.log('break aux data: ' + JSON.stringify(message.params.data || {}, null, ' ')); + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); +Protocol.Debugger.enable() + .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']})) + .then(() => Protocol.Runtime.evaluate({ expression: 'testFunction()//# sourceURL=expr.js'})) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt b/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt new file mode 100644 index 0000000000..c54587a7e2 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-precise-ranges-expected.txt @@ -0,0 +1,140 @@ +Checks framework debugging with blackboxed ranges. + +Running test: testEntireScript +{ + id : <messageId> + result : { + } +} + +Running test: testFooNotBlackboxed +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testFooBlackboxed +{ + id : <messageId> + result : { + } +} +testFunction (test.js:14:21) +(anonymous) (expr.js:0:0) + +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +testFunction (test.js:16:0) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed1 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed2 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + + +Running test: testBooPartiallyBlackboxed3 +{ + id : <messageId> + result : { + } +} +foo (test.js:8:12) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:9:2) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:12:2) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +boo (test.js:13:0) +foo (test.js:9:9) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + +foo (test.js:10:0) +testFunction (test.js:15:2) +(anonymous) (expr.js:0:0) + diff --git a/deps/v8/test/inspector/debugger/framework-precise-ranges.js b/deps/v8/test/inspector/debugger/framework-precise-ranges.js new file mode 100644 index 0000000000..cae0747b69 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-precise-ranges.js @@ -0,0 +1,78 @@ +// 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. + +print('Checks framework debugging with blackboxed ranges.'); + +InspectorTest.addScript( + ` +function foo() { + return boo(); +} +function boo() { + return 42; +} +function testFunction() { + foo(); +} +//# sourceURL=test.js`, + 7, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger.stepInto(); +}); +var scriptId; +Protocol.Debugger.onScriptParsed(message => { + if (message.params.url === 'test.js') { + scriptId = message.params.scriptId; + } +}); + +Protocol.Debugger.enable() + .then(() => Protocol.Debugger.setBlackboxPatterns({patterns: ['expr\.js']})) + .then(() => InspectorTest.runTestSuite(testSuite)); + +var testSuite = [ + function testEntireScript(next) { + testPositions([position(0, 0)]).then(next); + }, + function testFooNotBlackboxed(next) { + testPositions([position(11, 0)]).then(next); + }, + function testFooBlackboxed(next) { + testPositions([position(8, 0), position(10, 3)]).then(next); + }, + function testBooPartiallyBlackboxed1(next) { + // first line is not blackboxed, second and third - blackboxed. + testPositions([position(12, 0)]).then(next); + }, + function testBooPartiallyBlackboxed2(next) { + // first line is blackboxed, second - not, third - blackboxed. + testPositions([ + position(11, 0), position(12, 0), position(13, 0) + ]).then(next); + }, + function testBooPartiallyBlackboxed3(next) { + // first line is blackboxed, second and third - not. + testPositions([ + position(11, 0), position(12, 0), position(14, 0) + ]).then(next); + } +]; + +function testPositions(positions) { + schedulePauseOnNextStatement('', ''); + return Protocol.Debugger + .setBlackboxedRanges({scriptId: scriptId, positions: positions}) + .then(InspectorTest.logMessage) + .then( + () => Protocol.Runtime.evaluate( + {expression: 'testFunction()//# sourceURL=expr.js'})); +} + +function position(line, column) { + return {lineNumber: line, columnNumber: column}; +} diff --git a/deps/v8/test/inspector/debugger/framework-stepping-expected.txt b/deps/v8/test/inspector/debugger/framework-stepping-expected.txt new file mode 100644 index 0000000000..32b3886f88 --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-stepping-expected.txt @@ -0,0 +1,100 @@ +Checks stepping with blackboxed frames on stack + +Running test: testStepIntoFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userBoo (user.js:27:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOverFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +Executing stepOver... +userBoo (user.js:27:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +Executing stepOver... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOutFromUser +(anonymous) (expr.js:0:0) + +Executing stepInto... +Executing stepInto... +userFoo (user.js:23:2) +frameworkCall (framework.js:10:23) +testStepFromUser (user.js:31:2) +(anonymous) (expr.js:0:0) + +Executing stepOut... +testStepFromUser (user.js:32:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepIntoFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepInto... +userFoo (user.js:23:2) +frameworkBreakAndCall (framework.js:15:23) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOverFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepOver... +testStepFromFramework (user.js:36:0) +(anonymous) (expr.js:0:0) + +Executing resume... + +Running test: testStepOutFromFramework +frameworkBreakAndCall (framework.js:14:2) +testStepFromFramework (user.js:35:2) +(anonymous) (expr.js:0:0) + +Executing stepOut... +testStepFromFramework (user.js:36:0) +(anonymous) (expr.js:0:0) + +Executing resume... diff --git a/deps/v8/test/inspector/debugger/framework-stepping.js b/deps/v8/test/inspector/debugger/framework-stepping.js new file mode 100644 index 0000000000..de75eab9ab --- /dev/null +++ b/deps/v8/test/inspector/debugger/framework-stepping.js @@ -0,0 +1,113 @@ +// 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. + +print('Checks stepping with blackboxed frames on stack'); + +InspectorTest.addScript( + ` +function frameworkCall(funcs) { + for (var f of funcs) f(); +} + +function frameworkBreakAndCall(funcs) { + breakProgram('', ''); + for (var f of funcs) f(); +} +//# sourceURL=framework.js`, + 8, 4); + +InspectorTest.addScript( + ` +function userFoo() { + return 1; +} + +function userBoo() { + return 2; +} + +function testStepFromUser() { + frameworkCall([userFoo, userBoo]) +} + +function testStepFromFramework() { + frameworkBreakAndCall([userFoo, userBoo]); +} +//# sourceURL=user.js`, + 21, 4); + +InspectorTest.setupScriptMap(); + +Protocol.Debugger.enable() + .then( + () => Protocol.Debugger.setBlackboxPatterns( + {patterns: ['framework\.js']})) + .then(() => InspectorTest.runTestSuite(testSuite)); + +var testSuite = [ + function testStepIntoFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepInto', 'stepInto', 'print', // userBoo + 'stepInto', 'stepInto', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepOverFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepOver', 'stepOver', 'print', // userBoo + 'stepOver', 'stepOver', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepOutFromUser(next) { + schedulePauseOnNextStatement('', ''); + test('testStepFromUser()', [ + 'print', // before testStepFromUser call + 'stepInto', 'stepInto', 'print', // userFoo + 'stepOut', 'print' // testStepFromUser + ]).then(next); + }, + + function testStepIntoFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepInto', 'print', // userFoo + ]).then(next); + }, + + function testStepOverFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepOver', 'print', // testStepFromFramework + ]).then(next); + }, + + function testStepOutFromFramework(next) { + test('testStepFromFramework()', [ + 'print', // frameworkBreakAndCall + 'stepOut', 'print', // testStepFromFramework + ]).then(next); + } +]; + +function test(entryExpression, actions) { + Protocol.Debugger.onPaused(message => { + var action = actions.shift() || 'resume'; + if (action === 'print') { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + action = actions.shift() || 'resume'; + } + if (action) InspectorTest.log(`Executing ${action}...`); + Protocol.Debugger[action](); + }); + return Protocol.Runtime.evaluate( + {expression: entryExpression + '//# sourceURL=expr.js'}); +} diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js index e574f69c01..13e2920cc7 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js @@ -9,4 +9,4 @@ Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId) .then(InspectorTest.logMessage) .then(InspectorTest.completeTest); -compileAndRunWithOrigin("() => []", "", 0, 0); +InspectorTest.addScript("() => []"); diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt index 608abce218..c685625de8 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt @@ -18,1092 +18,254 @@ Test not existing scriptId. id : <messageId> } Test end < start. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in not first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in not first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ #return Promise.resolve().then(() => 42); } + + Test end is undefined -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 1 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 1 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test end.lineNumber > scripts.lineCount() -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 1 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 1 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 1 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test one string -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Test end.columnNumber > end.line.length(), should be the same as previous. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 42 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Running test: getPossibleBreakpointsInArrow -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 53 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 56 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 69 - lineNumber : 0 - scriptId : <scriptId> - } - [4] : { - columnNumber : 71 - lineNumber : 0 - scriptId : <scriptId> - } - [5] : { - columnNumber : 84 - lineNumber : 0 - scriptId : <scriptId> - } - [6] : { - columnNumber : 90 - lineNumber : 0 - scriptId : <scriptId> - } - [7] : { - columnNumber : 92 - lineNumber : 0 - scriptId : <scriptId> - } - [8] : { - columnNumber : 94 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +function foo() { #return Promise.#resolve().#then(() => #239#).#then(() => #42#).#then(() => #() => #42#) #} Running test: arrowFunctionFirstLine -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +function foo1() { #Promise.#resolve().#then(() => #42#) #} +function foo2() { Promise.resolve().then(() => 42) } paused in foo1 -{ - columnNumber : 18 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { ^Promise.resolve().then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } paused in foo1 -{ - columnNumber : 51 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.^resolve().then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } +paused in foo1 +function foo1() { Promise.resolve().^then(() => 42) } +function foo2() { Promise.resolve().then(() => 42) } +paused in foo1 +function foo1() { Promise.resolve().then(() => 42) ^} +function foo2() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.resolve().then(() => ^42) } +function foo2() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> -} +function foo1() { Promise.resolve().then(() => 42^) } +function foo2() { Promise.resolve().then(() => 42) } Running test: arrowFunctionOnPause -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> - } - [4] : { - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> - } - [5] : { - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> - } - [6] : { - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> - } - [7] : { - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> - } - [8] : { - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> - } - [9] : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - [10] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - [11] : { - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +#debugger; function foo3() { #Promise.#resolve().#then(() => #42#) #} +function foo4() { #Promise.#resolve().#then(() => #42#) #}; +#foo3(); +#foo4()#; paused in -{ - columnNumber : 0 - lineNumber : 2 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +^foo3(); +foo4(); paused in foo3 -{ - columnNumber : 28 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { ^Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in foo3 -{ - columnNumber : 61 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.^resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo3 +debugger; function foo3() { Promise.resolve().^then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo3 +debugger; function foo3() { Promise.resolve().then(() => 42) ^} +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in -{ - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +^foo4(); paused in foo4 -{ - columnNumber : 18 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { ^Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in foo4 -{ - columnNumber : 51 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.^resolve().then(() => 42) }; +foo3(); +foo4(); +paused in foo4 +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().^then(() => 42) }; +foo3(); +foo4(); +paused in foo4 +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) ^}; +foo3(); +foo4(); paused in -{ - columnNumber : 6 - lineNumber : 3 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4()^; paused in Promise.resolve.then -{ - columnNumber : 57 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => ^42) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 59 - lineNumber : 0 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42^) } +function foo4() { Promise.resolve().then(() => 42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => ^42) }; +foo3(); +foo4(); paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 1 - scriptId : <scriptId> -} +debugger; function foo3() { Promise.resolve().then(() => 42) } +function foo4() { Promise.resolve().then(() => 42^) }; +foo3(); +foo4(); Running test: getPossibleBreakpointsInRangeWithOffset Test empty range in first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test empty range in not first line. -{ - id : <messageId> - result : { - locations : [ - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ return Promise.resolve().then(() => 42); } + + Test one character range in not first line. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - ] - } -} +function foo(){ return Promise.resolve(); } +function boo(){ #return Promise.resolve().then(() => 42); } + + Test end is undefined -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 2 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 2 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 2 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test end.lineNumber > scripts.lineCount() -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - [2] : { - columnNumber : 16 - lineNumber : 2 - scriptId : <scriptId> - } - [3] : { - columnNumber : 52 - lineNumber : 2 - scriptId : <scriptId> - } - [4] : { - columnNumber : 54 - lineNumber : 2 - scriptId : <scriptId> - } - [5] : { - columnNumber : 57 - lineNumber : 2 - scriptId : <scriptId> - } - [6] : { - columnNumber : 0 - lineNumber : 3 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ #return Promise.#resolve().#then(() => #42#); #} +# + Test one string -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Test end.columnNumber > end.line.length(), should be the same as previous. -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 1 - scriptId : <scriptId> - } - [1] : { - columnNumber : 43 - lineNumber : 1 - scriptId : <scriptId> - } - ] - } -} +function foo(){ #return Promise.#resolve(); #} +function boo(){ return Promise.resolve().then(() => 42); } + + Running test: withOffset -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> - } - [1] : { - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> - } - [2] : { - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> - } - [3] : { - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> - } - [4] : { - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> - } - [5] : { - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> - } - [6] : { - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> - } - [7] : { - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} -{ - id : <messageId> - result : { - actualLocation : { - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> - } - breakpointId : <breakpointId> - } -} +function foo5() { #Promise.#resolve().#then(() => #42#) #} +function foo6() { #Promise.#resolve().#then(() => #42#) #} paused in foo5 -{ - columnNumber : 36 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { ^Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } paused in foo5 -{ - columnNumber : 69 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.^resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } +paused in foo5 +function foo5() { Promise.resolve().^then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) } +paused in foo5 +function foo5() { Promise.resolve().then(() => 42) ^} +function foo6() { Promise.resolve().then(() => 42) } paused in foo6 -{ - columnNumber : 18 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { ^Promise.resolve().then(() => 42) } paused in foo6 -{ - columnNumber : 51 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.^resolve().then(() => 42) } +paused in foo6 +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().^then(() => 42) } +paused in foo6 +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42) ^} paused in Promise.resolve.then -{ - columnNumber : 65 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => ^42) } +function foo6() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 67 - lineNumber : 3 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42^) } +function foo6() { Promise.resolve().then(() => 42) } paused in Promise.resolve.then -{ - columnNumber : 47 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => ^42) } paused in Promise.resolve.then -{ - columnNumber : 49 - lineNumber : 4 - scriptId : <scriptId> -} +function foo5() { Promise.resolve().then(() => 42) } +function foo6() { Promise.resolve().then(() => 42^) } Running test: arrowFunctionReturn -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 6 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 9 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 34 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 45 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 48 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 49 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 12 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 13 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 17 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 21 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 22 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 6 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [3] : { - columnNumber : 9 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} -{ - id : <messageId> - result : { - locations : [ - [0] : { - columnNumber : 0 - lineNumber : 0 - scriptId : <scriptId> - } - [1] : { - columnNumber : 8 - lineNumber : 0 - scriptId : <scriptId> - } - [2] : { - columnNumber : 19 - lineNumber : 0 - scriptId : <scriptId> - } - ] - } -} +#() => #239# + +function foo() { function boo() { #return 239 #} #}# + +#() => { #239 #}# + +function foo() { #239 #}# + +#() => #23#9# +#() => { #return 239 #} + +Running test: argumentsAsCalls +function foo(){#} +function boo(){#} +function main(f1,f2){#} +#main(#foo(), #boo());# + diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints.js b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js index b09c08de14..640c3e61ea 100644 --- a/deps/v8/test/inspector/debugger/get-possible-breakpoints.js +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -print("Test for Debugger.getPossibleBreakpoints"); +print('Test for Debugger.getPossibleBreakpoints'); Protocol.Runtime.enable(); Protocol.Debugger.enable(); @@ -10,160 +10,150 @@ Protocol.Debugger.enable(); InspectorTest.runTestSuite([ function getPossibleBreakpointsInRange(next) { - var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n"; + var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n'; var scriptId; compileScript(source) .then(id => scriptId = id) - .then(() => InspectorTest.log("Test start.scriptId != end.scriptId.")) - .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + "0" }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test not existing scriptId.")) - .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: "-1" }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end < start.")) + .then(() => InspectorTest.log('Test start.scriptId != end.scriptId.')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + '0' }})) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test not existing scriptId.')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: '-1' }})) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end < start.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test empty range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one character range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in not first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test empty range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in not first line.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one character range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end is undefined")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end is undefined')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one string")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test one string')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous.")) + .then(message => dumpAllLocations(message, source)) + .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 256, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(next); }, function getPossibleBreakpointsInArrow(next) { - var source = "function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }"; + var source = 'function foo() { return Promise.resolve().then(() => 239).then(() => 42).then(() => () => 42) }'; var scriptId; compileScript(source) .then(id => scriptId = id) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(next); }, function arrowFunctionFirstLine(next) { - Protocol.Debugger.onPaused(message => { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - }); + Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source)); var source = `function foo1() { Promise.resolve().then(() => 42) } function foo2() { Promise.resolve().then(() => 42) }`; waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lineNumber: 1, columnNumber: 0 }) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(setAllBreakpoints) - .then(() => Protocol.Runtime.evaluate({ expression: "foo1(); foo2()"})) + .then(() => Protocol.Runtime.evaluate({ expression: 'foo1(); foo2()'})) .then(next); }, function arrowFunctionOnPause(next) { - function dumpAndResume(message) { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - } - var source = `debugger; function foo3() { Promise.resolve().then(() => 42) } function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`; waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 }, undefined, next) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source)) .then(setAllBreakpoints) - .then(() => Protocol.Debugger.onPaused(dumpAndResume)) + .then(() => Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source))) .then(() => Protocol.Debugger.resume()); }, function getPossibleBreakpointsInRangeWithOffset(next) { - var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n"; + var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ return Promise.resolve().then(() => 42); }\n\n'; var scriptId; - compileScript(source, { name: "with-offset.js", line_offset: 1, column_offset: 1 }) + compileScript(source, { name: 'with-offset.js', line_offset: 1, column_offset: 1 }) .then(id => scriptId = id) - .then(() => InspectorTest.log("Test empty range in first line.")) + .then(() => InspectorTest.log('Test empty range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one character range in first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 18, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test empty range in not first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test empty range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one character range in not first line.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one character range in not first line.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 17, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end is undefined")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end is undefined')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test one string")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test one string')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 2, columnNumber: 0, scriptId: scriptId }})) - .then(InspectorTest.logMessage) - .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous.")) + .then(message => dumpAllLocations(message, source, 1, 1)) + .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(), should be the same as previous.')) .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 256, scriptId: scriptId }})) - .then(InspectorTest.logMessage) + .then(message => dumpAllLocations(message, source, 1, 1)) .then(next); }, function withOffset(next) { - Protocol.Debugger.onPaused(message => { - InspectorTest.log("paused in " + message.params.callFrames[0].functionName); - InspectorTest.logMessage(message.params.callFrames[0].location); - Protocol.Debugger.resume(); - }); + Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(message, source, 3, 18)); var source = `function foo5() { Promise.resolve().then(() => 42) } function foo6() { Promise.resolve().then(() => 42) }`; - waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) - .then(InspectorTest.logMessage) + waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undefined, { name: 'with-offset.js', line_offset: 3, column_offset: 18 }) + .then(message => dumpAllLocations(message, source, 3, 18)) .then(setAllBreakpoints) - .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) + .then(() => Protocol.Runtime.evaluate({ expression: 'foo5(); foo6()'})) .then(next); }, function arrowFunctionReturn(next) { - waitForPossibleBreakpoints("() => 239\n", { lineNumber: 0, columnNumber: 0 }) - .then(InspectorTest.logMessage) - .then(() => waitForPossibleBreakpoints("function foo() { function boo() { return 239 } }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - .then(() => waitForPossibleBreakpoints("() => { 239 }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - // TODO(kozyatinskiy): lineNumber for return position should be 21 instead of 22. - .then(() => waitForPossibleBreakpoints("function foo() { 239 }\n", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) + function checkSource(source, location) { + return waitForPossibleBreakpoints(source, location) + .then(message => dumpAllLocations(message, source)); + } + + checkSource('() => 239\n', { lineNumber: 0, columnNumber: 0 }) + .then(() => checkSource('function foo() { function boo() { return 239 } }\n', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('() => { 239 }\n', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('function foo() { 239 }\n', { lineNumber: 0, columnNumber: 0 })) // TODO(kozyatinskiy): lineNumber for return position should be only 9, not 8. - .then(() => waitForPossibleBreakpoints("() => 239", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - // TODO(kozyatinskiy): lineNumber for return position should be only 19, not 20. - .then(() => waitForPossibleBreakpoints("() => { return 239 }", { lineNumber: 0, columnNumber: 0 })) - .then(InspectorTest.logMessage) - .then(next) + .then(() => checkSource('() => 239', { lineNumber: 0, columnNumber: 0 })) + .then(() => checkSource('() => { return 239 }', { lineNumber: 0, columnNumber: 0 })) + .then(next); + }, + + function argumentsAsCalls(next) { + var source = 'function foo(){}\nfunction boo(){}\nfunction main(f1,f2){}\nmain(foo(), boo());\n'; + waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }) + .then(message => dumpAllLocations(message, source)) + .then(next); } ]); function compileScript(source, origin) { var promise = Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId); - if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; - compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset); + if (!origin) origin = { name: '', line_offset: 0, column_offset: 0 }; + compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column_offset, false); return promise; } @@ -184,20 +174,60 @@ function waitForPossibleBreakpointsOnPause(source, start, end, next) { function setAllBreakpoints(message) { var promises = []; for (var location of message.result.locations) - promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpointAndDump)); + promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpoint)); return Promise.all(promises); } -function checkBreakpointAndDump(message) { +function checkBreakpoint(message) { if (message.error) { - InspectorTest.log("FAIL: error in setBreakpoint"); + InspectorTest.log('FAIL: error in setBreakpoint'); InspectorTest.logMessage(message); return; } - var id_data = message.result.breakpointId.split(":"); + var id_data = message.result.breakpointId.split(':'); if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parseInt(id_data[2]) !== message.result.actualLocation.columnNumber) { - InspectorTest.log("FAIL: possible breakpoint was resolved in another location"); + InspectorTest.log('FAIL: possible breakpoint was resolved in another location'); + } +} + +function dumpAllLocations(message, source, lineOffset, columnOffset) { + if (message.error) { InspectorTest.logMessage(message); + return; + } + + lineOffset = lineOffset || 0; + columnOffset = columnOffset || 0; + + var sourceLines = source.split('\n') + var lineOffsets = Array(sourceLines.length).fill(0); + for (var location of message.result.locations) { + var lineNumber = location.lineNumber - lineOffset; + var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset; + var line = sourceLines[lineNumber] || ''; + var offset = lineOffsets[lineNumber]; + line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber + offset); + ++lineOffsets[lineNumber]; + sourceLines[lineNumber] = line; } - InspectorTest.logMessage(message); + InspectorTest.log(sourceLines.join('\n')); + return message; +} + +function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnOffset) { + lineOffset = lineOffset || 0; + columnOffset = columnOffset || 0; + + InspectorTest.log('paused in ' + message.params.callFrames[0].functionName); + var location = message.params.callFrames[0].location; + var sourceLines = source.split('\n') + + var lineNumber = location.lineNumber - lineOffset; + var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnNumber - columnOffset; + + var line = sourceLines[lineNumber]; + line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber); + sourceLines[lineNumber] = line; + InspectorTest.log(sourceLines.join('\n')); + Protocol.Debugger.resume(); } diff --git a/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt b/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt new file mode 100644 index 0000000000..f3b019d058 --- /dev/null +++ b/deps/v8/test/inspector/debugger/inspector-break-api-expected.txt @@ -0,0 +1,38 @@ +Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API + +Running test: testBreakProgram +Stack: +callBreakProgram (:9:2) +(anonymous) (:0:0) +Other data: +{ + method : Debugger.paused + params : { + data : { + a : 42 + } + hitBreakpoints : [ + ] + reason : reason + } +} + + +Running test: testSchedulePauseOnNextStatement +Stack: +(anonymous) (expr1.js:0:0) +Other data: +{ + method : Debugger.paused + params : { + data : { + a : 42 + } + hitBreakpoints : [ + ] + reason : reason + } +} + + +Running test: testCancelPauseOnNextStatement diff --git a/deps/v8/test/inspector/debugger/inspector-break-api.js b/deps/v8/test/inspector/debugger/inspector-break-api.js new file mode 100644 index 0000000000..af1f2df9dc --- /dev/null +++ b/deps/v8/test/inspector/debugger/inspector-break-api.js @@ -0,0 +1,50 @@ +// 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. + +print("Checks breakProgram,(schedule|cancel)PauseOnNextStatement test API"); + +InspectorTest.addScript(` +function callBreakProgram() { + breakProgram('reason', JSON.stringify({a: 42})); +} + +function foo() { + return 42; +}`, 7, 26); + +InspectorTest.setupScriptMap(); +Protocol.Debugger.onPaused(message => { + InspectorTest.log('Stack:'); + InspectorTest.logCallFrames(message.params.callFrames); + delete message.params.callFrames; + InspectorTest.log('Other data:'); + InspectorTest.logMessage(message); + InspectorTest.log(''); + Protocol.Debugger.resume(); +}); + +Protocol.Debugger.enable(); + +InspectorTest.runTestSuite([ + function testBreakProgram(next) { + Protocol.Runtime.evaluate({ expression: 'callBreakProgram()'}) + .then(next); + }, + + function testSchedulePauseOnNextStatement(next) { + schedulePauseOnNextStatement('reason', JSON.stringify({a: 42})); + Protocol.Runtime.evaluate({ expression: 'foo()//# sourceURL=expr1.js'}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'foo()//# sourceURL=expr2.js'})) + .then(() => cancelPauseOnNextStatement()) + .then(next); + }, + + function testCancelPauseOnNextStatement(next) { + schedulePauseOnNextStatement('reason', JSON.stringify({a: 42})); + cancelPauseOnNextStatement(); + Protocol.Runtime.evaluate({ expression: 'foo()'}) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt index 481ef8b1a3..6b0b8bf177 100644 --- a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt @@ -163,23 +163,19 @@ expression: (new Map([[1,2]])).entries() [[Entries]]: [ [0] : { + key : { + description : 1 + overflow : false + properties : [ + ] + type : number + } value : { - description : Array(2) + description : 2 overflow : false properties : [ - [0] : { - name : 0 - type : number - value : 1 - } - [1] : { - name : 1 - type : number - value : 2 - } ] - subtype : array - type : object + type : number } } ] @@ -209,15 +205,13 @@ expression: (new Set([[1,2]])).entries() properties : [ [0] : { name : 0 - subtype : array - type : object - value : Array(2) + type : number + value : 1 } [1] : { name : 1 - subtype : array - type : object - value : Array(2) + type : number + value : 2 } ] subtype : array diff --git a/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt b/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt new file mode 100644 index 0000000000..4ca988deca --- /dev/null +++ b/deps/v8/test/inspector/debugger/pause-on-oom-expected.txt @@ -0,0 +1,2 @@ +Check pause on OOM +reason: OOM diff --git a/deps/v8/test/inspector/debugger/pause-on-oom.js b/deps/v8/test/inspector/debugger/pause-on-oom.js new file mode 100644 index 0000000000..84995dbf39 --- /dev/null +++ b/deps/v8/test/inspector/debugger/pause-on-oom.js @@ -0,0 +1,28 @@ +// 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. + +// Flags: --max-old-space-size=4 + +print('Check pause on OOM'); + +InspectorTest.addScript(` +var arr = []; +var stop = false; +function generateGarbage() { + while(!stop) { + arr.push(42); + } +} +//# sourceURL=test.js`, 10, 26); + +Protocol.Debugger.onPaused((message) => { + InspectorTest.log(`reason: ${message.params.reason}`); + Protocol.Debugger.evaluateOnCallFrame({ + callFrameId: message.params.callFrames[0].callFrameId, + expression: 'arr = []; stop = true;' + }).then(() => Protocol.Debugger.resume()); +}); +Protocol.Debugger.enable(); +Protocol.Runtime.evaluate({ expression: 'generateGarbage()' }) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt b/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt index d7c6d76346..baa832dcac 100644 --- a/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt +++ b/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt @@ -10,6 +10,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -27,6 +28,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -44,6 +46,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -61,6 +64,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -78,6 +82,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-map startColumn : 0 @@ -95,6 +100,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-without-nl-map startColumn : 0 @@ -112,6 +118,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : twoline-map startColumn : 0 @@ -129,6 +136,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : threeline-map startColumn : 0 @@ -146,6 +154,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -163,6 +172,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -180,6 +190,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -197,6 +208,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -214,6 +226,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -231,6 +244,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -248,6 +262,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -265,6 +280,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -282,6 +298,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -299,6 +316,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -316,6 +334,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -333,6 +352,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -350,6 +370,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -367,6 +388,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -384,6 +406,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -401,6 +424,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-map startColumn : 0 @@ -418,6 +442,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : oneline-without-nl-map startColumn : 0 @@ -435,6 +460,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : twoline-map startColumn : 0 @@ -452,6 +478,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : threeline-map startColumn : 0 @@ -469,6 +496,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -486,6 +514,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : source-mapping-url-map startColumn : 0 @@ -503,6 +532,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -520,6 +550,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -537,6 +568,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -554,6 +586,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -571,6 +604,7 @@ scriptParsed hasSourceURL : true hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -587,6 +621,7 @@ scriptFailedToParse executionContextId : <executionContextId> hasSourceURL : true hash : <hash> + isModule : false scriptId : <scriptId> sourceMapURL : failed-map startColumn : 0 @@ -604,6 +639,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -621,6 +657,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -638,6 +675,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -655,6 +693,7 @@ scriptParsed hasSourceURL : false hash : <hash> isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 diff --git a/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt b/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt index 1e86252c4f..cc91a65dec 100644 --- a/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt +++ b/deps/v8/test/inspector/debugger/script-parsed-for-runtime-evaluate-expected.txt @@ -9,6 +9,7 @@ Runtime.evaluate with valid expression hasSourceURL : true hash : 9D04F7335D1661503EAB9AF3EACAF92020803F34 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -25,6 +26,7 @@ Runtime.evaluate with syntax error executionContextId : <executionContextId> hasSourceURL : true hash : 9BCA34A10E5386925E74C1716C857BEB02821E15 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -42,6 +44,7 @@ Runtime.callFunctionOn with valid functionDeclaration hasSourceURL : false hash : 9D04CEA1B54DF92A01A0498543D429DC872EBA18 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -58,6 +61,7 @@ Runtime.callFunctionOn with syntax error executionContextId : <executionContextId> hasSourceURL : false hash : 9D04D83251E2B7F64CB5762843D429DC872EBA18 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -75,6 +79,7 @@ Runtime.compileScript with valid expression hasSourceURL : false hash : 9D04F733E4E4F1BA4CB5762843D429DC872EBA18 isLiveEdit : false + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 @@ -91,6 +96,7 @@ Runtime.compileScript with syntax error executionContextId : <executionContextId> hasSourceURL : false hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : false scriptId : <scriptId> sourceMapURL : startColumn : 0 diff --git a/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt b/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt index 03624e989c..376c11d0b3 100644 --- a/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt +++ b/deps/v8/test/inspector/debugger/set-script-source-exception-expected.txt @@ -4,7 +4,7 @@ Running test: testIncorrectScriptId { error : { code : -32000 - message : Uncaught Script not found + message : No script with given id found } id : <messageId> } diff --git a/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt new file mode 100644 index 0000000000..d77870e737 --- /dev/null +++ b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate-expected.txt @@ -0,0 +1,5 @@ +Paused on 'debugger;' +f() returns 1 +g() returns 2 +f() returns 1 +g() throws EvalError diff --git a/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js new file mode 100644 index 0000000000..18ea6fba27 --- /dev/null +++ b/deps/v8/test/inspector/debugger/side-effect-free-debug-evaluate.js @@ -0,0 +1,56 @@ +// 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. + +// Flags: --ignition + +InspectorTest.addScript(` +function testFunction() +{ + var o = 0; + function f() { return 1; } + function g() { o = 2; return o; } + debugger; +} +//# sourceURL=foo.js`); + +Protocol.Debugger.enable(); + +Protocol.Debugger.oncePaused().then(debuggerPaused); + +Protocol.Runtime.evaluate({ "expression": "setTimeout(testFunction, 0)" }); + +var topFrameId; + +function debuggerPaused(messageObject) +{ + InspectorTest.log("Paused on 'debugger;'"); + + topFrameId = messageObject.params.callFrames[0].callFrameId; + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "f()"}).then(evaluatedFirst); +} + +function evaluatedFirst(response) +{ + InspectorTest.log("f() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "g()"}).then(evaluatedSecond); +} + +function evaluatedSecond(response) +{ + InspectorTest.log("g() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "f()", throwOnSideEffect: true}).then(evaluatedThird); +} + +function evaluatedThird(response) +{ + InspectorTest.log("f() returns " + response.result.result.value); + Protocol.Debugger.evaluateOnCallFrame({ callFrameId: topFrameId, expression: "g()", throwOnSideEffect: true}).then(evaluatedFourth); + InspectorTest.completeTest(); +} + +function evaluatedFourth(response) +{ + InspectorTest.log("g() throws " + response.result.result.className); + InspectorTest.completeTest(); +} diff --git a/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt b/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt new file mode 100644 index 0000000000..e779d06771 --- /dev/null +++ b/deps/v8/test/inspector/debugger/step-into-next-script-expected.txt @@ -0,0 +1,83 @@ +Debugger breaks in next script after stepOut from previous one. + +Running test: testStepOut +test (foo.js:12:2) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +foo (timeout2.js:1:12) + +(anonymous) (timeout3.js:0:0) + + +Running test: testStepOver +(anonymous) (:0:0) + +test (foo.js:12:2) +(anonymous) (:0:0) + +test (foo.js:13:0) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +(anonymous) (timeout1.js:0:8) + +(anonymous) (timeout1.js:0:34) + +foo (timeout2.js:1:12) + +foo (timeout2.js:2:2) + +foo (timeout2.js:3:0) + +(anonymous) (timeout3.js:0:0) + +(anonymous) (timeout3.js:0:8) + +(anonymous) (timeout3.js:0:34) + + +Running test: testStepInto +(anonymous) (:0:0) + +test (foo.js:9:2) +(anonymous) (:0:0) + +test (foo.js:10:2) +(anonymous) (:0:0) + +test (foo.js:11:2) +(anonymous) (:0:0) + +test (foo.js:12:2) +(anonymous) (:0:0) + +test (foo.js:13:0) +(anonymous) (:0:0) + +(anonymous) (:0:5) + +(anonymous) (timeout1.js:0:0) + +(anonymous) (timeout1.js:0:8) + +(anonymous) (timeout1.js:0:34) + +foo (timeout2.js:1:12) + +foo (timeout2.js:2:2) + +foo (timeout2.js:3:0) + +(anonymous) (timeout3.js:0:0) + +(anonymous) (timeout3.js:0:8) + +(anonymous) (timeout3.js:0:34) + diff --git a/deps/v8/test/inspector/debugger/step-into-next-script.js b/deps/v8/test/inspector/debugger/step-into-next-script.js new file mode 100644 index 0000000000..b51ce012d8 --- /dev/null +++ b/deps/v8/test/inspector/debugger/step-into-next-script.js @@ -0,0 +1,51 @@ +// 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. + +print('Debugger breaks in next script after stepOut from previous one.'); + +InspectorTest.addScript(` +function test() { + setTimeout('var a = 1;//# sourceURL=timeout1.js', 0); + setTimeout(foo, 0); + setTimeout('var a = 3;//# sourceURL=timeout3.js', 0); + debugger; +} +//# sourceURL=foo.js`, 7, 26); + +InspectorTest.addScript(` +function foo() { + return 42; +} +//# sourceURL=timeout2.js`) + +InspectorTest.setupScriptMap(); +var stepAction; +Protocol.Debugger.onPaused(message => { + InspectorTest.logCallFrames(message.params.callFrames); + InspectorTest.log(''); + Protocol.Debugger[stepAction](); +}); +Protocol.Debugger.enable() +InspectorTest.runTestSuite([ + function testStepOut(next) { + stepAction = 'stepOut'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + }, + + function testStepOver(next) { + stepAction = 'stepOver'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + }, + + function testStepInto(next) { + stepAction = 'stepInto'; + Protocol.Runtime.evaluate({ expression: 'test()' }) + .then(() => InspectorTest.waitPendingTasks()) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js b/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js index 0a97e5dc35..65b694b566 100644 --- a/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js +++ b/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js @@ -90,10 +90,15 @@ function setIncorrectRanges(scriptId, response) function setMixedSourceRanges(scriptId) { Protocol.Debugger.onPaused(runAction); - Protocol.Debugger.setBlackboxedRanges({ - scriptId: scriptId, - positions: [ { lineNumber: 8, columnNumber: 0 }, { lineNumber: 15, columnNumber: 0 } ] // blackbox ranges for mixed.js - }).then(runAction); + Protocol.Debugger + .setBlackboxedRanges({ + scriptId: scriptId, + positions: [ + {lineNumber: 6, columnNumber: 0}, + {lineNumber: 14, columnNumber: 0} + ] // blackbox ranges for mixed.js + }) + .then(runAction); } var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print", diff --git a/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt new file mode 100644 index 0000000000..736117bf97 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations-expected.txt @@ -0,0 +1,87 @@ +Running testFunction... +Script nr 0 parsed. URL: v8://test/setup +Script nr 1 parsed. URL: v8://test/runTestFunction +Script nr 2 parsed. URL: wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0 +This is a wasm script (nr 0). +Script nr 3 parsed. URL: wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1 +This is a wasm script (nr 1). +Querying breakable locations for all wasm scripts now... +Requesting all breakable locations in wasm script 0 +4 breakable location(s): +[0] 2:2 || >nop +[1] 3:2 || >i32.const 12 +[2] 4:2 || >set_local 0 +[3] 5:0 || >end +Requesting breakable locations in lines [0,3) +1 breakable location(s): +[0] 2:2 || >nop +Requesting breakable locations in lines [4,6) +2 breakable location(s): +[0] 4:2 || >set_local 0 +[1] 5:0 || >end +Requesting all breakable locations in wasm script 1 +7 breakable location(s): +[0] 1:2 || >get_local 0 +[1] 2:2 || >if +[2] 3:4 || >block +[3] 4:6 || >call 0 +[4] 5:4 || >end +[5] 6:2 || >end +[6] 7:0 || >end +Requesting breakable locations in lines [0,3) +2 breakable location(s): +[0] 1:2 || >get_local 0 +[1] 2:2 || >if +Requesting breakable locations in lines [4,6) +2 breakable location(s): +[0] 4:6 || >call 0 +[1] 5:4 || >end +Setting a breakpoint on each breakable location... +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:2:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:3:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:4:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:5:0 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:1:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:2:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:3:4 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:4:6 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:5:4 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:6:2 +Success! +Setting at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:7:0 +Success! +Running wasm code... +Missing breakpoints: 11 +Script nr 4 parsed. URL: v8://test/runWasm +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:1:2 +Missing breakpoints: 10 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:2:2 +Missing breakpoints: 9 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:3:4 +Missing breakpoints: 8 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:4:6 +Missing breakpoints: 7 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:2:2 +Missing breakpoints: 6 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:3:2 +Missing breakpoints: 5 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:4:2 +Missing breakpoints: 4 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-0:5:0 +Missing breakpoints: 3 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:5:4 +Missing breakpoints: 2 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:6:2 +Missing breakpoints: 1 +Stopped at wasm://wasm/wasm-eb3c2032/wasm-eb3c2032-1:7:0 +Missing breakpoints: 0 +Finished! diff --git a/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js new file mode 100644 index 0000000000..f947161b5e --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-get-breakable-locations.js @@ -0,0 +1,208 @@ +// Copyright 2016 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. + +// Flags: --expose-wasm + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); + +// clang-format off +var func_idx = builder.addFunction('helper', kSig_v_v) + .addLocals({i32_count: 1}) + .addBody([ + kExprNop, + kExprI32Const, 12, + kExprSetLocal, 0, + ]).index; + +builder.addFunction('main', kSig_v_i) + .addBody([ + kExprGetLocal, 0, + kExprIf, kWasmStmt, + kExprBlock, kWasmStmt, + kExprCallFunction, func_idx, + kExprEnd, + kExprEnd + ]).exportAs('main'); +// clang-format on + +var module_bytes = builder.toArray(); + +function testFunction(bytes) { + var buffer = new ArrayBuffer(bytes.length); + var view = new Uint8Array(buffer); + for (var i = 0; i < bytes.length; i++) { + view[i] = bytes[i] | 0; + } + + var module = new WebAssembly.Module(buffer); + // Set global variable. + instance = new WebAssembly.Instance(module); +} + +var evalWithUrl = (code, url) => Protocol.Runtime.evaluate( + {'expression': code + '\n//# sourceURL=v8://test/' + url}); + +var setupCode = testFunction.toString() + ';\nvar module_bytes = ' + + JSON.stringify(module_bytes) + ';\nvar instance;'; + +Protocol.Debugger.enable(); +Protocol.Debugger.onScriptParsed(handleScriptParsed); +InspectorTest.log('Running testFunction...'); +evalWithUrl(setupCode, 'setup') + .then(() => evalWithUrl('testFunction(module_bytes)', 'runTestFunction')) + .then(getBreakableLocationsForAllWasmScripts) + .then(setAllBreakableLocations) + .then(() => InspectorTest.log('Running wasm code...')) + .then(() => (evalWithUrl('instance.exports.main(1)', 'runWasm'), 0)) + .then(waitForAllPauses) + .then(() => InspectorTest.log('Finished!')) + .then(InspectorTest.completeTest); + +var allBreakableLocations = []; + +var urls = {}; +var numScripts = 0; +var wasmScripts = []; +function handleScriptParsed(messageObject) { + var scriptId = messageObject.params.scriptId; + var url = messageObject.params.url; + urls[scriptId] = url; + InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); + ++numScripts; + + if (url.startsWith('wasm://')) { + InspectorTest.log('This is a wasm script (nr ' + wasmScripts.length + ').'); + wasmScripts.push(scriptId); + } +} + +function printFailure(message) { + if (!message.result) { + InspectorTest.logMessage(message); + } + return message; +} + +function printBreakableLocations(message, expectedScriptId, source) { + var lines = source.split('\n'); + var locations = message.result.locations; + InspectorTest.log(locations.length + ' breakable location(s):'); + for (var i = 0; i < locations.length; ++i) { + if (locations[i].scriptId != expectedScriptId) { + InspectorTest.log( + 'SCRIPT ID MISMATCH!! ' + locations[i].scriptId + ' != ' + + expectedScriptId); + } + var line = '<illegal line number>'; + if (locations[i].lineNumber < lines.length) { + line = lines[locations[i].lineNumber]; + if (locations[i].columnNumber < line.length) { + line = line.substr(0, locations[i].columnNumber) + '>' + + line.substr(locations[i].columnNumber); + } + } + InspectorTest.log( + '[' + i + '] ' + locations[i].lineNumber + ':' + + locations[i].columnNumber + ' || ' + line); + } +} + +function checkGetBreakableLocations(wasmScriptNr) { + InspectorTest.log( + 'Requesting all breakable locations in wasm script ' + wasmScriptNr); + var scriptId = wasmScripts[wasmScriptNr]; + var source; + return Protocol.Debugger.getScriptSource({scriptId: scriptId}) + .then(msg => source = msg.result.scriptSource) + .then( + () => Protocol.Debugger.getPossibleBreakpoints( + {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}})) + .then(printFailure) + .then(msg => (allBreakableLocations.push(...msg.result.locations), msg)) + .then(msg => printBreakableLocations(msg, scriptId, source)) + .then( + () => InspectorTest.log( + 'Requesting breakable locations in lines [0,3)')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ + start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}, + end: {lineNumber: 3, columnNumber: 0, scriptId: scriptId} + })) + .then(printFailure) + .then(msg => printBreakableLocations(msg, scriptId, source)) + .then( + () => InspectorTest.log( + 'Requesting breakable locations in lines [4,6)')) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ + start: {lineNumber: 4, columnNumber: 0, scriptId: scriptId}, + end: {lineNumber: 6, columnNumber: 0, scriptId: scriptId} + })) + .then(printFailure) + .then(msg => printBreakableLocations(msg, scriptId, source)); +} + +function getBreakableLocationsForAllWasmScripts() { + InspectorTest.log('Querying breakable locations for all wasm scripts now...'); + var promise = Promise.resolve(); + for (var wasmScriptNr = 0; wasmScriptNr < wasmScripts.length; + ++wasmScriptNr) { + promise = promise.then(checkGetBreakableLocations.bind(null, wasmScriptNr)); + } + return promise; +} + +function locationMatches(loc1, loc2) { + return loc1.scriptId == loc2.scriptId && loc1.lineNumber == loc2.lineNumber && + loc1.columnNumber == loc2.columnNumber; +} + +function locationStr(loc) { + return urls[loc.scriptId] + ':' + loc.lineNumber + ':' + loc.columnNumber; +} + +function setBreakpoint(loc) { + InspectorTest.log('Setting at ' + locationStr(loc)); + function check(msg) { + if (locationMatches(loc, msg.result.actualLocation)) { + InspectorTest.log("Success!"); + } else { + InspectorTest.log("Mismatch!"); + InspectorTest.logMessage(msg); + } + } + return Protocol.Debugger.setBreakpoint({'location': loc}) + .then(printFailure) + .then(check); +} + +function setAllBreakableLocations() { + InspectorTest.log('Setting a breakpoint on each breakable location...'); + var promise = Promise.resolve(); + for (var loc of allBreakableLocations) { + promise = promise.then(setBreakpoint.bind(null, loc)); + } + return promise; +} + +function removePausedLocation(msg) { + var topLocation = msg.params.callFrames[0].location; + InspectorTest.log('Stopped at ' + locationStr(topLocation)); + for (var i = 0; i < allBreakableLocations.length; ++i) { + if (locationMatches(topLocation, allBreakableLocations[i])) { + allBreakableLocations.splice(i, 1); + --i; + } + } +} + +function waitForAllPauses() { + InspectorTest.log('Missing breakpoints: ' + allBreakableLocations.length); + if (allBreakableLocations.length == 0) return; + return Protocol.Debugger.oncePaused() + .then(removePausedLocation) + .then(Protocol.Debugger.resume()) + .then(waitForAllPauses); +} diff --git a/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt b/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt new file mode 100644 index 0000000000..922d51aa49 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stepping-expected.txt @@ -0,0 +1,83 @@ +Installing code an global variable. +Calling instantiate function. +Waiting for two wasm scripts to be parsed. +Ignoring script with url v8://test/callInstantiate +Got wasm script: wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0 +Requesting source for wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0... +Got wasm script: wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1 +Requesting source for wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1... +func $wasm_A + nop + nop +end + +func $wasm_B (param i32) + loop + get_local 0 + if + get_local 0 + i32.const 1 + i32.sub + set_local 0 + call 0 + br 1 + end + end +end + +Setting breakpoint on line 7 (on the setlocal before the call), url wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1 +{ + columnNumber : 6 + lineNumber : 7 + scriptId : <scriptId> +} +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:2:2: >nop +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepOver +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: resume +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepOut +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:1:2: >loop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:2:4: >get_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:3:4: >if +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:4:6: >get_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:5:6: >i32.const 1 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:6:6: >i32.sub +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:7:6: >set_local 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:8:6: >call 0 +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:1:2: >nop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:2:2: >nop +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-0:3:0: >end +Step action: stepInto +Paused at wasm://wasm/wasm-0e9ccf72/wasm-0e9ccf72-1:9:6: >br 1 +Step action: resume +exports.main returned! +Finished! diff --git a/deps/v8/test/inspector/debugger/wasm-stepping.js b/deps/v8/test/inspector/debugger/wasm-stepping.js new file mode 100644 index 0000000000..8cf14d361c --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stepping.js @@ -0,0 +1,160 @@ +// 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. + +load('test/mjsunit/wasm/wasm-constants.js'); +load('test/mjsunit/wasm/wasm-module-builder.js'); + +var builder = new WasmModuleBuilder(); + +var func_a_idx = + builder.addFunction('wasm_A', kSig_v_v).addBody([kExprNop, kExprNop]).index; + +// wasm_B calls wasm_A <param0> times. +builder.addFunction('wasm_B', kSig_v_i) + .addBody([ + // clang-format off + kExprLoop, kWasmStmt, // while + kExprGetLocal, 0, // - + kExprIf, kWasmStmt, // if <param0> != 0 + kExprGetLocal, 0, // - + kExprI32Const, 1, // - + kExprI32Sub, // - + kExprSetLocal, 0, // decrease <param0> + kExprCallFunction, func_a_idx, // - + kExprBr, 1, // continue + kExprEnd, // - + kExprEnd, // break + // clang-format on + ]) + .exportAs('main'); + +var module_bytes = builder.toArray(); + +function instantiate(bytes) { + var buffer = new ArrayBuffer(bytes.length); + var view = new Uint8Array(buffer); + for (var i = 0; i < bytes.length; ++i) { + view[i] = bytes[i] | 0; + } + + var module = new WebAssembly.Module(buffer); + // Set global variable. + instance = new WebAssembly.Instance(module); +} + +var evalWithUrl = (code, url) => Protocol.Runtime.evaluate( + {'expression': code + '\n//# sourceURL=v8://test/' + url}); + +Protocol.Debugger.onPaused(handlePaused); +var wasm_B_scriptId; +var step_actions = [ + 'stepInto', // == stepOver, to call instruction + 'stepInto', // into call to wasm_A + 'stepOver', // over first nop + 'stepOut', // out of wasm_A + 'stepOut', // out of wasm_B, stop on breakpoint again + 'stepOver', // to call + 'stepOver', // over call + 'resume', // to next breakpoint (third iteration) + 'stepInto', // to call + 'stepInto', // into wasm_A + 'stepOut', // out to wasm_B + // now step 9 times, until we are in wasm_A again. + 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', 'stepInto', + 'stepInto', 'stepInto', 'stepInto', + // 3 more times, back to wasm_B. + 'stepInto', 'stepInto', 'stepInto', + // then just resume. + 'resume' +]; +var sources = {}; +var urls = {}; +var afterTwoSourcesCallback; + +Protocol.Debugger.enable() + .then(() => InspectorTest.log('Installing code an global variable.')) + .then( + () => evalWithUrl('var instance;\n' + instantiate.toString(), 'setup')) + .then(() => InspectorTest.log('Calling instantiate function.')) + .then( + () => + (evalWithUrl( + 'instantiate(' + JSON.stringify(module_bytes) + ')', + 'callInstantiate'), + 0)) + .then(waitForTwoWasmScripts) + .then( + () => InspectorTest.log( + 'Setting breakpoint on line 7 (on the setlocal before the call), url ' + + urls[wasm_B_scriptId])) + .then( + () => Protocol.Debugger.setBreakpoint( + {'location': {'scriptId': wasm_B_scriptId, 'lineNumber': 7}})) + .then(printFailure) + .then(msg => InspectorTest.logMessage(msg.result.actualLocation)) + .then(() => evalWithUrl('instance.exports.main(4)', 'runWasm')) + .then(() => InspectorTest.log('exports.main returned!')) + .then(() => InspectorTest.log('Finished!')) + .then(InspectorTest.completeTest); + +function printFailure(message) { + if (!message.result) { + InspectorTest.logMessage(message); + } + return message; +} + +function waitForTwoWasmScripts() { + var num = 0; + InspectorTest.log('Waiting for two wasm scripts to be parsed.'); + var promise = new Promise(fulfill => gotBothSources = fulfill); + function waitForMore() { + if (num == 2) return promise; + Protocol.Debugger.onceScriptParsed() + .then(handleNewScript) + .then(waitForMore); + } + function handleNewScript(msg) { + var url = msg.params.url; + if (!url.startsWith('wasm://')) { + InspectorTest.log('Ignoring script with url ' + url); + return; + } + num += 1; + var scriptId = msg.params.scriptId; + urls[scriptId] = url; + InspectorTest.log('Got wasm script: ' + url); + if (url.substr(-2) == '-1') wasm_B_scriptId = scriptId; + InspectorTest.log('Requesting source for ' + url + '...'); + Protocol.Debugger.getScriptSource({scriptId: scriptId}) + .then(printFailure) + .then(msg => sources[scriptId] = msg.result.scriptSource) + .then(InspectorTest.log) + .then(() => Object.keys(sources).length == 2 ? gotBothSources() : 0); + } + waitForMore(); + return promise; +} + +function printPauseLocation(scriptId, lineNr, columnNr) { + var lines = sources[scriptId].split('\n'); + var line = '<illegal line number>'; + if (lineNr < lines.length) { + line = lines[lineNr]; + if (columnNr < line.length) { + line = line.substr(0, columnNr) + '>' + line.substr(columnNr); + } + } + InspectorTest.log( + 'Paused at ' + urls[scriptId] + ':' + lineNr + ':' + columnNr + ': ' + + line); +} + +function handlePaused(msg) { + var loc = msg.params.callFrames[0].location; + printPauseLocation(loc.scriptId, loc.lineNumber, loc.columnNumber); + var action = step_actions.shift(); + InspectorTest.log('Step action: ' + action); + Protocol.Debugger[action](); +} |