diff options
Diffstat (limited to 'deps/v8/test/inspector')
67 files changed, 5822 insertions, 1315 deletions
diff --git a/deps/v8/test/inspector/console/destroy-context-during-log.js b/deps/v8/test/inspector/console/destroy-context-during-log.js index 2289fbefc0..9c5753ffc0 100644 --- a/deps/v8/test/inspector/console/destroy-context-during-log.js +++ b/deps/v8/test/inspector/console/destroy-context-during-log.js @@ -6,6 +6,7 @@ const expression = ` Object.defineProperty(Object.prototype, 'RemoteObject', { configurable: true, set(v) { + console.log("Should never be called"); delete Object.prototype.RemoteObject; this.RemoteObject = v; @@ -25,6 +26,7 @@ const expression = ` detachInspector(); attachInspector(); console.log("First inspector activity after attaching inspector"); + console.log("End of test"); `; Protocol.Runtime.enable(); diff --git a/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt b/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt new file mode 100644 index 0000000000..6b0af036fc --- /dev/null +++ b/deps/v8/test/inspector/cpu-profiler/coverage-expected.txt @@ -0,0 +1,333 @@ +Test collecting code coverage data with Profiler.collectCoverage. + +Running test: testPreciseCoverage +{ + id : <messageId> + result : { + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 1 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 0 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 0 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 0 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 1 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 0 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} + +Running test: testPreciseCoverageFail +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + error : { + code : -32000 + message : Precise coverage has not been started. + } + id : <messageId> +} + +Running test: testBestEffortCoverage +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + id : <messageId> + result : { + result : [ + ] + } +} +{ + id : <messageId> + result : { + result : [ + ] + } +} + +Running test: testBestEffortCoveragePrecise +{ + id : <messageId> + result : { + result : { + description : 8 + type : number + value : 8 + } + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 4 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 0 + endLineNumber : 9 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + [1] : { + functionName : fib + ranges : [ + [0] : { + count : 15 + endColumnNumber : 1 + endLineNumber : 4 + startColumnNumber : 0 + startLineNumber : 1 + } + ] + } + [2] : { + functionName : iife + ranges : [ + [0] : { + count : 1 + endColumnNumber : 1 + endLineNumber : 7 + startColumnNumber : 1 + startLineNumber : 5 + } + ] + } + ] + scriptId : <scriptId> + url : 4 + } + [1] : { + functions : [ + [0] : { + functionName : + ranges : [ + [0] : { + count : 1 + endColumnNumber : 11 + endLineNumber : 0 + startColumnNumber : 0 + startLineNumber : 0 + } + ] + } + ] + scriptId : <scriptId> + url : + } + ] + } +} diff --git a/deps/v8/test/inspector/cpu-profiler/coverage.js b/deps/v8/test/inspector/cpu-profiler/coverage.js new file mode 100644 index 0000000000..16f679dc5a --- /dev/null +++ b/deps/v8/test/inspector/cpu-profiler/coverage.js @@ -0,0 +1,100 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var source = +` +function fib(x) { + if (x < 2) return 1; + return fib(x-1) + fib(x-2); +} +(function iife() { + return 1; +})(); +fib(5); +`; + +print("Test collecting code coverage data with Profiler.collectCoverage."); + +function ClearAndGC() { + return Protocol.Runtime.evaluate({ expression: "fib = null;" }) + .then(() => Protocol.HeapProfiler.enable()) + .then(() => Protocol.HeapProfiler.collectGarbage()) + .then(() => Protocol.HeapProfiler.disable()); +} + +function LogSorted(message) { + message.result.result.sort((a, b) => parseInt(a.scriptId) - parseInt(b.scriptId)); + return InspectorTest.logMessage(message); +} + +InspectorTest.runTestSuite([ + function testPreciseCoverage(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(Protocol.Profiler.startPreciseCoverage) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "1", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(ClearAndGC) + .then(InspectorTest.logMessage) + .then(Protocol.Profiler.takePreciseCoverage) + .then(LogSorted) + .then(Protocol.Profiler.takePreciseCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Profiler.stopPreciseCoverage) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testPreciseCoverageFail(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "2", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.takePreciseCoverage) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testBestEffortCoverage(next) + { + Protocol.Runtime.enable() + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "3", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Runtime.disable) + .then(next); + }, + function testBestEffortCoveragePrecise(next) + { + Protocol.Runtime.enable() + .then(Protocol.Profiler.enable) + .then(Protocol.Profiler.startPreciseCoverage) + .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "4", persistScript: true })) + .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId })) + .then(InspectorTest.logMessage) + .then(ClearAndGC) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(Protocol.Profiler.getBestEffortCoverage) + .then(LogSorted) + .then(ClearAndGC) + .then(Protocol.Profiler.stopPreciseCoverage) + .then(Protocol.Profiler.disable) + .then(Protocol.Runtime.disable) + .then(next); + }, +]); 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](); +} diff --git a/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt new file mode 100644 index 0000000000..2d2e5532b3 --- /dev/null +++ b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause-expected.txt @@ -0,0 +1,2 @@ +Checks that takeHeapSnapshot uses empty accessing_context for access checks. +Successfully finished diff --git a/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js new file mode 100644 index 0000000000..e36b11558d --- /dev/null +++ b/deps/v8/test/inspector/heap-profiler/take-heap-snapshot-on-pause.js @@ -0,0 +1,24 @@ +// 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 takeHeapSnapshot uses empty accessing_context for access \ +checks.'); + +InspectorTest.addScript(` +function testFunction() { + var array = [ createObjectWithStrictCheck() ]; + debugger; +} +//# sourceURL=test.js`); + +Protocol.Debugger.onScriptParsed(message => { + Protocol.HeapProfiler.takeHeapSnapshot({ reportProgress: false }) + .then(() => Protocol.Debugger.resume()); +}); + +Protocol.Debugger.enable(); +Protocol.HeapProfiler.enable(); +Protocol.Runtime.evaluate({ expression: 'testFunction()' }) + .then(() => InspectorTest.log('Successfully finished')) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/inspector-impl.cc b/deps/v8/test/inspector/inspector-impl.cc index f1d62afbad..3b04440372 100644 --- a/deps/v8/test/inspector/inspector-impl.cc +++ b/deps/v8/test/inspector/inspector-impl.cc @@ -138,7 +138,13 @@ v8::Local<v8::Context> InspectorClientImpl::ensureDefaultContextInGroup(int) { return context_.Get(isolate_); } +void InspectorClientImpl::setCurrentTimeMSForTest(double time) { + current_time_ = time; + current_time_set_for_test_ = true; +} + double InspectorClientImpl::currentTimeMS() { + if (current_time_set_for_test_) return current_time_; return v8::base::OS::TimeCurrentMillis(); } diff --git a/deps/v8/test/inspector/inspector-impl.h b/deps/v8/test/inspector/inspector-impl.h index f94bef1599..5da332bb27 100644 --- a/deps/v8/test/inspector/inspector-impl.h +++ b/deps/v8/test/inspector/inspector-impl.h @@ -27,6 +27,12 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { static v8_inspector::V8Inspector* InspectorFromContext( v8::Local<v8::Context> context); + static v8_inspector::V8InspectorSession* SessionFromContext( + v8::Local<v8::Context> context); + + void setCurrentTimeMSForTest(double time); + + v8_inspector::V8InspectorSession* session() const { return session_.get(); } private: // V8InspectorClient implementation. @@ -36,9 +42,6 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { void runMessageLoopOnPause(int context_group_id) override; void quitMessageLoopOnPause() override; - static v8_inspector::V8InspectorSession* SessionFromContext( - v8::Local<v8::Context> context); - friend class SendMessageToBackendTask; friend class ConnectTask; @@ -54,6 +57,9 @@ class InspectorClientImpl : public v8_inspector::V8InspectorClient { TaskRunner* task_runner_; FrontendChannel* frontend_channel_; + bool current_time_set_for_test_ = false; + double current_time_ = 0.0; + DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); }; diff --git a/deps/v8/test/inspector/inspector-test.cc b/deps/v8/test/inspector/inspector-test.cc index 286d685d21..b3dbcb4f52 100644 --- a/deps/v8/test/inspector/inspector-test.cc +++ b/deps/v8/test/inspector/inspector-test.cc @@ -54,7 +54,10 @@ class UtilsExtension : public v8::Extension { "native function quit();" "native function setlocale();" "native function load();" - "native function compileAndRunWithOrigin();") {} + "native function compileAndRunWithOrigin();" + "native function setCurrentTimeMSForTest();" + "native function schedulePauseOnNextStatement();" + "native function cancelPauseOnNextStatement();") {} virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( v8::Isolate* isolate, v8::Local<v8::String> name) { v8::Local<v8::Context> context = isolate->GetCurrentContext(); @@ -88,6 +91,28 @@ class UtilsExtension : public v8::Extension { .FromJust()) { return v8::FunctionTemplate::New(isolate, UtilsExtension::CompileAndRunWithOrigin); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "setCurrentTimeMSForTest", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, + UtilsExtension::SetCurrentTimeMSForTest); + } else if (name->Equals(context, + v8::String::NewFromUtf8( + isolate, "schedulePauseOnNextStatement", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, UtilsExtension::SchedulePauseOnNextStatement); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "cancelPauseOnNextStatement", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, UtilsExtension::CancelPauseOnNextStatement); } return v8::Local<v8::FunctionTemplate>(); } @@ -96,8 +121,13 @@ class UtilsExtension : public v8::Extension { backend_runner_ = runner; } + static void set_inspector_client(InspectorClientImpl* client) { + inspector_client_ = client; + } + private: static TaskRunner* backend_runner_; + static InspectorClientImpl* inspector_client_; static void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { for (int i = 0; i < args.Length(); i++) { @@ -168,21 +198,58 @@ class UtilsExtension : public v8::Extension { static void CompileAndRunWithOrigin( const v8::FunctionCallbackInfo<v8::Value>& args) { - if (args.Length() != 4 || !args[0]->IsString() || !args[1]->IsString() || - !args[2]->IsInt32() || !args[3]->IsInt32()) { + if (args.Length() != 5 || !args[0]->IsString() || !args[1]->IsString() || + !args[2]->IsInt32() || !args[3]->IsInt32() || !args[4]->IsBoolean()) { fprintf(stderr, "Internal error: compileAndRunWithOrigin(source, name, line, " - "column)."); + "column, is_module)."); Exit(); } backend_runner_->Append(new ExecuteStringTask( ToVector(args[0].As<v8::String>()), args[1].As<v8::String>(), - args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), nullptr, nullptr)); + args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), + args[4].As<v8::Boolean>(), nullptr, nullptr)); + } + + static void SetCurrentTimeMSForTest( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 1 || !args[0]->IsNumber()) { + fprintf(stderr, "Internal error: setCurrentTimeMSForTest(time)."); + Exit(); + } + inspector_client_->setCurrentTimeMSForTest( + args[0].As<v8::Number>()->Value()); + } + + static void SchedulePauseOnNextStatement( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { + fprintf( + stderr, + "Internal error: schedulePauseOnNextStatement('reason', 'details')."); + Exit(); + } + v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + inspector_client_->session()->schedulePauseOnNextStatement(reason_view, + details_view); + } + + static void CancelPauseOnNextStatement( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 0) { + fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); + Exit(); + } + inspector_client_->session()->cancelPauseOnNextStatement(); } }; TaskRunner* UtilsExtension::backend_runner_ = nullptr; +InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; class SetTimeoutTask : public AsyncTask { public: @@ -247,19 +314,29 @@ class SetTimeoutExtension : public v8::Extension { task.reset(new ExecuteStringTask( ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate), v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), - "setTimeout", inspector)); + v8::Boolean::New(isolate, false), "setTimeout", inspector)); } TaskRunner::FromContext(context)->Append(task.release()); } }; +bool StrictAccessCheck(v8::Local<v8::Context> accessing_context, + v8::Local<v8::Object> accessed_object, + v8::Local<v8::Value> data) { + CHECK(accessing_context.IsEmpty()); + return accessing_context.IsEmpty(); +} + class InspectorExtension : public v8::Extension { public: InspectorExtension() : v8::Extension("v8_inspector/inspector", "native function attachInspector();" "native function detachInspector();" - "native function setMaxAsyncTaskStacks();") {} + "native function setMaxAsyncTaskStacks();" + "native function breakProgram();" + "native function createObjectWithStrictCheck();" + "native function callWithScheduledBreak();") {} virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( v8::Isolate* isolate, v8::Local<v8::String> name) { @@ -283,6 +360,27 @@ class InspectorExtension : public v8::Extension { .FromJust()) { return v8::FunctionTemplate::New( isolate, InspectorExtension::SetMaxAsyncTaskStacks); + } else if (name->Equals(context, + v8::String::NewFromUtf8(isolate, "breakProgram", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, + InspectorExtension::BreakProgram); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "createObjectWithStrictCheck", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, InspectorExtension::CreateObjectWithStrictCheck); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "callWithScheduledBreak", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New( + isolate, InspectorExtension::CallWithScheduledBreak); } return v8::Local<v8::FunctionTemplate>(); } @@ -326,6 +424,61 @@ class InspectorExtension : public v8::Extension { v8_inspector::SetMaxAsyncTaskStacksForTest( inspector, args[0].As<v8::Int32>()->Value()); } + + static void BreakProgram(const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString()) { + fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); + Exit(); + } + v8_inspector::V8InspectorSession* session = + InspectorClientImpl::SessionFromContext( + args.GetIsolate()->GetCurrentContext()); + CHECK(session); + + v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + session->breakProgram(reason_view, details_view); + } + + static void CreateObjectWithStrictCheck( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 0) { + fprintf(stderr, "Internal error: createObjectWithStrictCheck()."); + Exit(); + } + v8::Local<v8::ObjectTemplate> templ = + v8::ObjectTemplate::New(args.GetIsolate()); + templ->SetAccessCheckCallback(&StrictAccessCheck); + args.GetReturnValue().Set( + templ->NewInstance(args.GetIsolate()->GetCurrentContext()) + .ToLocalChecked()); + } + + static void CallWithScheduledBreak( + const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 3 || !args[0]->IsFunction() || !args[1]->IsString() || + !args[2]->IsString()) { + fprintf(stderr, "Internal error: breakProgram('reason', 'details')."); + Exit(); + } + v8_inspector::V8InspectorSession* session = + InspectorClientImpl::SessionFromContext( + args.GetIsolate()->GetCurrentContext()); + CHECK(session); + + v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>()); + v8_inspector::StringView reason_view(reason.start(), reason.length()); + v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); + v8_inspector::StringView details_view(details.start(), details.length()); + session->schedulePauseOnNextStatement(reason_view, details_view); + v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); + v8::MaybeLocal<v8::Value> result; + result = args[0].As<v8::Function>()->Call(context, context->Global(), 0, + nullptr); + session->cancelPauseOnNextStatement(); + } }; v8::Local<v8::String> ToString(v8::Isolate* isolate, @@ -364,10 +517,10 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel { v8::Local<v8::String> result = v8::String::Concat(prefix, message_string); result = v8::String::Concat(result, suffix); - frontend_task_runner_->Append( - new ExecuteStringTask(ToVector(result), v8::String::Empty(isolate), - v8::Integer::New(isolate, 0), - v8::Integer::New(isolate, 0), nullptr, nullptr)); + frontend_task_runner_->Append(new ExecuteStringTask( + ToVector(result), v8::String::Empty(isolate), + v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), + v8::Boolean::New(isolate, false), nullptr, nullptr)); } private: @@ -415,6 +568,7 @@ int main(int argc, char* argv[]) { InspectorClientImpl inspector_client(&backend_runner, &frontend_channel, &ready_semaphore); ready_semaphore.Wait(); + UtilsExtension::set_inspector_client(&inspector_client); task_runners.push_back(&frontend_runner); task_runners.push_back(&backend_runner); diff --git a/deps/v8/test/inspector/inspector.status b/deps/v8/test/inspector/inspector.status index 511c405c2b..e79510d2d6 100644 --- a/deps/v8/test/inspector/inspector.status +++ b/deps/v8/test/inspector/inspector.status @@ -4,6 +4,11 @@ [ +[ALWAYS, { + # Test is failing on V8 Linux - arm64 - sim - nosnap - debug. + 'debugger/pause-on-oom': [SKIP], +}], # ALWAYS + ############################################################################## ['variant == asm_wasm', { '*': [SKIP], diff --git a/deps/v8/test/inspector/protocol-test.js b/deps/v8/test/inspector/protocol-test.js index 37e6447f79..d62c2e0c29 100644 --- a/deps/v8/test/inspector/protocol-test.js +++ b/deps/v8/test/inspector/protocol-test.js @@ -20,7 +20,8 @@ Protocol = new Proxy({}, { var eventName = match[2]; eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); if (match[1]) - return (args) => InspectorTest._waitForEventPromise(`${agentName}.${eventName}`, args || {}); + return () => InspectorTest._waitForEventPromise( + `${agentName}.${eventName}`); else return (listener) => { InspectorTest._eventHandler[`${agentName}.${eventName}`] = listener }; } @@ -112,6 +113,21 @@ InspectorTest.logCallFrames = function(callFrames) } } +InspectorTest.logAsyncStackTrace = function(asyncStackTrace) +{ + while (asyncStackTrace) { + if (asyncStackTrace.promiseCreationFrame) { + var frame = asyncStackTrace.promiseCreationFrame; + InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url + }:${frame.lineNumber}:${frame.columnNumber})--`); + } else { + InspectorTest.log(`-- ${asyncStackTrace.description} --`); + } + InspectorTest.logCallFrames(asyncStackTrace.callFrames); + asyncStackTrace = asyncStackTrace.parent; + } +} + InspectorTest.completeTest = function() { Protocol.Debugger.disable().then(() => quit()); @@ -119,13 +135,17 @@ InspectorTest.completeTest = function() InspectorTest.completeTestAfterPendingTimeouts = function() { - Protocol.Runtime.evaluate({ - expression: "new Promise(resolve => setTimeout(resolve, 0))", - awaitPromise: true }).then(InspectorTest.completeTest); + InspectorTest.waitPendingTasks().then(InspectorTest.completeTest); +} + +InspectorTest.waitPendingTasks = function() +{ + return Protocol.Runtime.evaluate({ expression: "new Promise(r => setTimeout(r, 0))//# sourceURL=wait-pending-tasks.js", awaitPromise: true }); } -InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0); -InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string, url, 0, 0); +InspectorTest.addScript = (string, lineOffset, columnOffset) => compileAndRunWithOrigin(string, "", lineOffset || 0, columnOffset || 0, false); +InspectorTest.addScriptWithUrl = (string, url) => compileAndRunWithOrigin(string, url, 0, 0, false); +InspectorTest.addModule = (string, url, lineOffset, columnOffset) => compileAndRunWithOrigin(string, url, lineOffset || 0, columnOffset || 0, true); InspectorTest.startDumpingProtocolMessages = function() { @@ -213,6 +233,8 @@ InspectorTest._dispatchMessage = function(messageObject) var eventHandler = InspectorTest._eventHandler[eventName]; if (InspectorTest._scriptMap && eventName === "Debugger.scriptParsed") InspectorTest._scriptMap.set(messageObject.params.scriptId, JSON.parse(JSON.stringify(messageObject.params))); + if (eventName === "Debugger.scriptParsed" && messageObject.params.url === "wait-pending-tasks.js") + return; if (eventHandler) eventHandler(messageObject); } diff --git a/deps/v8/test/inspector/runtime/console-methods-expected.txt b/deps/v8/test/inspector/runtime/console-methods-expected.txt new file mode 100644 index 0000000000..100789a773 --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-methods-expected.txt @@ -0,0 +1,648 @@ +Checks console methods +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : debug + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 9 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : debug + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : error + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 10 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : error + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : info + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 11 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : info + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : log + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 12 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : log + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : warn + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 13 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : warning + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : dir + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 14 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : dir + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : dirxml + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 15 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : dirxml + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + className : Array + description : Array(2) + objectId : <objectId> + preview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + type : number + value : 1 + } + [1] : { + name : 1 + type : number + value : 2 + } + ] + subtype : array + type : object + } + } + [1] : { + name : 1 + subtype : array + type : object + valuePreview : { + description : Array(2) + overflow : false + properties : [ + [0] : { + name : 0 + type : number + value : 3 + } + [1] : { + name : 1 + type : number + value : 4 + } + ] + subtype : array + type : object + } + } + ] + subtype : array + type : object + } + subtype : array + type : object + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 16 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : table + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : trace + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 17 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : trace + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.trace + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 18 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : trace + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.group + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 19 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : startGroup + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.groupEnd + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 20 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : endGroup + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.groupCollapsed + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 21 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : startGroupCollapsed + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : clear + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 22 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : clear + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : console.clear + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 23 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : clear + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : count: 1 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 10 + functionName : testFunction + lineNumber : 24 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : 1 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 12 + functionName : foo + lineNumber : 26 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 2 + functionName : testFunction + lineNumber : 28 + scriptId : <scriptId> + url : test.js + } + [2] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} +{ + method : Runtime.consoleAPICalled + params : { + args : [ + [0] : { + type : string + value : 2 + } + ] + executionContextId : <executionContextId> + stackTrace : { + callFrames : [ + [0] : { + columnNumber : 12 + functionName : foo + lineNumber : 26 + scriptId : <scriptId> + url : test.js + } + [1] : { + columnNumber : 2 + functionName : testFunction + lineNumber : 29 + scriptId : <scriptId> + url : test.js + } + [2] : { + columnNumber : 0 + functionName : + lineNumber : 0 + scriptId : <scriptId> + url : + } + ] + } + timestamp : <timestamp> + type : count + } +} diff --git a/deps/v8/test/inspector/runtime/console-methods.js b/deps/v8/test/inspector/runtime/console-methods.js new file mode 100644 index 0000000000..f6fb20758a --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-methods.js @@ -0,0 +1,36 @@ +// 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 console methods'); + +InspectorTest.addScript(` +function testFunction() { + console.debug('debug'); + console.error('error'); + console.info('info'); + console.log('log'); + console.warn('warn'); + console.dir('dir'); + console.dirxml('dirxml'); + console.table([[1,2],[3,4]]); + console.trace('trace'); + console.trace(); + console.group(); + console.groupEnd(); + console.groupCollapsed(); + console.clear('clear'); + console.clear(); + console.count('count'); + function foo() { + console.count(); + } + foo(); + foo(); +} +//# sourceURL=test.js`, 7, 26); + +Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); +Protocol.Runtime.enable(); +Protocol.Runtime.evaluate({ expression: 'testFunction()' }) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt b/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt new file mode 100644 index 0000000000..92fa158d2b --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-time-end-format-expected.txt @@ -0,0 +1,29 @@ +Checks format of console.timeEnd output + +Running test: zero +js: 0ms +timeEnd: 0ms + +Running test: verySmall +js: 1e-15ms +timeEnd: 1e-15ms + +Running test: small +js: 0.001ms +timeEnd: 0.001ms + +Running test: regular +js: 1.2345ms +timeEnd: 1.2345ms + +Running test: big +js: 10000.2345ms +timeEnd: 10000.2345ms + +Running test: veryBig +js: 1000000000000000.2ms +timeEnd: 1000000000000000.2ms + +Running test: huge +js: 1e+42ms +timeEnd: 1e+42ms diff --git a/deps/v8/test/inspector/runtime/console-time-end-format.js b/deps/v8/test/inspector/runtime/console-time-end-format.js new file mode 100644 index 0000000000..77e7b55831 --- /dev/null +++ b/deps/v8/test/inspector/runtime/console-time-end-format.js @@ -0,0 +1,45 @@ +// 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 format of console.timeEnd output'); + +Protocol.Runtime.enable(); +Protocol.Runtime.onConsoleAPICalled(message => { + InspectorTest.log(message.params.args[0].value); +}); + +InspectorTest.runTestSuite([ + function zero(next) { + checkInterval(0.0).then(next); + }, + function verySmall(next) { + checkInterval(1e-15).then(next); + }, + function small(next) { + checkInterval(0.001).then(next); + }, + function regular(next) { + checkInterval(1.2345).then(next); + }, + function big(next) { + checkInterval(10000.2345).then(next); + }, + function veryBig(next) { + checkInterval(1e+15 + 0.2345).then(next); + }, + function huge(next) { + checkInterval(1e+42).then(next); + } +]); + +function checkInterval(time) { + setCurrentTimeMSForTest(0.0); + return Protocol.Runtime.evaluate({ + expression: `console.log('js: ' + ${time} + 'ms')`}) + .then(() => Protocol.Runtime.evaluate({ + expression: 'console.time(\'timeEnd\')'})) + .then(() => setCurrentTimeMSForTest(time)) + .then(() => Protocol.Runtime.evaluate({ + expression: 'console.timeEnd(\'timeEnd\')'})); +} diff --git a/deps/v8/test/inspector/runtime/es6-module-expected.txt b/deps/v8/test/inspector/runtime/es6-module-expected.txt new file mode 100644 index 0000000000..421d88c4c3 --- /dev/null +++ b/deps/v8/test/inspector/runtime/es6-module-expected.txt @@ -0,0 +1,240 @@ +Checks basic ES6 modules support. +{ + method : Debugger.scriptParsed + params : { + endColumn : 17 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 9C014F7249BAFA12B91017817AD15091D01A9155 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module1 + } +} +{ + method : Debugger.scriptParsed + params : { + endColumn : 17 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 443A2FA24A6112E6B9101781E6A19B56BDC396D4 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module2 + } +} +{ + method : Debugger.scriptParsed + params : { + endColumn : 0 + endLine : 9 + executionContextId : <executionContextId> + hasSourceURL : false + hash : 54D834614FBF9B389082DAE06CD3EFC499BEBF13 + isLiveEdit : false + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module3 + } +} +console.log(module1) +foo (module1:2:10) +(anonymous) (module3:3:12) + +console.log(42) +(anonymous) (module3:3:8) + +console.log(module2) +foo (module2:2:10) +(anonymous) (module3:4:12) + +console.log(239) +(anonymous) (module3:4:8) + +{ + method : Debugger.paused + params : { + callFrames : [ + [0] : { + callFrameId : <callFrameId> + functionLocation : { + columnNumber : 0 + lineNumber : 0 + scriptId : <scriptId> + } + functionName : + location : { + columnNumber : 0 + lineNumber : 7 + scriptId : <scriptId> + } + scopeChain : [ + [0] : { + endLocation : { + columnNumber : 0 + lineNumber : 8 + scriptId : <scriptId> + } + object : { + className : Object + description : Object + objectId : <objectId> + type : object + } + startLocation : { + columnNumber : 0 + lineNumber : 0 + scriptId : <scriptId> + } + type : module + } + [1] : { + object : { + className : global + description : global + objectId : <objectId> + type : object + } + type : global + } + ] + this : { + type : undefined + } + } + ] + hitBreakpoints : [ + ] + reason : other + } +} +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : foo1 + value : { + className : Function + description : function foo() { console.log('module1'); return 42; } + objectId : <objectId> + type : function + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : foo2 + value : { + className : Function + description : function foo() { console.log('module2'); return 239; } + objectId : <objectId> + type : function + } + writable : true + } + [2] : { + configurable : true + enumerable : true + isOwn : true + name : a1 + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + [3] : { + configurable : true + enumerable : true + isOwn : true + name : a2 + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +{ + method : Debugger.scriptFailedToParse + params : { + endColumn : 1 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : FF746120E4E4F1BA4CB5762843D429DC872EBA18 + isModule : true + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : module4 + } +} +{ + method : Runtime.exceptionThrown + params : { + exceptionDetails : { + columnNumber : 0 + exception : { + className : SyntaxError + description : SyntaxError: Unexpected token } + objectId : <objectId> + preview : { + description : SyntaxError: Unexpected token } + overflow : false + properties : [ + [0] : { + name : stack + type : string + value : SyntaxError: Unexpected token } + } + [1] : { + name : message + type : string + value : Unexpected token } + } + ] + subtype : error + type : object + } + subtype : error + type : object + } + exceptionId : <exceptionId> + executionContextId : <executionContextId> + lineNumber : 0 + scriptId : <scriptId> + stackTrace : { + callFrames : [ + ] + } + text : Uncaught SyntaxError: Unexpected token } + url : module4 + } + timestamp : <timestamp> + } +} diff --git a/deps/v8/test/inspector/runtime/es6-module.js b/deps/v8/test/inspector/runtime/es6-module.js new file mode 100644 index 0000000000..e4e468ee5d --- /dev/null +++ b/deps/v8/test/inspector/runtime/es6-module.js @@ -0,0 +1,61 @@ +// 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 basic ES6 modules support.'); + +var module1 = ` +export function foo() { + console.log('module1'); + return 42; +} +export let a1 = 1`; + +var module2 = ` +export function foo() { + console.log('module2'); + return 239; +} +export let a2 = 2`; + +var module3 = ` +import { foo as foo1 } from 'module1'; +import { foo as foo2 } from 'module2'; +console.log(foo1()); +console.log(foo2()); +import { a1 } from 'module1'; +import { a2 } from 'module2'; +debugger; +`; + +var module4 = '}'; + +InspectorTest.setupScriptMap(); +// We get scriptParsed events for modules .. +Protocol.Debugger.onScriptParsed(InspectorTest.logMessage); +// .. scriptFailed to parse for modules with syntax error .. +Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage); +// .. API messages from modules contain correct stack trace .. +Protocol.Runtime.onConsoleAPICalled(message => { + InspectorTest.log(`console.log(${message.params.args[0].value})`); + InspectorTest.logCallFrames(message.params.stackTrace.callFrames); + InspectorTest.log(''); +}); +// .. we could break inside module and scope contains correct list of variables .. +Protocol.Debugger.onPaused(message => { + InspectorTest.logMessage(message); + Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeChain[0].object.objectId}) + .then(InspectorTest.logMessage) + .then(() => Protocol.Debugger.resume()); +}); +// .. we process uncaught errors from modules correctly. +Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage); + +Protocol.Runtime.enable(); +Protocol.Debugger.enable() + .then(() => InspectorTest.addModule(module1, "module1")) + .then(() => InspectorTest.addModule(module2, "module2")) + .then(() => InspectorTest.addModule(module3, "module3")) + .then(() => InspectorTest.addModule(module4, "module4")) + .then(() => InspectorTest.waitPendingTasks()) + .then(InspectorTest.completeTest); diff --git a/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt new file mode 100644 index 0000000000..d395067efe --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-entries-expected.txt @@ -0,0 +1,691 @@ +Checks internal [[Entries]] in Runtime.getProperties output + +Running test: maps +expression: new Map([[1,2],[3,4]]) +[ + [0] : { + key : 1 + value : 2 + } + [1] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {1 => 2} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: new Map() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: mapIterators +expression: new Map([[1,2],[3,4]]).entries() +[ + [0] : { + key : 1 + value : 2 + } + [1] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {1 => 2} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it +[ + [0] : { + key : 3 + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {3 => 4} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).keys(); it.next(); it +[ + [0] : { + value : 3 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 3 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).values(); it.next(); it +[ + [0] : { + value : 4 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 4 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Map([[1,2],[3,4]]).entries(); it.next(); it.next(); it +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: sets +expression: new Set([1,2]) +[ + [0] : { + value : 1 + } + [1] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 1 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: new Set() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: setIterators +expression: new Set([1,2]).values() +[ + [0] : { + value : 1 + } + [1] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 1 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : true + enumerable : true + isOwn : true + name : 1 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [2] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 2 + type : number + value : 2 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).values(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).keys(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).entries(); it.next(); it +[ + [0] : { + value : 2 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : 2 + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} +expression: it = new Set([1,2]).values(); it.next(); it.next(); it +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} + +Running test: weakMaps +expression: new WeakMap() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} +expression: new WeakMap([[{ a: 2 }, 42]]) +[ + [0] : { + key : { + a : 2 + } + value : 42 + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : {Object => 42} + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} + +Running test: weakSets +expression: new WeakSet() +[ +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 0 + type : number + value : 0 + } + writable : true + } + ] + } +} +expression: new WeakSet([{a:2}]) +[ + [0] : { + value : { + a : 2 + } + } +] +{ + id : <messageId> + result : { + result : [ + [0] : { + configurable : true + enumerable : true + isOwn : true + name : 0 + value : { + className : Object + description : Object + objectId : <objectId> + subtype : internal#entry + type : object + } + writable : true + } + [1] : { + configurable : false + enumerable : false + isOwn : true + name : length + value : { + description : 1 + type : number + value : 1 + } + writable : true + } + ] + } +} diff --git a/deps/v8/test/inspector/runtime/internal-properties-entries.js b/deps/v8/test/inspector/runtime/internal-properties-entries.js new file mode 100644 index 0000000000..2e49c92b34 --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-entries.js @@ -0,0 +1,65 @@ +// 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 internal [[Entries]] in Runtime.getProperties output'); + +Protocol.Runtime.enable(); + +InspectorTest.runTestSuite([ + function maps(next) { + checkExpression('new Map([[1,2],[3,4]])') + .then(() => checkExpression('new Map()')) + .then(next); + }, + + function mapIterators(next) { + checkExpression('new Map([[1,2],[3,4]]).entries()') + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).keys(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).values(); it.next(); it')) + .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.next(); it.next(); it')) + .then(next); + }, + + function sets(next) { + checkExpression('new Set([1,2])') + .then(() => checkExpression('new Set()')) + .then(next); + }, + + function setIterators(next) { + checkExpression('new Set([1,2]).values()') + .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).keys(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).entries(); it.next(); it')) + .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it.next(); it')) + .then(next); + }, + + function weakMaps(next) { + checkExpression('new WeakMap()') + .then(() => checkExpression('new WeakMap([[{ a: 2 }, 42]])')) + .then(next); + }, + + function weakSets(next) { + checkExpression('new WeakSet()') + .then(() => checkExpression('new WeakSet([{a:2}])')) + .then(next); + } +]); + +function checkExpression(expression) +{ + InspectorTest.log(`expression: ${expression}`); + var entriesObjectId; + return Protocol.Runtime.evaluate({ expression: expression }) + .then(message => Protocol.Runtime.getProperties({ objectId: message.result.result.objectId })) + .then(message => message.result.internalProperties.filter(p => p.name === '[[Entries]]')[0]) + .then(entries => entriesObjectId = entries.value.objectId) + .then(() => Protocol.Runtime.callFunctionOn({ objectId: entriesObjectId, functionDeclaration: 'function f() { return this; }', returnByValue: true })) + .then(message => InspectorTest.logMessage(message.result.result.value)) + .then(() => Protocol.Runtime.getProperties({ objectId: entriesObjectId, ownProperties: true })) + .then(message => InspectorTest.logMessage(message)); +} diff --git a/deps/v8/test/inspector/runtime/internal-properties-expected.txt b/deps/v8/test/inspector/runtime/internal-properties-expected.txt new file mode 100644 index 0000000000..deee4cfdbd --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties-expected.txt @@ -0,0 +1,576 @@ +Checks internal properties in Runtime.getProperties output + +Running test: generatorFunction +expression: (function* foo() { yield 1 }) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[FunctionLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 14 + lineNumber : 0 + scriptId : <scriptId> + } + } + } + [1] : { + name : [[IsGenerator]] + value : { + type : boolean + value : true + } + } + [2] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[1] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: regularFunction +expression: (function foo() {}) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[FunctionLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 0 + scriptId : <scriptId> + } + } + } + [1] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[1] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: boxedObjects +expression: new Number(239) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + description : 239 + type : number + value : 239 + } + } + ] + } +} +expression: new Boolean(false) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + type : boolean + value : false + } + } + ] + } +} +expression: new String('abc') +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + type : string + value : abc + } + } + ] + } +} +expression: Object(Symbol(42)) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PrimitiveValue]] + value : { + description : Symbol(42) + objectId : <objectId> + type : symbol + } + } + ] + } +} + +Running test: promise +expression: Promise.resolve(42) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PromiseStatus]] + value : { + type : string + value : resolved + } + } + [1] : { + name : [[PromiseValue]] + value : { + description : 42 + type : number + value : 42 + } + } + ] + } +} +expression: new Promise(() => undefined) +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[PromiseStatus]] + value : { + type : string + value : pending + } + } + [1] : { + name : [[PromiseValue]] + value : { + type : undefined + } + } + ] + } +} + +Running test: generatorObject +expression: gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} +expression: gen1.next();gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 2 + lineNumber : 9 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} +expression: gen1.next();gen1 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : closed + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + [4] : { + name : [[Scopes]] + value : { + className : Array + description : Scopes[2] + objectId : <objectId> + subtype : internal#scopeList + type : object + } + } + ] + } +} + +Running test: generatorObjectDebuggerDisabled +expression: gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + ] + } +} +expression: gen2.next();gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : suspended + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 2 + lineNumber : 9 + scriptId : <scriptId> + } + } + } + ] + } +} +expression: gen2.next();gen2 +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[GeneratorStatus]] + value : { + type : string + value : closed + } + } + [1] : { + name : [[GeneratorFunction]] + value : { + className : GeneratorFunction + description : function* foo() { yield 1; } + objectId : <objectId> + type : function + } + } + [2] : { + name : [[GeneratorReceiver]] + value : { + className : global + description : global + objectId : <objectId> + type : object + } + } + [3] : { + name : [[GeneratorLocation]] + value : { + description : Object + subtype : internal#location + type : object + value : { + columnNumber : 13 + lineNumber : 8 + scriptId : <scriptId> + } + } + } + ] + } +} + +Running test: iteratorObject +expression: (new Map([[1,2]])).entries() +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[IteratorHasMore]] + value : { + type : boolean + value : true + } + } + [1] : { + name : [[IteratorIndex]] + value : { + description : 0 + type : number + value : 0 + } + } + [2] : { + name : [[IteratorKind]] + value : { + type : string + value : entries + } + } + [3] : { + name : [[Entries]] + value : { + className : Array + description : Array(1) + objectId : <objectId> + subtype : array + type : object + } + } + ] + } +} +expression: (new Set([[1,2]])).entries() +{ + id : <messageId> + result : { + internalProperties : [ + [0] : { + name : [[IteratorHasMore]] + value : { + type : boolean + value : true + } + } + [1] : { + name : [[IteratorIndex]] + value : { + description : 0 + type : number + value : 0 + } + } + [2] : { + name : [[IteratorKind]] + value : { + type : string + value : entries + } + } + [3] : { + name : [[Entries]] + value : { + className : Array + description : Array(1) + objectId : <objectId> + subtype : array + type : object + } + } + ] + } +} diff --git a/deps/v8/test/inspector/runtime/internal-properties.js b/deps/v8/test/inspector/runtime/internal-properties.js new file mode 100644 index 0000000000..86fe96ab1c --- /dev/null +++ b/deps/v8/test/inspector/runtime/internal-properties.js @@ -0,0 +1,70 @@ +// 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 internal properties in Runtime.getProperties output'); + +InspectorTest.addScript(` +function* foo() { + yield 1; +} +var gen1 = foo(); +var gen2 = foo(); +//# sourceURL=test.js`, 7, 26); + +Protocol.Runtime.enable(); +Protocol.Debugger.enable(); + +InspectorTest.runTestSuite([ + function generatorFunction(next) { + checkExpression('(function* foo() { yield 1 })').then(next); + }, + + function regularFunction(next) { + checkExpression('(function foo() {})').then(next); + }, + + function boxedObjects(next) { + checkExpression('new Number(239)') + .then(() => checkExpression('new Boolean(false)')) + .then(() => checkExpression('new String(\'abc\')')) + .then(() => checkExpression('Object(Symbol(42))')) + .then(next); + }, + + function promise(next) { + checkExpression('Promise.resolve(42)') + .then(() => checkExpression('new Promise(() => undefined)')) + .then(next); + }, + + function generatorObject(next) { + checkExpression('gen1') + .then(() => checkExpression('gen1.next();gen1')) + .then(() => checkExpression('gen1.next();gen1')) + .then(next); + }, + + function generatorObjectDebuggerDisabled(next) { + Protocol.Debugger.disable() + .then(() => checkExpression('gen2')) + .then(() => checkExpression('gen2.next();gen2')) + .then(() => checkExpression('gen2.next();gen2')) + .then(next); + }, + + function iteratorObject(next) { + checkExpression('(new Map([[1,2]])).entries()') + .then(() => checkExpression('(new Set([[1,2]])).entries()')) + .then(next); + } +]); + +function checkExpression(expression) +{ + InspectorTest.log(`expression: ${expression}`); + return Protocol.Runtime.evaluate({ expression: expression }) + .then(message => Protocol.Runtime.getProperties({ objectId: message.result.result.objectId })) + .then(message => { delete message.result.result; return message; }) + .then(InspectorTest.logMessage); +} diff --git a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt index d526d5d447..ee70e94c2a 100644 --- a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt +++ b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale-expected.txt @@ -1,3 +1,4 @@ + Running test: consoleLogWithDefaultLocale { method : Runtime.consoleAPICalled @@ -34,14 +35,14 @@ set locale to fr_CA.UTF-8 (has comma as separator) args : [ [0] : { type : string - value : a: x.xms + value : a: 0.001ms } ] executionContextId : <executionContextId> stackTrace : { callFrames : [ [0] : { - columnNumber : 27 + columnNumber : 8 functionName : lineNumber : 0 scriptId : <scriptId> @@ -50,7 +51,7 @@ set locale to fr_CA.UTF-8 (has comma as separator) ] } timestamp : <timestamp> - type : debug + type : timeEnd } } @@ -117,14 +118,14 @@ set locale to fr_CA.UTF-8 (has comma as separator) args : [ [0] : { type : string - value : a: x.xms + value : a: 0.001ms } ] executionContextId : <executionContextId> stackTrace : { callFrames : [ [0] : { - columnNumber : 27 + columnNumber : 8 functionName : lineNumber : 0 scriptId : <scriptId> @@ -133,6 +134,6 @@ set locale to fr_CA.UTF-8 (has comma as separator) ] } timestamp : <timestamp> - type : debug + type : timeEnd } } diff --git a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js index 381dfab31e..27be5ed905 100644 --- a/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js +++ b/deps/v8/test/inspector/runtime/protocol-works-with-different-locale.js @@ -4,7 +4,7 @@ Protocol.Runtime.enable(); -Protocol.Runtime.onConsoleAPICalled(dumpConsoleApiCalled); +Protocol.Runtime.onConsoleAPICalled(InspectorTest.logMessage); InspectorTest.runTestSuite([ function consoleLogWithDefaultLocale(next) { @@ -14,7 +14,11 @@ InspectorTest.runTestSuite([ function consoleTimeWithCommaAsSeparator(next) { InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)"); setlocale("fr_CA.UTF-8"); - Protocol.Runtime.evaluate({ expression: "console.time(\"a\"); console.timeEnd(\"a\")"}).then(next); + setCurrentTimeMSForTest(0.0); + Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"}) + .then(() => setCurrentTimeMSForTest(0.001)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"})) + .then(next); }, function consoleLogWithCommaAsSeparator(next) { @@ -27,14 +31,10 @@ InspectorTest.runTestSuite([ InspectorTest.log("set locale to fr_CA.UTF-8 (has comma as separator)"); setlocale("fr_CA.UTF-8"); Protocol.Runtime.evaluate({ expression: "console.log(239) "}) - .then(() => Protocol.Runtime.evaluate({ expression: "console.time(\"a\"); console.timeEnd(\"a\")"})) + .then(() => setCurrentTimeMSForTest(0.0)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.time(\"a\");"})) + .then(() => setCurrentTimeMSForTest(0.001)) + .then(() => Protocol.Runtime.evaluate({ expression: "console.timeEnd(\"a\");"})) .then(next); } ]); - -function dumpConsoleApiCalled(message) { - var firstArg = message.params.args[0]; - if (firstArg.type === "string") - firstArg.value = firstArg.value.replace(/[0-9]+/g, "x"); - InspectorTest.logMessage(message); -} diff --git a/deps/v8/test/inspector/task-runner.cc b/deps/v8/test/inspector/task-runner.cc index 14270177f0..4bfd784900 100644 --- a/deps/v8/test/inspector/task-runner.cc +++ b/deps/v8/test/inspector/task-runner.cc @@ -22,6 +22,13 @@ void ReportUncaughtException(v8::Isolate* isolate, fprintf(stderr, "Unhandle exception: %s\n", message.data()); } +v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { + v8::internal::Vector<uint16_t> buffer = + v8::internal::Vector<uint16_t>::New(str->Length()); + str->Write(buffer.start(), 0, str->Length()); + return buffer; +} + } // namespace TaskRunner::TaskRunner(v8::ExtensionConfiguration* extensions, @@ -101,6 +108,19 @@ void TaskRunner::Terminate() { process_queue_semaphore_.Signal(); } +void TaskRunner::RegisterModule(v8::internal::Vector<uint16_t> name, + v8::Local<v8::Module> module) { + modules_[name] = v8::Global<v8::Module>(isolate_, module); +} + +v8::MaybeLocal<v8::Module> TaskRunner::ModuleResolveCallback( + v8::Local<v8::Context> context, v8::Local<v8::String> specifier, + v8::Local<v8::Module> referrer) { + std::string str = *v8::String::Utf8Value(specifier); + TaskRunner* runner = TaskRunner::FromContext(context); + return runner->modules_[ToVector(specifier)].Get(runner->isolate_); +} + TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { for (;;) { if (is_terminated_.Value()) return nullptr; @@ -125,17 +145,6 @@ TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) { context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex)); } -namespace { - -v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { - v8::internal::Vector<uint16_t> buffer = - v8::internal::Vector<uint16_t>::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); - return buffer; -} - -} // namespace - AsyncTask::AsyncTask(const char* task_name, v8_inspector::V8Inspector* inspector) : inspector_(task_name ? inspector : nullptr) { @@ -157,20 +166,18 @@ void AsyncTask::Run(v8::Isolate* isolate, ExecuteStringTask::ExecuteStringTask( const v8::internal::Vector<uint16_t>& expression, v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, - v8::Local<v8::Integer> column_offset, const char* task_name, - v8_inspector::V8Inspector* inspector) + v8::Local<v8::Integer> column_offset, v8::Local<v8::Boolean> is_module, + const char* task_name, v8_inspector::V8Inspector* inspector) : AsyncTask(task_name, inspector), expression_(expression), name_(ToVector(name)), line_offset_(line_offset.As<v8::Int32>()->Value()), - column_offset_(column_offset.As<v8::Int32>()->Value()) {} + column_offset_(column_offset.As<v8::Int32>()->Value()), + is_module_(is_module->Value()) {} ExecuteStringTask::ExecuteStringTask( const v8::internal::Vector<const char>& expression) - : AsyncTask(nullptr, nullptr), - expression_utf8_(expression), - line_offset_(0), - column_offset_(0) {} + : AsyncTask(nullptr, nullptr), expression_utf8_(expression) {} void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, const v8::Global<v8::Context>& context) { @@ -188,7 +195,14 @@ void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, v8::Local<v8::Integer> column_offset = v8::Integer::New(isolate, column_offset_); - v8::ScriptOrigin origin(name, line_offset, column_offset); + v8::ScriptOrigin origin( + name, line_offset, column_offset, + /* resource_is_shared_cross_origin */ v8::Local<v8::Boolean>(), + /* script_id */ v8::Local<v8::Integer>(), + /* source_map_url */ v8::Local<v8::Value>(), + /* resource_is_opaque */ v8::Local<v8::Boolean>(), + /* is_wasm */ v8::Local<v8::Boolean>(), + v8::Boolean::New(isolate, is_module_)); v8::Local<v8::String> source; if (expression_.length()) { source = v8::String::NewFromTwoByte(isolate, expression_.start(), @@ -203,10 +217,28 @@ void ExecuteStringTask::AsyncRun(v8::Isolate* isolate, } v8::ScriptCompiler::Source scriptSource(source, origin); - v8::Local<v8::Script> script; - if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) - .ToLocal(&script)) - return; - v8::MaybeLocal<v8::Value> result; - result = script->Run(local_context); + if (!is_module_) { + v8::Local<v8::Script> script; + if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) + .ToLocal(&script)) + return; + v8::MaybeLocal<v8::Value> result; + if (inspector_) + inspector_->willExecuteScript(local_context, + script->GetUnboundScript()->GetId()); + result = script->Run(local_context); + if (inspector_) inspector_->didExecuteScript(local_context); + } else { + v8::Local<v8::Module> module; + if (!v8::ScriptCompiler::CompileModule(isolate, &scriptSource) + .ToLocal(&module)) { + return; + } + if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) + return; + v8::Local<v8::Value> result; + if (!module->Evaluate(local_context).ToLocal(&result)) return; + TaskRunner* runner = TaskRunner::FromContext(local_context); + runner->RegisterModule(name_, module); + } } diff --git a/deps/v8/test/inspector/task-runner.h b/deps/v8/test/inspector/task-runner.h index 045bba0d25..73d0f0430e 100644 --- a/deps/v8/test/inspector/task-runner.h +++ b/deps/v8/test/inspector/task-runner.h @@ -5,6 +5,8 @@ #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ +#include <map> + #include "include/v8-inspector.h" #include "include/v8-platform.h" #include "include/v8.h" @@ -14,6 +16,16 @@ #include "src/locked-queue-inl.h" #include "src/vector.h" +struct VectorCompare { + bool operator()(const v8::internal::Vector<uint16_t>& lhs, + const v8::internal::Vector<uint16_t>& rhs) const { + for (int i = 0; i < lhs.length() && i < rhs.length(); ++i) { + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i]; + } + return false; + } +}; + class TaskRunner : public v8::base::Thread { public: class Task { @@ -42,6 +54,12 @@ class TaskRunner : public v8::base::Thread { void Terminate(); + void RegisterModule(v8::internal::Vector<uint16_t> name, + v8::Local<v8::Module> module); + static v8::MaybeLocal<v8::Module> ModuleResolveCallback( + v8::Local<v8::Context> context, v8::Local<v8::String> specifier, + v8::Local<v8::Module> referrer); + private: void InitializeContext(); Task* GetNext(bool only_protocol); @@ -60,6 +78,10 @@ class TaskRunner : public v8::base::Thread { v8::internal::LockedQueue<Task*> deffered_queue_; v8::base::Semaphore process_queue_semaphore_; + std::map<v8::internal::Vector<uint16_t>, v8::Global<v8::Module>, + VectorCompare> + modules_; + int nested_loop_count_; v8::base::AtomicNumber<int> is_terminated_; @@ -77,7 +99,7 @@ class AsyncTask : public TaskRunner::Task { virtual void AsyncRun(v8::Isolate* isolate, const v8::Global<v8::Context>& context) = 0; - private: + protected: v8_inspector::V8Inspector* inspector_; }; @@ -86,7 +108,8 @@ class ExecuteStringTask : public AsyncTask { ExecuteStringTask(const v8::internal::Vector<uint16_t>& expression, v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, - v8::Local<v8::Integer> column_offset, const char* task_name, + v8::Local<v8::Integer> column_offset, + v8::Local<v8::Boolean> is_module, const char* task_name, v8_inspector::V8Inspector* inspector); explicit ExecuteStringTask( const v8::internal::Vector<const char>& expression); @@ -99,8 +122,9 @@ class ExecuteStringTask : public AsyncTask { v8::internal::Vector<uint16_t> expression_; v8::internal::Vector<const char> expression_utf8_; v8::internal::Vector<uint16_t> name_; - int32_t line_offset_; - int32_t column_offset_; + int32_t line_offset_ = 0; + int32_t column_offset_ = 0; + bool is_module_ = false; DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); }; diff --git a/deps/v8/test/inspector/testcfg.py b/deps/v8/test/inspector/testcfg.py index 6995669a15..fc498aa113 100644 --- a/deps/v8/test/inspector/testcfg.py +++ b/deps/v8/test/inspector/testcfg.py @@ -71,7 +71,7 @@ class InspectorProtocolTestSuite(testsuite.TestSuite): def ExpIterator(): for line in expected_lines: - if line.startswith("#") or not line.strip(): continue + if not line.strip(): continue yield line.strip() def ActIterator(lines): |