diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-02-14 11:27:26 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-02-22 15:55:42 +0100 |
commit | 7a77daf24344db7942e34c962b0f1ee729ab7af5 (patch) | |
tree | e7cbe7bf4e2f4b802a8f5bc18336c546cd6a0d7f /deps/v8/test/inspector | |
parent | 5f08871ee93ea739148cc49e0f7679e33c70295a (diff) | |
download | android-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.tar.gz android-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.tar.bz2 android-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.zip |
deps: update V8 to 5.6.326.55
PR-URL: https://github.com/nodejs/node/pull/10992
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/test/inspector')
36 files changed, 3749 insertions, 139 deletions
diff --git a/deps/v8/test/inspector/BUILD.gn b/deps/v8/test/inspector/BUILD.gn index cb96bf423c..e51b011569 100644 --- a/deps/v8/test/inspector/BUILD.gn +++ b/deps/v8/test/inspector/BUILD.gn @@ -3,37 +3,34 @@ # found in the LICENSE file. import("../../gni/v8.gni") +import("//build_overrides/v8.gni") -v8_executable("inspector-test") { - testonly = true +if (v8_enable_inspector_override) { + v8_executable("inspector-test") { + testonly = true - sources = [ - "inspector-impl.cc", - "inspector-impl.h", - "inspector-test.cc", - "task-runner.cc", - "task-runner.h", - ] + sources = [ + "inspector-impl.cc", + "inspector-impl.h", + "inspector-test.cc", + "task-runner.cc", + "task-runner.h", + ] - configs = [ - "../..:external_config", - "../..:internal_config_base", - ] + configs = [ + "../..:external_config", + "../..:internal_config_base", + ] - deps = [ - "../..:v8_libplatform", - "//build/config/sanitizers:deps", - "//build/win:default_exe_manifest", - ] + deps = [ + "../..:v8", + "../..:v8_libbase", + "../..:v8_libplatform", + "//build/config/sanitizers:deps", + "//build/win:default_exe_manifest", + ] - if (is_component_build) { - # inspector-test can't be built against a shared library, so we - # need to depend on the underlying static target in that case. - deps += [ "../..:v8_maybe_snapshot" ] - } else { - deps += [ "../..:v8" ] + cflags = [] + ldflags = [] } - - cflags = [] - ldflags = [] } diff --git a/deps/v8/test/inspector/DEPS b/deps/v8/test/inspector/DEPS index af99e05595..93c8f6afa5 100644 --- a/deps/v8/test/inspector/DEPS +++ b/deps/v8/test/inspector/DEPS @@ -1,9 +1,9 @@ include_rules = [ "-src", + "+src/base/atomic-utils.h", "+src/base/macros.h", "+src/base/platform/platform.h", "+src/flags.h", - "+src/inspector/string-16.h", "+src/locked-queue-inl.h", "+src/utils.h", "+src/vector.h", diff --git a/deps/v8/test/inspector/console/destroy-context-during-log-expected.txt b/deps/v8/test/inspector/console/destroy-context-during-log-expected.txt new file mode 100644 index 0000000000..c8e9293ff2 --- /dev/null +++ b/deps/v8/test/inspector/console/destroy-context-during-log-expected.txt @@ -0,0 +1,8 @@ +{ + type : string + value : First inspector activity after attaching inspector +} +{ + type : string + value : End of test +} diff --git a/deps/v8/test/inspector/console/destroy-context-during-log.js b/deps/v8/test/inspector/console/destroy-context-during-log.js new file mode 100644 index 0000000000..2289fbefc0 --- /dev/null +++ b/deps/v8/test/inspector/console/destroy-context-during-log.js @@ -0,0 +1,38 @@ +// 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. + +const expression = ` + Object.defineProperty(Object.prototype, 'RemoteObject', { + configurable: true, + set(v) { + delete Object.prototype.RemoteObject; + this.RemoteObject = v; + + detachInspector(); + setTimeout(function() { + // Attach the inspector again for the sake of establishing a + // communication channel with the frontend test runner. + attachInspector(); + console.log("End of test"); + }, 0); + }, + }); + + // Before the whole script runs, the inspector is already attached. + // Re-attach the inspector and trigger the console API to make sure that the + // injected inspector script runs again (and triggers the above setter). + detachInspector(); + attachInspector(); + console.log("First inspector activity after attaching inspector"); +`; + +Protocol.Runtime.enable(); +Protocol.Runtime.evaluate({ expression: expression }); + +Protocol.Runtime.onConsoleAPICalled(function(result) { + InspectorTest.logObject(result.params.args[0]); + if (result.params.args[0].value == "End of test") { + InspectorTest.completeTest(); + } +}); diff --git a/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec-expected.txt b/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec-expected.txt new file mode 100644 index 0000000000..90d57c2dfe --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec-expected.txt @@ -0,0 +1,109 @@ +This test runs asm.js which calls back to JS. Before executing (after the script is parsed) we set breakpoints in the asm.js code. + +Running test: enableDebugger + +Running test: addScript +Script nr 1 parsed! +First script; assuming testFunction. +Flooding script with breakpoints for all lines (0 - 20)... +Setting breakpoint on line 0 +error: undefined +Setting breakpoint on line 1 +error: undefined +Setting breakpoint on line 2 +error: undefined +Setting breakpoint on line 3 +error: undefined +Setting breakpoint on line 4 +error: undefined +Setting breakpoint on line 5 +error: undefined +Setting breakpoint on line 6 +error: undefined +Setting breakpoint on line 7 +error: undefined +Setting breakpoint on line 8 +error: undefined +Setting breakpoint on line 9 +error: undefined +Setting breakpoint on line 10 +error: undefined +Setting breakpoint on line 11 +error: undefined +Setting breakpoint on line 12 +error: undefined +Setting breakpoint on line 13 +error: undefined +Setting breakpoint on line 14 +error: undefined +Setting breakpoint on line 15 +error: undefined +Setting breakpoint on line 16 +error: undefined +Setting breakpoint on line 17 +error: undefined +Setting breakpoint on line 18 +error: undefined +Setting breakpoint on line 19 +error: undefined + +Running test: runTestFunction +Script nr 2 parsed! +Paused #1 + - [0] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":17,"columnNumber":2} + - [1] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #2 + - [0] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":12} + - [1] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #3 + - [0] {"functionName":"generateAsmJs","function_lineNumber":1,"function_columnNumber":24,"lineNumber":2,"columnNumber":4} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":12} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #4 + - [0] {"functionName":"generateAsmJs","function_lineNumber":1,"function_columnNumber":24,"lineNumber":3,"columnNumber":30} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":12} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #5 + - [0] {"functionName":"generateAsmJs","function_lineNumber":1,"function_columnNumber":24,"lineNumber":10,"columnNumber":4} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":12} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #6 + - [0] {"functionName":"generateAsmJs","function_lineNumber":1,"function_columnNumber":24,"lineNumber":11,"columnNumber":2} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":12} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #7 + - [0] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [1] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #8 + - [0] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #9 + - [0] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":5,"columnNumber":6} + - [1] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [2] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [3] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #10 + - [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":14,"columnNumber":4} + - [1] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":5,"columnNumber":6} + - [2] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #11 + - [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":15,"columnNumber":2} + - [1] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":5,"columnNumber":6} + - [2] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #12 + - [0] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":6,"columnNumber":4} + - [1] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [2] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [3] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Paused #13 + - [0] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":9,"columnNumber":4} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} + +Running test: finished +Finished TestSuite. diff --git a/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec.js b/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec.js new file mode 100644 index 0000000000..5c0dbaaefb --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-breakpoint-before-exec.js @@ -0,0 +1,128 @@ +// 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: --validate-asm --allow-natives-syntax + +InspectorTest.log( + 'This test runs asm.js which calls back to JS. Before executing (after ' + + 'the script is parsed) we set breakpoints in the asm.js code.'); + +function testFunction() { + function generateAsmJs(stdlib, foreign, heap) { + 'use asm'; + var debugger_fun = foreign.call_debugger; + function callDebugger() { + debugger_fun(); + } + function redirectFun() { + callDebugger(); + } + return redirectFun; + } + + function call_debugger() { + debugger; + } + + %OptimizeFunctionOnNextCall(generateAsmJs); + var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined); + fun(); +} + +Protocol.Debugger.onPaused(handleDebuggerPaused); +Protocol.Debugger.onScriptParsed(handleScriptParsed); + +function printResultAndContinue(next, message) { + if (message.result && message.result.exceptionDetails) + InspectorTest.logMessage(message.result.exceptionDetails); + else if (message.error) + InspectorTest.logMessage(message.error); + else if (message.result && message.result.type !== undefined) + InspectorTest.logMessage(message.result); + next(); +} + +InspectorTest.runTestSuite([ + function enableDebugger(next) { + Protocol.Debugger.enable().then(next); + }, + + function addScript(next) { + afterScriptParsedCallback = next; + InspectorTest.addScript(testFunction.toString()); + }, + + function runTestFunction(next) { + Protocol.Runtime.evaluate({'expression': 'testFunction()'}) + .then(printResultAndContinue.bind(null, next)); + }, + + function finished(next) { + InspectorTest.log('Finished TestSuite.'); + next(); + }, +]); + +function locationToString(callFrame) { + var res = {functionName: callFrame.functionName}; + for (var attr in callFrame.functionLocation) { + if (attr == 'scriptId') continue; + res['function_' + attr] = callFrame.functionLocation[attr]; + } + for (var attr in callFrame.location) { + if (attr == 'scriptId') continue; + res[attr] = callFrame.location[attr]; + } + return JSON.stringify(res); +} + +function logStackTrace(messageObject) { + var frames = messageObject.params.callFrames; + for (var i = 0; i < frames.length; ++i) { + InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i])); + } +} + +var numPaused = 0; + +function handleDebuggerPaused(messageObject) +{ + ++numPaused; + InspectorTest.log('Paused #' + numPaused); + logStackTrace(messageObject); + Protocol.Debugger.resume(); +} + +var numScripts = 0; + +function handleScriptParsed(messageObject) +{ + var scriptId = messageObject.params.scriptId; + ++numScripts; + InspectorTest.log('Script nr ' + numScripts + ' parsed!'); + if (numScripts > 1) return; + + var startLine = messageObject.params.startLine; + var endLine = messageObject.params.endLine; + InspectorTest.log('First script; assuming testFunction.'); + InspectorTest.log( + 'Flooding script with breakpoints for all lines (' + startLine + ' - ' + + endLine + ')...'); + var currentLine = startLine; + function setNextBreakpoint(message) { + if (message) InspectorTest.logMessage('error: ' + message.error); + if (currentLine == endLine) { + afterScriptParsedCallback(); + return; + } + var thisLine = currentLine; + currentLine += 1; + InspectorTest.log('Setting breakpoint on line ' + thisLine); + Protocol.Debugger + .setBreakpoint( + {'location': {'scriptId': scriptId, 'lineNumber': thisLine}}) + .then(setNextBreakpoint); + } + setNextBreakpoint(); +} diff --git a/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec-expected.txt b/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec-expected.txt new file mode 100644 index 0000000000..32c950d2bd --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec-expected.txt @@ -0,0 +1,99 @@ +This test runs asm.js which calls back to JS. JS triggers a break, on pause we set breakpoints in the asm.js code. + +Running test: enableDebugger + +Running test: addScript +Script nr 1 parsed! + +Running test: runTestFunction +Script nr 2 parsed! +Paused #1 + - [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":14,"columnNumber":4} + - [1] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":5,"columnNumber":6} + - [2] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +First time paused, setting breakpoints! +Flooding script with breakpoints for all lines (0 - 23)... +Setting breakpoint on line 0 +error: undefined +Setting breakpoint on line 1 +error: undefined +Setting breakpoint on line 2 +error: undefined +Setting breakpoint on line 3 +error: undefined +Setting breakpoint on line 4 +error: undefined +Setting breakpoint on line 5 +error: undefined +Setting breakpoint on line 6 +error: undefined +Setting breakpoint on line 7 +error: undefined +Setting breakpoint on line 8 +error: undefined +Setting breakpoint on line 9 +error: undefined +Setting breakpoint on line 10 +error: undefined +Setting breakpoint on line 11 +error: undefined +Setting breakpoint on line 12 +error: undefined +Setting breakpoint on line 13 +error: undefined +Setting breakpoint on line 14 +error: undefined +Setting breakpoint on line 15 +error: undefined +Setting breakpoint on line 16 +error: undefined +Setting breakpoint on line 17 +error: undefined +Setting breakpoint on line 18 +error: undefined +Setting breakpoint on line 19 +error: undefined +Setting breakpoint on line 20 +error: undefined +Setting breakpoint on line 21 +error: undefined +Setting breakpoint on line 22 +error: undefined +Script nr 3 parsed! +Resuming... +Paused #2 + - [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":15,"columnNumber":2} + - [1] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":5,"columnNumber":6} + - [2] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Script nr 4 parsed! +Resuming... +Paused #3 + - [0] {"functionName":"callDebugger","function_lineNumber":4,"function_columnNumber":25,"lineNumber":6,"columnNumber":4} + - [1] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":8,"columnNumber":6} + - [2] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [3] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Script nr 5 parsed! +Resuming... +Paused #4 + - [0] {"functionName":"redirectFun","function_lineNumber":7,"function_columnNumber":24,"lineNumber":9,"columnNumber":4} + - [1] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":19,"columnNumber":2} + - [2] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Script nr 6 parsed! +Resuming... +Paused #5 + - [0] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":21,"columnNumber":17} + - [1] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Script nr 7 parsed! +Resuming... +Paused #6 + - [0] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":22,"columnNumber":2} + - [1] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Script nr 8 parsed! +Resuming... + +Running test: finished +Finished TestSuite. diff --git a/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec.js b/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec.js new file mode 100644 index 0000000000..2a29dc1ea4 --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-breakpoint-during-exec.js @@ -0,0 +1,165 @@ +// 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: --validate-asm --allow-natives-syntax + +InspectorTest.log( + 'This test runs asm.js which calls back to JS. JS triggers a break, on ' + + 'pause we set breakpoints in the asm.js code.'); + +function testFunction() { + function generateAsmJs(stdlib, foreign, heap) { + 'use asm'; + var debugger_fun = foreign.call_debugger; + function callDebugger() { + debugger_fun(); + } + function redirectFun() { + callDebugger(); + } + return redirectFun; + } + + function call_debugger() { + debugger; + } + + %OptimizeFunctionOnNextCall(generateAsmJs); + var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined); + fun(); + + var finished = 'finished'; + debugger; +} + +Protocol.Debugger.onPaused(handleDebuggerPaused); +Protocol.Debugger.onScriptParsed(handleScriptParsed); + +function printResultAndContinue(next, message) { + if (message.result && message.result.exceptionDetails) + InspectorTest.logMessage(message.result.exceptionDetails); + else if (message.error) + InspectorTest.logMessage(message.error); + else if (message.result && message.result.type !== undefined) + InspectorTest.logMessage(message.result); + if (next) next(); +} + +InspectorTest.runTestSuite([ + function enableDebugger(next) { + Protocol.Debugger.enable().then(next); + }, + + function addScript(next) { + afterScriptParsedCallback = next; + InspectorTest.addScript(testFunction.toString()); + }, + + function runTestFunction(next) { + afterFinishedTestFunctionCallback = next; + Protocol.Runtime.evaluate({'expression': 'testFunction()'}) + .then(printResultAndContinue.bind(null, null)); + }, + + function finished(next) { + InspectorTest.log('Finished TestSuite.'); + next(); + }, +]); + +function locationToString(callFrame) { + var res = {functionName: callFrame.functionName}; + for (var attr in callFrame.functionLocation) { + if (attr == 'scriptId') continue; + res['function_' + attr] = callFrame.functionLocation[attr]; + } + for (var attr in callFrame.location) { + if (attr == 'scriptId') continue; + res[attr] = callFrame.location[attr]; + } + return JSON.stringify(res); +} + +function logStackTrace(messageObject) { + var frames = messageObject.params.callFrames; + for (var i = 0; i < frames.length; ++i) { + InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i])); + } +} + +var numPaused = 0; +var parsedScriptParams; + +function handleDebuggerPaused(messageObject) +{ + ++numPaused; + InspectorTest.log('Paused #' + numPaused); + logStackTrace(messageObject); + + function cont() { + var topFrameId = messageObject.params.callFrames[0].callFrameId; + Protocol.Debugger + .evaluateOnCallFrame({ + callFrameId: topFrameId, + expression: 'typeof finished' + }) + .then(callbackEvaluate); + function callbackEvaluate(message) { + var finished = message.result && message.result.result && + message.result.result.value === 'string'; + + InspectorTest.log('Resuming...'); + Protocol.Debugger.resume(); + + if (finished) + afterFinishedTestFunctionCallback(); + } + } + + if (numPaused > 1) { + cont(); + return; + } + + InspectorTest.log('First time paused, setting breakpoints!'); + + var startLine = parsedScriptParams.startLine; + var endLine = parsedScriptParams.endLine; + InspectorTest.log( + 'Flooding script with breakpoints for all lines (' + startLine + ' - ' + + endLine + ')...'); + var currentLine = startLine; + function setNextBreakpoint(message) { + if (message) InspectorTest.logMessage('error: ' + message.error); + if (currentLine == endLine) { + cont(); + return; + } + var thisLine = currentLine; + currentLine += 1; + InspectorTest.log('Setting breakpoint on line ' + thisLine); + Protocol.Debugger + .setBreakpoint({ + 'location': { + 'scriptId': parsedScriptParams.scriptId, + 'lineNumber': thisLine + } + }) + .then(setNextBreakpoint); + } + setNextBreakpoint(); +} + +var numScripts = 0; + +function handleScriptParsed(messageObject) +{ + var scriptId = messageObject.params.scriptId; + ++numScripts; + InspectorTest.log('Script nr ' + numScripts + ' parsed!'); + if (numScripts == 1) { + parsedScriptParams = JSON.parse(JSON.stringify(messageObject.params)); + afterScriptParsedCallback(); + } +} diff --git a/deps/v8/test/inspector/debugger/asm-js-stack-expected.txt b/deps/v8/test/inspector/debugger/asm-js-stack-expected.txt new file mode 100644 index 0000000000..f3bfd8de6a --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-stack-expected.txt @@ -0,0 +1,17 @@ +Paused on 'debugger;' +Number of frames: 5 + - [0] {"functionName":"call_debugger","function_lineNumber":13,"function_columnNumber":24,"lineNumber":14,"columnNumber":4} + - [1] {"functionName":"callDebugger","lineNumber":5,"columnNumber":6} + - [2] {"functionName":"redirectFun","lineNumber":8,"columnNumber":6} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":18,"columnNumber":2} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Getting v8-generated stack trace... +Result of evaluate (string): +Error: getting stack trace + -- skipped -- + at call_debugger (<anonymous>:15:5) + at callDebugger (<anonymous>:6:7) + at redirectFun (<anonymous>:9:7) + at testFunction (<anonymous>:19:3) + at <anonymous>:1:1 +Finished! diff --git a/deps/v8/test/inspector/debugger/asm-js-stack.js b/deps/v8/test/inspector/debugger/asm-js-stack.js new file mode 100644 index 0000000000..37db088ba1 --- /dev/null +++ b/deps/v8/test/inspector/debugger/asm-js-stack.js @@ -0,0 +1,79 @@ +// 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: --validate-asm + +function testFunction() { + function generateAsmJs(stdlib, foreign, heap) { + 'use asm'; + var debugger_fun = foreign.call_debugger; + function callDebugger() { + debugger_fun(); + } + function redirectFun() { + callDebugger(); + } + return redirectFun; + } + + function call_debugger() { + debugger; + } + + var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined); + fun(); +} + +InspectorTest.addScript(testFunction.toString()); + +Protocol.Debugger.enable(); +Protocol.Debugger.oncePaused().then(handleDebuggerPaused); +Protocol.Runtime.evaluate({'expression': 'testFunction()'}); + +function locationToString(callFrame) { + var res = {functionName: callFrame.functionName}; + for (var attr in callFrame.functionLocation) { + if (attr == 'scriptId') continue; + res['function_'+attr] = callFrame.functionLocation[attr]; + } + for (var attr in callFrame.location) { + if (attr == 'scriptId') continue; + res[attr] = callFrame.location[attr]; + } + return JSON.stringify(res); +} + +function logStackTrace(messageObject) { + var frames = messageObject.params.callFrames; + InspectorTest.log('Number of frames: ' + frames.length); + for (var i = 0; i < frames.length; ++i) { + InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i])); + } +} + +function handleDebuggerPaused(messageObject) +{ + InspectorTest.log('Paused on \'debugger;\''); + logStackTrace(messageObject); + InspectorTest.log('Getting v8-generated stack trace...'); + var topFrameId = messageObject.params.callFrames[0].callFrameId; + Protocol.Debugger + .evaluateOnCallFrame({ + callFrameId: topFrameId, + expression: '(new Error("getting stack trace")).stack' + }) + .then(callbackEvaluate); +} + +function callbackEvaluate(response) +{ + InspectorTest.log( + 'Result of evaluate (' + response.result.result.type + '):'); + var result_lines = response.result.result.value.split("\n"); + // Skip the second line, containing the 'evaluate' position. + result_lines[1] = " -- skipped --"; + InspectorTest.log(result_lines.join('\n')); + InspectorTest.log('Finished!'); + InspectorTest.completeTest(); +} diff --git a/deps/v8/test/inspector/debugger/break-on-exception-expected.txt b/deps/v8/test/inspector/debugger/break-on-exception-expected.txt new file mode 100644 index 0000000000..92a38f0e83 --- /dev/null +++ b/deps/v8/test/inspector/debugger/break-on-exception-expected.txt @@ -0,0 +1,12 @@ +Check that inspector correctly change break on exception state. + +Running test: noBreakOnExceptionAfterEnabled + +Running test: breakOnUncaughtException +paused in throwUncaughtException + +Running test: breakOnCaughtException +paused in throwUncaughtException +paused in throwCaughtException + +Running test: noBreakInEvaluateInSilentMode
\ No newline at end of file diff --git a/deps/v8/test/inspector/debugger/break-on-exception.js b/deps/v8/test/inspector/debugger/break-on-exception.js new file mode 100644 index 0000000000..e0afc3846f --- /dev/null +++ b/deps/v8/test/inspector/debugger/break-on-exception.js @@ -0,0 +1,71 @@ +// 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. + +print("Check that inspector correctly change break on exception state."); + +InspectorTest.addScript(` +function scheduleUncaughtException() +{ + setTimeout(throwUncaughtException, 0); +} +function throwUncaughtException() +{ + throw new Error(); +} +function throwCaughtException() +{ + throw new Error(); +}`); + +Protocol.Debugger.onPaused(message => { + InspectorTest.log("paused in " + message.params.callFrames[0].functionName); + Protocol.Debugger.resume(); +}); + +Protocol.Runtime.enable(); + +InspectorTest.runTestSuite([ + function noBreakOnExceptionAfterEnabled(next) + { + Protocol.Debugger.enable(); + Protocol.Debugger.setPauseOnExceptions({ state: "all" }); + Protocol.Debugger.disable(); + Protocol.Debugger.enable(); + Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" }) + .then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" })) + .then(() => Protocol.Debugger.disable()) + .then(next); + }, + + function breakOnUncaughtException(next) + { + Protocol.Debugger.enable(); + Protocol.Debugger.setPauseOnExceptions({ state: "uncaught" }); + Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" }) + .then(() => Protocol.Runtime.onceExceptionThrown()) + .then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" })) + .then(() => Protocol.Debugger.disable()) + .then(next); + }, + + function breakOnCaughtException(next) + { + Protocol.Debugger.enable(); + Protocol.Debugger.setPauseOnExceptions({ state: "all" }); + Protocol.Runtime.evaluate({ expression: "scheduleUncaughtException()" }) + .then(() => Protocol.Runtime.onceExceptionThrown()) + .then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()" })) + .then(() => Protocol.Debugger.disable()) + .then(next); + }, + + function noBreakInEvaluateInSilentMode(next) + { + Protocol.Debugger.enable(); + Protocol.Debugger.setPauseOnExceptions({ state: "all" }) + .then(() => Protocol.Runtime.evaluate({ expression: "throwCaughtException()", silent: true })) + .then(() => Protocol.Debugger.disable()) + .then(next); + } +]); diff --git a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt new file mode 100644 index 0000000000..b784fa549e --- /dev/null +++ b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions-expected.txt @@ -0,0 +1,5 @@ +Check that inspector correctly passes caught/uncaught information. +paused in throwCaught +uncaught: false +paused in throwUncaught +uncaught: true diff --git a/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js new file mode 100644 index 0000000000..95d9b3ff65 --- /dev/null +++ b/deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js @@ -0,0 +1,25 @@ +// 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. + +print("Check that inspector correctly passes caught/uncaught information."); + +InspectorTest.addScript( +`function throwCaught() { try { throw new Error(); } catch (_) {} } + function throwUncaught() { throw new Error(); } + function schedule(f) { setTimeout(f, 0); } +`); + +Protocol.Debugger.enable(); + +Protocol.Debugger.setPauseOnExceptions({ "state": "all" }); +Protocol.Debugger.onPaused(message => { + InspectorTest.log("paused in " + message.params.callFrames[0].functionName); + InspectorTest.log("uncaught: " + message.params.data.uncaught); + Protocol.Debugger.resume(); +}); + +Protocol.Runtime.evaluate({ "expression": "schedule(throwCaught);" }) + .then(() => Protocol.Runtime.evaluate( + { "expression": "schedule(throwUncaught);" })) + .then(() => InspectorTest.completeTest()); diff --git a/deps/v8/test/inspector/debugger/command-line-api-with-bound-function-expected.txt b/deps/v8/test/inspector/debugger/command-line-api-with-bound-function-expected.txt index 4148ef860a..821ce46cd3 100644 --- a/deps/v8/test/inspector/debugger/command-line-api-with-bound-function-expected.txt +++ b/deps/v8/test/inspector/debugger/command-line-api-with-bound-function-expected.txt @@ -1,23 +1,23 @@ Check that debug and monitor methods from Command Line API works with bound function. -debug foo and bar -call foo and bar +> debug foo and bar +> call foo and bar paused in foo paused in boo -undebug foo and bar -call foo and bar -monitor foo and bar -call foo and bar +> undebug foo and bar +> call foo and bar +> monitor foo and bar +> call foo and bar function foo called function boo called -unmonitor foo and bar -call foo and bar -monitor and debug bar -call bar +> unmonitor foo and bar +> call foo and bar +> monitor and debug bar +> call bar function boo called paused in boo -undebug bar -call bar +> undebug bar +> call bar function boo called -debug and unmonitor bar -call bar +> debug and unmonitor bar +> call bar paused in boo
\ No newline at end of file diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt new file mode 100644 index 0000000000..c85832872c --- /dev/null +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal-expected.txt @@ -0,0 +1,27 @@ +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 0 + lineNumber : 0 + scriptId : <scriptId> + } + [1] : { + columnNumber : 6 + lineNumber : 0 + scriptId : <scriptId> + } + [2] : { + columnNumber : 7 + lineNumber : 0 + scriptId : <scriptId> + } + [3] : { + columnNumber : 8 + lineNumber : 0 + scriptId : <scriptId> + } + ] + } +} 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 new file mode 100644 index 0000000000..e574f69c01 --- /dev/null +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-array-literal.js @@ -0,0 +1,12 @@ +// 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. + +Protocol.Debugger.enable(); + +Protocol.Debugger.onceScriptParsed().then(message => message.params.scriptId) + .then((scriptId) => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) + .then(InspectorTest.logMessage) + .then(InspectorTest.completeTest); + +compileAndRunWithOrigin("() => []", "", 0, 0); diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt new file mode 100644 index 0000000000..608abce218 --- /dev/null +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints-expected.txt @@ -0,0 +1,1109 @@ +Test for Debugger.getPossibleBreakpoints + +Running test: getPossibleBreakpointsInRange +Test start.scriptId != end.scriptId. +{ + error : { + code : -32000 + message : Locations should contain the same scriptId + } + id : <messageId> +} +Test not existing scriptId. +{ + error : { + code : -32000 + message : Script not found + } + id : <messageId> +} +Test end < start. +{ + id : <messageId> + result : { + locations : [ + ] + } +} +Test empty range in first line. +{ + id : <messageId> + result : { + locations : [ + ] + } +} +Test one character range in first line. +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 16 + lineNumber : 0 + scriptId : <scriptId> + } + ] + } +} +Test empty range in not first line. +{ + id : <messageId> + result : { + locations : [ + ] + } +} +Test one character range in not first line. +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 16 + lineNumber : 1 + scriptId : <scriptId> + } + ] + } +} +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> + } + ] + } +} +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> + } + ] + } +} +Test one string +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 16 + lineNumber : 0 + scriptId : <scriptId> + } + [1] : { + columnNumber : 42 + lineNumber : 0 + scriptId : <scriptId> + } + ] + } +} +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> + } + ] + } +} + +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> + } + ] + } +} + +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> + } +} +paused in foo1 +{ + columnNumber : 18 + lineNumber : 0 + scriptId : <scriptId> +} +paused in foo1 +{ + columnNumber : 51 + lineNumber : 0 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 47 + lineNumber : 0 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 49 + lineNumber : 0 + scriptId : <scriptId> +} + +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> + } +} +paused in +{ + columnNumber : 0 + lineNumber : 2 + scriptId : <scriptId> +} +paused in foo3 +{ + columnNumber : 28 + lineNumber : 0 + scriptId : <scriptId> +} +paused in foo3 +{ + columnNumber : 61 + lineNumber : 0 + scriptId : <scriptId> +} +paused in +{ + columnNumber : 0 + lineNumber : 3 + scriptId : <scriptId> +} +paused in foo4 +{ + columnNumber : 18 + lineNumber : 1 + scriptId : <scriptId> +} +paused in foo4 +{ + columnNumber : 51 + lineNumber : 1 + scriptId : <scriptId> +} +paused in +{ + columnNumber : 6 + lineNumber : 3 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 57 + lineNumber : 0 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 59 + lineNumber : 0 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 47 + lineNumber : 1 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 49 + lineNumber : 1 + scriptId : <scriptId> +} + +Running test: getPossibleBreakpointsInRangeWithOffset +Test empty range in first line. +{ + id : <messageId> + result : { + locations : [ + ] + } +} +Test one character range in first line. +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 17 + lineNumber : 1 + scriptId : <scriptId> + } + ] + } +} +Test empty range in not first line. +{ + id : <messageId> + result : { + locations : [ + ] + } +} +Test one character range in not first line. +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 16 + lineNumber : 2 + scriptId : <scriptId> + } + ] + } +} +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> + } + ] + } +} +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> + } + ] + } +} +Test one string +{ + id : <messageId> + result : { + locations : [ + [0] : { + columnNumber : 17 + lineNumber : 1 + scriptId : <scriptId> + } + [1] : { + columnNumber : 43 + lineNumber : 1 + scriptId : <scriptId> + } + ] + } +} +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> + } + ] + } +} + +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> + } +} +paused in foo5 +{ + columnNumber : 36 + lineNumber : 3 + scriptId : <scriptId> +} +paused in foo5 +{ + columnNumber : 69 + lineNumber : 3 + scriptId : <scriptId> +} +paused in foo6 +{ + columnNumber : 18 + lineNumber : 4 + scriptId : <scriptId> +} +paused in foo6 +{ + columnNumber : 51 + lineNumber : 4 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 65 + lineNumber : 3 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 67 + lineNumber : 3 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 47 + lineNumber : 4 + scriptId : <scriptId> +} +paused in Promise.resolve.then +{ + columnNumber : 49 + lineNumber : 4 + scriptId : <scriptId> +} + +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> + } + ] + } +} diff --git a/deps/v8/test/inspector/debugger/get-possible-breakpoints.js b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js new file mode 100644 index 0000000000..b09c08de14 --- /dev/null +++ b/deps/v8/test/inspector/debugger/get-possible-breakpoints.js @@ -0,0 +1,203 @@ +// 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. + +print("Test for Debugger.getPossibleBreakpoints"); + +Protocol.Runtime.enable(); +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 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(() => 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(() => 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(() => 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(() => 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(() => 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(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) + .then(InspectorTest.logMessage) + .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(() => 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(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 256, scriptId: scriptId }})) + .then(InspectorTest.logMessage) + .then(next); + }, + + function getPossibleBreakpointsInArrow(next) { + 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(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(); + }); + + 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(setAllBreakpoints) + .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(setAllBreakpoints) + .then(() => Protocol.Debugger.onPaused(dumpAndResume)) + .then(() => Protocol.Debugger.resume()); + }, + + function getPossibleBreakpointsInRangeWithOffset(next) { + 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 }) + .then(id => scriptId = id) + .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(() => 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(() => 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(() => 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(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }})) + .then(InspectorTest.logMessage) + .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(() => 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(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 256, scriptId: scriptId }})) + .then(InspectorTest.logMessage) + .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(); + }); + + 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) + .then(setAllBreakpoints) + .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) + // 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) + } +]); + +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); + return promise; +} + +function waitForPossibleBreakpoints(source, start, end, origin) { + return compileScript(source, origin) + .then(scriptId => { (start || {}).scriptId = scriptId; (end || {}).scriptId = scriptId }) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: end })); +} + +function waitForPossibleBreakpointsOnPause(source, start, end, next) { + var promise = Protocol.Debugger.oncePaused() + .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.scriptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId }) + .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: end })); + Protocol.Runtime.evaluate({ expression: source }).then(next); + return promise; +} + +function setAllBreakpoints(message) { + var promises = []; + for (var location of message.result.locations) + promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(checkBreakpointAndDump)); + return Promise.all(promises); +} + +function checkBreakpointAndDump(message) { + if (message.error) { + InspectorTest.log("FAIL: error in setBreakpoint"); + InspectorTest.logMessage(message); + return; + } + 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.logMessage(message); + } + InspectorTest.logMessage(message); +} 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 new file mode 100644 index 0000000000..2c7995c335 --- /dev/null +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt @@ -0,0 +1,253 @@ +Check internal properties reported in object preview. + +Running test: boxedObjects +expression: new Number(239) +{ + name : [[PrimitiveValue]] + type : number + value : 239 +} + +expression: new Boolean(false) +{ + name : [[PrimitiveValue]] + type : boolean + value : false +} + +expression: new String("abc") +{ + name : [[PrimitiveValue]] + type : string + value : abc +} + +expression: Object(Symbol(42)) +{ + name : [[PrimitiveValue]] + type : symbol + valuePreview : { + description : Symbol + overflow : false + properties : [ + ] + type : object + } +} + + +Running test: promise +expression: Promise.resolve(42) +{ + name : [[PromiseStatus]] + type : string + value : resolved +} +{ + name : [[PromiseValue]] + type : number + value : 42 +} + +expression: new Promise(() => undefined) +{ + name : [[PromiseStatus]] + type : string + value : pending +} +{ + name : [[PromiseValue]] + type : undefined + value : undefined +} + + +Running test: generatorObject +expression: (function* foo() { yield 1 })() +{ + name : [[GeneratorStatus]] + type : string + value : suspended +} + + +Running test: entriesInMapAndSet +expression: new Map([[1,2]]) +[[Entries]]: +[ + [0] : { + key : { + description : 1 + overflow : false + properties : [ + ] + type : number + } + value : { + description : 2 + overflow : false + properties : [ + ] + type : number + } + } +] + +expression: new Set([1]) +[[Entries]]: +[ + [0] : { + value : { + description : 1 + overflow : false + properties : [ + ] + type : number + } + } +] + +expression: new WeakMap([[{}, 42]]) +[[Entries]]: +[ + [0] : { + key : { + description : Object + overflow : false + properties : [ + ] + type : object + } + value : { + description : 42 + overflow : false + properties : [ + ] + type : number + } + } +] + +expression: new WeakSet([{}]) +[[Entries]]: +[ + [0] : { + value : { + description : Object + overflow : false + properties : [ + ] + type : object + } + } +] + + +Running test: iteratorObject +expression: (new Map([[1,2]])).entries() +{ + name : [[IteratorHasMore]] + type : boolean + value : true +} +{ + name : [[IteratorIndex]] + type : number + value : 0 +} +{ + name : [[IteratorKind]] + type : string + value : entries +} +[[Entries]]: +[ + [0] : { + value : { + description : Array[2] + overflow : false + properties : [ + [0] : { + name : 0 + type : number + value : 1 + } + [1] : { + name : 1 + type : number + value : 2 + } + ] + subtype : array + type : object + } + } +] + +expression: (new Set([[1,2]])).entries() +{ + name : [[IteratorHasMore]] + type : boolean + value : true +} +{ + name : [[IteratorIndex]] + type : number + value : 0 +} +{ + name : [[IteratorKind]] + type : string + value : entries +} +[[Entries]]: +[ + [0] : { + value : { + description : Array[2] + overflow : false + properties : [ + [0] : { + name : 0 + subtype : array + type : object + value : Array[2] + } + [1] : { + name : 1 + subtype : array + type : object + value : Array[2] + } + ] + subtype : array + type : object + } + } +] + + +Running test: noPreviewForFunctionObject +(function foo(){}) +{ + id : <messageId> + result : { + result : { + className : Function + description : function foo(){} + objectId : <objectId> + type : function + } + } +} + +Running test: otherObjects +expression: [1,2,3] + +expression: /123/ + +expression: ({}) + + +Running test: overridenArrayGetter +expression: Promise.resolve(42) diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties.js b/deps/v8/test/inspector/debugger/object-preview-internal-properties.js new file mode 100644 index 0000000000..00b1d5bf45 --- /dev/null +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties.js @@ -0,0 +1,107 @@ +// 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. + +print("Check internal properties reported in object preview."); + +Protocol.Debugger.enable(); +Protocol.Runtime.enable(); +Protocol.Runtime.onConsoleAPICalled(dumpInternalPropertiesAndEntries); + +InspectorTest.runTestSuite([ + 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("(function* foo() { yield 1 })()") + .then(next); + }, + + function entriesInMapAndSet(next) + { + checkExpression("new Map([[1,2]])") + .then(() => checkExpression("new Set([1])")) + .then(() => checkExpression("new WeakMap([[{}, 42]])")) + .then(() => checkExpression("new WeakSet([{}])")) + .then(next); + }, + + function iteratorObject(next) + { + checkExpression("(new Map([[1,2]])).entries()") + .then(() => checkExpression("(new Set([[1,2]])).entries()")) + .then(next); + }, + + function noPreviewForFunctionObject(next) + { + var expression = "(function foo(){})"; + InspectorTest.log(expression); + Protocol.Runtime.evaluate({ expression: expression, generatePreview: true}) + .then(message => InspectorTest.logMessage(message)) + .then(next); + }, + + function otherObjects(next) + { + checkExpression("[1,2,3]") + .then(() => checkExpression("/123/")) + .then(() => checkExpression("({})")) + .then(next); + }, + + function overridenArrayGetter(next) + { + Protocol.Runtime.evaluate({ expression: "Array.prototype.__defineGetter__(\"0\",() => { throw new Error() }) "}) + .then(() => checkExpression("Promise.resolve(42)")) + .then(next); + } +]); + +function checkExpression(expression) +{ + InspectorTest.log(`expression: ${expression}`); + // console.table has higher limits for internal properties amount in preview. + return Protocol.Runtime.evaluate({ expression: `console.table(${expression})`, generatePreview: true }); +} + +function dumpInternalPropertiesAndEntries(message) +{ + var properties; + var entries; + try { + var preview = message.params.args[0].preview; + properties = preview.properties; + entries = preview.entries; + } catch (e) { + InspectorTest.logMessage(message); + return; + } + if (!properties) { + InspectorTest.logMessage(message); + return; + } + for (var property of properties) { + if (property.name.startsWith("[[")) + InspectorTest.logMessage(property); + } + if (entries) { + InspectorTest.log("[[Entries]]:"); + InspectorTest.logMessage(entries); + } + InspectorTest.log(""); +} 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 new file mode 100644 index 0000000000..d7c6d76346 --- /dev/null +++ b/deps/v8/test/inspector/debugger/script-on-after-compile-expected.txt @@ -0,0 +1,664 @@ +Checks that inspector correctly process compiled scripts +scriptParsed +{ + scriptSource : function foo1(){}//# sourceURL=oneline.js<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : oneline.js +} +scriptParsed +{ + scriptSource : function foo2(){}//# sourceURL=oneline-without-nl.js +} +{ + endColumn : 52 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : oneline-without-nl.js +} +scriptParsed +{ + scriptSource : function foo3(){}<nl>//# sourceURL=twoline.js<nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : twoline.js +} +scriptParsed +{ + scriptSource : function foo4(){}<nl><nl>//# sourceURL=threeline.js<nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : threeline.js +} +scriptParsed +{ + scriptSource : function foo5(){}//# sourceMappingURL=oneline-map<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : oneline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo6(){}//# sourceMappingURL=oneline-without-nl-map +} +{ + endColumn : 60 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : oneline-without-nl-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo7(){}<nl>//# sourceMappingURL=twoline-map<nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : twoline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo8(){}<nl><nl>//# sourceMappingURL=threeline-map<nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : threeline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo9(){}//# sourceMappingURL=source-mapping-url-map<nl>//# sourceURL=source-url.js +} +{ + endColumn : 27 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : source-mapping-url-map + startColumn : 0 + startLine : 0 + url : source-url.js +} +scriptParsed +{ + scriptSource : function foo10(){}//# sourceURL=source-url.js<nl>//# sourceMappingURL=source-mapping-url-map +} +{ + endColumn : 43 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : source-mapping-url-map + startColumn : 0 + startLine : 0 + url : source-url.js +} +scriptParsed +{ + scriptSource : function foo11(){}<nl>//# sourceURL=end1.js +} +{ + endColumn : 21 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : end1.js +} +scriptParsed +{ + scriptSource : function foo12(){}<nl>//# sourceURL=end2.js +} +{ + endColumn : 22 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : end2.js +} +scriptParsed +{ + scriptSource : function foo13(){} +} +{ + endColumn : 18 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo15(){}; eval("function foo14(){}//# sourceURL=eval.js")//# sourceURL=eval-wrapper.js +} +{ + endColumn : 96 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : eval-wrapper.js +} +scriptParsed +{ + scriptSource : function foo14(){}//# sourceURL=eval.js +} +{ + endColumn : 39 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : eval.js +} +scriptParsed +{ + scriptSource : function foo16(){}<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo17(){}<nl><nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo18(){}<nl><nl><nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo19(){}<nl><nl><nl><nl> +} +{ + endColumn : 0 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo1(){}//# sourceURL=oneline.js<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : oneline.js +} +scriptParsed +{ + scriptSource : function foo2(){}//# sourceURL=oneline-without-nl.js +} +{ + endColumn : 52 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : oneline-without-nl.js +} +scriptParsed +{ + scriptSource : function foo3(){}<nl>//# sourceURL=twoline.js<nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : twoline.js +} +scriptParsed +{ + scriptSource : function foo4(){}<nl><nl>//# sourceURL=threeline.js<nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : threeline.js +} +scriptParsed +{ + scriptSource : function foo5(){}//# sourceMappingURL=oneline-map<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : oneline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo6(){}//# sourceMappingURL=oneline-without-nl-map +} +{ + endColumn : 60 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : oneline-without-nl-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo7(){}<nl>//# sourceMappingURL=twoline-map<nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : twoline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo8(){}<nl><nl>//# sourceMappingURL=threeline-map<nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : threeline-map + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo9(){}//# sourceMappingURL=source-mapping-url-map<nl>//# sourceURL=source-url.js +} +{ + endColumn : 27 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : source-mapping-url-map + startColumn : 0 + startLine : 0 + url : source-url.js +} +scriptParsed +{ + scriptSource : function foo10(){}//# sourceURL=source-url.js<nl>//# sourceMappingURL=source-mapping-url-map +} +{ + endColumn : 43 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : source-mapping-url-map + startColumn : 0 + startLine : 0 + url : source-url.js +} +scriptParsed +{ + scriptSource : function foo11(){}<nl>//# sourceURL=end1.js +} +{ + endColumn : 21 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : end1.js +} +scriptParsed +{ + scriptSource : function foo12(){}<nl>//# sourceURL=end2.js +} +{ + endColumn : 22 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : end2.js +} +scriptParsed +{ + scriptSource : function foo13(){} +} +{ + endColumn : 18 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo15(){}; eval("function foo14(){}//# sourceURL=eval.js")//# sourceURL=eval-wrapper.js +} +{ + endColumn : 96 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : eval-wrapper.js +} +scriptParsed +{ + scriptSource : function foo14(){}//# sourceURL=eval.js +} +{ + endColumn : 39 + endLine : 0 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : eval.js +} +scriptFailedToParse +{ + scriptSource : }//# sourceURL=failed.js<nl>//# sourceMappingURL=failed-map +} +{ + endColumn : 31 + endLine : 1 + executionContextId : <executionContextId> + hasSourceURL : true + hash : <hash> + scriptId : <scriptId> + sourceMapURL : failed-map + startColumn : 0 + startLine : 0 + url : failed.js +} +scriptParsed +{ + scriptSource : function foo16(){}<nl> +} +{ + endColumn : 0 + endLine : 2 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo17(){}<nl><nl> +} +{ + endColumn : 0 + endLine : 3 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo18(){}<nl><nl><nl> +} +{ + endColumn : 0 + endLine : 4 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +scriptParsed +{ + scriptSource : function foo19(){}<nl><nl><nl><nl> +} +{ + endColumn : 0 + endLine : 5 + executionContextId : <executionContextId> + hasSourceURL : false + hash : <hash> + isLiveEdit : false + scriptId : <scriptId> + sourceMapURL : + startColumn : 0 + startLine : 0 + url : +} +Remove script references and re-enable debugger. diff --git a/deps/v8/test/inspector/debugger/script-on-after-compile.js b/deps/v8/test/inspector/debugger/script-on-after-compile.js new file mode 100644 index 0000000000..083aa48065 --- /dev/null +++ b/deps/v8/test/inspector/debugger/script-on-after-compile.js @@ -0,0 +1,93 @@ +// 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. + +print("Checks that inspector correctly process compiled scripts"); + +function addScripts() { + // sourceURL in the same line + return addScript("function foo1(){}//# sourceURL=oneline.js\n") + // sourceURL without end line + .then(() => addScript("function foo2(){}//# sourceURL=oneline-without-nl.js")) + // other source urls + .then(() => addScript("function foo3(){}\n//# sourceURL=twoline.js\n")) + .then(() => addScript("function foo4(){}\n\n//# sourceURL=threeline.js\n")) + + // sourceMappingURL in the same line + .then(() => addScript("function foo5(){}//# sourceMappingURL=oneline-map\n")) + // sourceMappingURL without end line + .then(() => addScript("function foo6(){}//# sourceMappingURL=oneline-without-nl-map")) + // other sourceMappingURLs + .then(() => addScript("function foo7(){}\n//# sourceMappingURL=twoline-map\n")) + .then(() => addScript("function foo8(){}\n\n//# sourceMappingURL=threeline-map\n")) + + // sourceURL + sourceMappingURL + .then(() => addScript("function foo9(){}//# sourceMappingURL=source-mapping-url-map\n//# sourceURL=source-url.js")) + .then(() => addScript("function foo10(){}//# sourceURL=source-url.js\n//# sourceMappingURL=source-mapping-url-map")) + + // non zero endLine and endColumn.. + .then(() => addScript("function foo11(){}\n//# sourceURL=end1.js")) + // .. + 1 character + .then(() => addScript("function foo12(){}\n//# sourceURL=end2.js ")) + // script without sourceURL + .then(() => addScript("function foo13(){}")) + // script in eval + .then(() => addScript("function foo15(){}; eval(\"function foo14(){}//# sourceURL=eval.js\")//# sourceURL=eval-wrapper.js")) + // sourceURL and sourceMappingURL works even for script with syntax error + .then(() => addScript("}//# sourceURL=failed.js\n//# sourceMappingURL=failed-map")) + // empty lines at end + .then(() => addScript("function foo16(){}\n")) + .then(() => addScript("function foo17(){}\n\n")) + .then(() => addScript("function foo18(){}\n\n\n")) + .then(() => addScript("function foo19(){}\n\n\n\n")); +} + +Protocol.Debugger.onScriptParsed((message) => requestSourceAndDump(message, true)); +Protocol.Debugger.onScriptFailedToParse((message) => requestSourceAndDump(message, false)); +addScripts() + .then(() => Protocol.Debugger.enable()) + .then(addScripts) + .then(() => Protocol.Debugger.disable()) + .then(() => InspectorTest.log("Remove script references and re-enable debugger.")) + .then(() => Protocol.Runtime.evaluate( + { expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`);" })) + .then(() => Protocol.HeapProfiler.collectGarbage()) + .then(() => Protocol.Debugger.enable()) + .then(InspectorTest.completeTest); + +function addScript(source) { + return Protocol.Runtime.evaluate({ expression: source }); +} + +function requestSourceAndDump(scriptParsedMessage, scriptParsed) { + Protocol.Debugger.getScriptSource({ scriptId: scriptParsedMessage.params.scriptId }) + .then((sourceMessage) => dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed)); +} + +function dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed) { + var params = scriptParsedMessage.params; + var re = /[A-Z0-9]{40,40}/; + if (!params.hash || !matchExact(re, params.hash)) + params.hash = "Invalid hash: " + params.hash; + else + params.hash = "<hash>"; + if (params.executionContextId <= 0) + params.executionContextId = "Invalid executionContextId: " + params.executionContextId; + else + params.executionContextId = "<executionContextId>"; + if (params.scriptId * 1 <= 0) + params.scriptId = "Invalid scriptId: " + params.scriptId; + else + params.scriptId = "<scriptId>"; + + var sourceResult = sourceMessage.result; + sourceResult.scriptSource = sourceResult.scriptSource.replace(/\n/g, "<nl>"); + InspectorTest.log(scriptParsed ? "scriptParsed" : "scriptFailedToParse"); + InspectorTest.logObject(sourceResult); + InspectorTest.logObject(params); +} + +function matchExact(re, str) { + var match = str.match(re); + return match !== null && str === match[0]; +} diff --git a/deps/v8/test/inspector/debugger/set-breakpoint-before-enabling-expected.txt b/deps/v8/test/inspector/debugger/set-breakpoint-before-enabling-expected.txt index 81685a2b8b..e4fdd95d5f 100644 --- a/deps/v8/test/inspector/debugger/set-breakpoint-before-enabling-expected.txt +++ b/deps/v8/test/inspector/debugger/set-breakpoint-before-enabling-expected.txt @@ -1,7 +1,6 @@ setBreakpointByUrl error: undefined setBreakpoint error: { "code": -32602, - "message": "Invalid request", + "message": "Invalid parameters", "data": "location: object expected" } - diff --git a/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints-expected.txt b/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints-expected.txt new file mode 100644 index 0000000000..da35fc77b4 --- /dev/null +++ b/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints-expected.txt @@ -0,0 +1,11 @@ +-- call boo: +(top) +(top) +boo +(top) +-- call foo: +(top) +(top) +(top) +foo +(top) diff --git a/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints.js b/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints.js new file mode 100644 index 0000000000..7d6577b82a --- /dev/null +++ b/deps/v8/test/inspector/debugger/stepping-after-get-possible-breakpoints.js @@ -0,0 +1,26 @@ +// 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. + +InspectorTest.addScript(` +function boo() {} +boo(); +function foo() {} +//# sourceURL=foo.js`); + +Protocol.Debugger.onPaused((message) => { + InspectorTest.logMessage(message.params.callFrames[0].functionName || "(top)"); + Protocol.Debugger.stepInto(); +}); +var scriptId; +Protocol.Debugger.onScriptParsed(message => { + if (message.params.url === 'foo.js') + scriptId = message.params.scriptId; +}); +Protocol.Debugger.enable() + .then(() => Protocol.Debugger.getPossibleBreakpoints({start: {scriptId, lineNumber:0,columnNumber:0}})) + .then(() => InspectorTest.log('-- call boo:')) + .then(() => Protocol.Runtime.evaluate({ expression: 'debugger; boo();'})) + .then(() => InspectorTest.log('-- call foo:')) + .then(() => Protocol.Runtime.evaluate({ expression: 'debugger; foo();'})) + .then(InspectorTest.completeTest); 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 740634f68f..0a97e5dc35 100644 --- a/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js +++ b/deps/v8/test/inspector/debugger/stepping-with-blackboxed-ranges.js @@ -103,8 +103,10 @@ var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print", function runAction(response) { var action = actions.shift(); - if (!action) + if (!action) { InspectorTest.completeTest(); + return; + } if (action === "print") { printCallFrames(response.params.callFrames); diff --git a/deps/v8/test/inspector/debugger/wasm-stack-expected.txt b/deps/v8/test/inspector/debugger/wasm-stack-expected.txt new file mode 100644 index 0000000000..cbe4406932 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stack-expected.txt @@ -0,0 +1,18 @@ +Running testFunction with generated WASM bytes... +Paused on 'debugger;' +Number of frames: 5 + - [0] {"functionName":"call_debugger","function_lineNumber":1,"function_columnNumber":24,"lineNumber":2,"columnNumber":4} + - [1] {"functionName":"call_func","lineNumber":1,"columnNumber":1} + - [2] {"functionName":"main","lineNumber":2,"columnNumber":1} + - [3] {"functionName":"testFunction","function_lineNumber":0,"function_columnNumber":21,"lineNumber":14,"columnNumber":19} + - [4] {"functionName":"","function_lineNumber":0,"function_columnNumber":0,"lineNumber":0,"columnNumber":0} +Getting v8-generated stack trace... +Result of evaluate (string): +Error: this is your stack trace: + -- skipped -- + at call_debugger (<anonymous>:3:5) + at call_func (<WASM>[1]+1) + at main (<WASM>[2]+1) + at testFunction (<anonymous>:15:20) + at <anonymous>:1:1 +Finished! diff --git a/deps/v8/test/inspector/debugger/wasm-stack.js b/deps/v8/test/inspector/debugger/wasm-stack.js new file mode 100644 index 0000000000..a30d37f320 --- /dev/null +++ b/deps/v8/test/inspector/debugger/wasm-stack.js @@ -0,0 +1,94 @@ +// 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(); + +var imported_idx = builder.addImport("func", kSig_v_v); + +var call_imported_idx = builder.addFunction("call_func", kSig_v_v) + .addBody([kExprCallFunction, imported_idx]) + .index; + +builder.addFunction("main", kSig_v_v) + .addBody([kExprCallFunction, call_imported_idx]) + .exportAs("main"); + +var module_bytes = builder.toArray(); + +function testFunction(bytes) { + function call_debugger() { + debugger; + } + + 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); + var instance = new WebAssembly.Instance(module, {func: call_debugger}); + + instance.exports.main(); +} + +InspectorTest.addScript(testFunction.toString()); + +Protocol.Debugger.enable(); +Protocol.Debugger.onPaused(handleDebuggerPaused); +InspectorTest.log('Running testFunction with generated WASM bytes...'); +Protocol.Runtime.evaluate( + {'expression': 'testFunction(' + JSON.stringify(module_bytes) + ')'}); + +function locationToString(callFrame) { + var res = {functionName: callFrame.functionName}; + for (var attr in callFrame.functionLocation) { + if (attr == 'scriptId') continue; + res['function_'+attr] = callFrame.functionLocation[attr]; + } + for (var attr in callFrame.location) { + if (attr == 'scriptId') continue; + res[attr] = callFrame.location[attr]; + } + return JSON.stringify(res); +} + +function logStackTrace(messageObject) { + var frames = messageObject.params.callFrames; + InspectorTest.log('Number of frames: ' + frames.length); + for (var i = 0; i < frames.length; ++i) { + InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i])); + } +} + +function handleDebuggerPaused(messageObject) +{ + InspectorTest.log('Paused on \'debugger;\''); + logStackTrace(messageObject); + InspectorTest.log('Getting v8-generated stack trace...'); + var topFrameId = messageObject.params.callFrames[0].callFrameId; + Protocol.Debugger + .evaluateOnCallFrame({ + callFrameId: topFrameId, + expression: '(new Error("this is your stack trace:")).stack' + }) + .then(callbackEvaluate); +} + +function callbackEvaluate(response) +{ + InspectorTest.log( + 'Result of evaluate (' + response.result.result.type + '):'); + var result_lines = response.result.result.value.split('\n'); + // Skip the second line, containing the 'evaluate' position. + result_lines[1] = ' -- skipped --'; + InspectorTest.log(result_lines.join('\n')); + InspectorTest.log('Finished!'); + InspectorTest.completeTest(); +} diff --git a/deps/v8/test/inspector/inspector-impl.cc b/deps/v8/test/inspector/inspector-impl.cc index 57499215b9..87b3c7b4a1 100644 --- a/deps/v8/test/inspector/inspector-impl.cc +++ b/deps/v8/test/inspector/inspector-impl.cc @@ -5,7 +5,8 @@ #include "test/inspector/inspector-impl.h" #include "include/v8.h" -#include "src/inspector/string-16.h" + +#include "src/vector.h" namespace { @@ -40,10 +41,11 @@ InspectorClientImpl* InspectorClientFromContext( return inspector_client; } -v8_inspector::String16 ToString16(v8::Local<v8::String> str) { - std::unique_ptr<uint16_t[]> buffer(new uint16_t[str->Length()]); - str->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, str->Length()); - return v8_inspector::String16(buffer.get(), str->Length()); +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; } void MessageHandler(v8::Local<v8::Message> message, @@ -55,7 +57,8 @@ void MessageHandler(v8::Local<v8::Message> message, InspectorClientImpl::InspectorFromContext(context); v8::Local<v8::StackTrace> stack = message->GetStackTrace(); - int script_id = message->GetScriptOrigin().ScriptID()->Value(); + int script_id = + static_cast<int>(message->GetScriptOrigin().ScriptID()->Value()); if (!stack.IsEmpty() && stack->GetFrameCount() > 0) { int top_script_id = stack->GetFrame(0)->GetScriptId(); if (top_script_id == script_id) script_id = 0; @@ -66,15 +69,15 @@ void MessageHandler(v8::Local<v8::Message> message, column_number = message->GetStartColumn(context).FromJust() + 1; v8_inspector::StringView detailed_message; - v8_inspector::String16 message_text_string = ToString16(message->Get()); - v8_inspector::StringView message_text(message_text_string.characters16(), + v8::internal::Vector<uint16_t> message_text_string = ToVector(message->Get()); + v8_inspector::StringView message_text(message_text_string.start(), message_text_string.length()); - v8_inspector::String16 url_string; + v8::internal::Vector<uint16_t> url_string; if (message->GetScriptOrigin().ResourceName()->IsString()) { url_string = - ToString16(message->GetScriptOrigin().ResourceName().As<v8::String>()); + ToVector(message->GetScriptOrigin().ResourceName().As<v8::String>()); } - v8_inspector::StringView url(url_string.characters16(), url_string.length()); + v8_inspector::StringView url(url_string.start(), url_string.length()); inspector->exceptionThrown(context, message_text, exception, detailed_message, url, line_number, column_number, @@ -158,7 +161,8 @@ v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext( class SendMessageToBackendTask : public TaskRunner::Task { public: - explicit SendMessageToBackendTask(const v8_inspector::String16& message) + explicit SendMessageToBackendTask( + const v8::internal::Vector<uint16_t>& message) : message_(message) {} bool is_inspector_task() final { return true; } @@ -172,14 +176,12 @@ class SendMessageToBackendTask : public TaskRunner::Task { session = InspectorClientImpl::SessionFromContext(context); CHECK(session); } - v8_inspector::StringView message_view( - reinterpret_cast<const uint16_t*>(message_.characters16()), - message_.length()); + v8_inspector::StringView message_view(message_.start(), message_.length()); session->dispatchProtocolMessage(message_view); } private: - v8_inspector::String16 message_; + v8::internal::Vector<uint16_t> message_; }; TaskRunner* SendMessageToBackendExtension::backend_task_runner_ = nullptr; @@ -196,6 +198,5 @@ void SendMessageToBackendExtension::SendMessageToBackend( CHECK(backend_task_runner_); CHECK(args.Length() == 1 && args[0]->IsString()); v8::Local<v8::String> message = args[0].As<v8::String>(); - backend_task_runner_->Append( - new SendMessageToBackendTask(ToString16(message))); + backend_task_runner_->Append(new SendMessageToBackendTask(ToVector(message))); } diff --git a/deps/v8/test/inspector/inspector-test.cc b/deps/v8/test/inspector/inspector-test.cc index 872d211c75..401aca0776 100644 --- a/deps/v8/test/inspector/inspector-test.cc +++ b/deps/v8/test/inspector/inspector-test.cc @@ -21,10 +21,28 @@ namespace { +std::vector<TaskRunner*> task_runners; + +void Terminate() { + for (size_t i = 0; i < task_runners.size(); ++i) { + task_runners[i]->Terminate(); + task_runners[i]->Join(); + } + std::vector<TaskRunner*> empty; + task_runners.swap(empty); +} + void Exit() { fflush(stdout); fflush(stderr); - _exit(0); + Terminate(); +} + +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; } class UtilsExtension : public v8::Extension { @@ -33,7 +51,9 @@ class UtilsExtension : public v8::Extension { : v8::Extension("v8_inspector/utils", "native function print();" "native function quit();" - "native function setlocale();") {} + "native function setlocale();" + "native function load();" + "native function compileAndRunWithOrigin();") {} virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( v8::Isolate* isolate, v8::Local<v8::String> name) { v8::Local<v8::Context> context = isolate->GetCurrentContext(); @@ -54,11 +74,30 @@ class UtilsExtension : public v8::Extension { .ToLocalChecked()) .FromJust()) { return v8::FunctionTemplate::New(isolate, UtilsExtension::SetLocale); + } else if (name->Equals(context, + v8::String::NewFromUtf8(isolate, "load", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, UtilsExtension::Load); + } else if (name->Equals(context, v8::String::NewFromUtf8( + isolate, "compileAndRunWithOrigin", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, + UtilsExtension::CompileAndRunWithOrigin); } return v8::Local<v8::FunctionTemplate>(); } + static void set_backend_task_runner(TaskRunner* runner) { + backend_runner_ = runner; + } + private: + static TaskRunner* backend_runner_; + static void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { for (int i = 0; i < args.Length(); i++) { v8::HandleScope handle_scope(args.GetIsolate()); @@ -102,8 +141,48 @@ class UtilsExtension : public v8::Extension { v8::String::Utf8Value str(args[0]); setlocale(LC_NUMERIC, *str); } + + static void Load(const v8::FunctionCallbackInfo<v8::Value>& args) { + if (args.Length() != 1 || !args[0]->IsString()) { + fprintf(stderr, "Internal error: load gets one string argument."); + Exit(); + } + v8::String::Utf8Value str(args[0]); + v8::Isolate* isolate = args.GetIsolate(); + bool exists = false; + std::string filename(*str, str.length()); + v8::internal::Vector<const char> chars = + v8::internal::ReadFile(filename.c_str(), &exists); + if (!exists) { + isolate->ThrowException( + v8::String::NewFromUtf8(isolate, "Error loading file", + v8::NewStringType::kNormal) + .ToLocalChecked()); + return; + } + ExecuteStringTask task(chars); + v8::Global<v8::Context> context(isolate, isolate->GetCurrentContext()); + task.Run(isolate, context); + } + + 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()) { + fprintf(stderr, + "Internal error: compileAndRunWithOrigin(source, name, line, " + "column)."); + 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>())); + } }; +TaskRunner* UtilsExtension::backend_runner_ = nullptr; + class SetTimeoutTask : public TaskRunner::Task { public: SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function) @@ -153,28 +232,84 @@ class SetTimeoutExtension : public v8::Extension { "Internal error: only setTimeout(function, 0) is supported."); Exit(); } - v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); + v8::Isolate* isolate = args.GetIsolate(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); if (args[0]->IsFunction()) { - TaskRunner::FromContext(context)->Append(new SetTimeoutTask( - args.GetIsolate(), v8::Local<v8::Function>::Cast(args[0]))); + TaskRunner::FromContext(context)->Append( + new SetTimeoutTask(isolate, v8::Local<v8::Function>::Cast(args[0]))); } else { - v8::Local<v8::String> data = args[0].As<v8::String>(); - std::unique_ptr<uint16_t[]> buffer(new uint16_t[data->Length()]); - data->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, data->Length()); - v8_inspector::String16 source = - v8_inspector::String16(buffer.get(), data->Length()); - TaskRunner::FromContext(context)->Append(new ExecuteStringTask(source)); + TaskRunner::FromContext(context)->Append(new ExecuteStringTask( + ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate), + v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0))); } } }; -v8_inspector::String16 ToString16(const v8_inspector::StringView& string) { +class InspectorExtension : public v8::Extension { + public: + InspectorExtension() + : v8::Extension("v8_inspector/inspector", + "native function attachInspector();" + "native function detachInspector();") {} + + virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( + v8::Isolate* isolate, v8::Local<v8::String> name) { + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + if (name->Equals(context, + v8::String::NewFromUtf8(isolate, "attachInspector", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, InspectorExtension::Attach); + } else if (name->Equals(context, + v8::String::NewFromUtf8(isolate, "detachInspector", + v8::NewStringType::kNormal) + .ToLocalChecked()) + .FromJust()) { + return v8::FunctionTemplate::New(isolate, InspectorExtension::Detach); + } + return v8::Local<v8::FunctionTemplate>(); + } + + private: + static void Attach(const v8::FunctionCallbackInfo<v8::Value>& args) { + v8::Isolate* isolate = args.GetIsolate(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8_inspector::V8Inspector* inspector = + InspectorClientImpl::InspectorFromContext(context); + if (!inspector) { + fprintf(stderr, "Inspector client not found - cannot attach!"); + Exit(); + } + inspector->contextCreated( + v8_inspector::V8ContextInfo(context, 1, v8_inspector::StringView())); + } + + static void Detach(const v8::FunctionCallbackInfo<v8::Value>& args) { + v8::Isolate* isolate = args.GetIsolate(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8_inspector::V8Inspector* inspector = + InspectorClientImpl::InspectorFromContext(context); + if (!inspector) { + fprintf(stderr, "Inspector client not found - cannot detach!"); + Exit(); + } + inspector->contextDestroyed(context); + } +}; + +v8::Local<v8::String> ToString(v8::Isolate* isolate, + const v8_inspector::StringView& string) { if (string.is8Bit()) - return v8_inspector::String16( - reinterpret_cast<const char*>(string.characters8()), string.length()); - return v8_inspector::String16( - reinterpret_cast<const uint16_t*>(string.characters16()), - string.length()); + return v8::String::NewFromOneByte(isolate, string.characters8(), + v8::NewStringType::kNormal, + static_cast<int>(string.length())) + .ToLocalChecked(); + else + return v8::String::NewFromTwoByte(isolate, string.characters16(), + v8::NewStringType::kNormal, + static_cast<int>(string.length())) + .ToLocalChecked(); } class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel { @@ -184,11 +319,24 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel { virtual ~FrontendChannelImpl() {} void SendMessageToFrontend(const v8_inspector::StringView& message) final { - v8_inspector::String16Builder script; - script.append("InspectorTest._dispatchMessage("); - script.append(ToString16(message)); - script.append(")"); - frontend_task_runner_->Append(new ExecuteStringTask(script.toString())); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope scope(v8::Isolate::GetCurrent()); + + v8::Local<v8::String> prefix = + v8::String::NewFromUtf8(isolate, "InspectorTest._dispatchMessage(", + v8::NewStringType::kInternalized) + .ToLocalChecked(); + v8::Local<v8::String> message_string = ToString(isolate, message); + v8::Local<v8::String> suffix = + v8::String::NewFromUtf8(isolate, ")", v8::NewStringType::kInternalized) + .ToLocalChecked(); + + 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))); } private: @@ -201,12 +349,14 @@ int main(int argc, char* argv[]) { v8::V8::InitializeICUDefaultLocation(argv[0]); v8::Platform* platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(platform); - v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); + v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::InitializeExternalStartupData(argv[0]); v8::V8::Initialize(); SetTimeoutExtension set_timeout_extension; v8::RegisterExtension(&set_timeout_extension); + InspectorExtension inspector_extension; + v8::RegisterExtension(&inspector_extension); UtilsExtension utils_extension; v8::RegisterExtension(&utils_extension); SendMessageToBackendExtension send_message_to_backend_extension; @@ -214,12 +364,14 @@ int main(int argc, char* argv[]) { v8::base::Semaphore ready_semaphore(0); - const char* backend_extensions[] = {"v8_inspector/setTimeout"}; + const char* backend_extensions[] = {"v8_inspector/setTimeout", + "v8_inspector/inspector"}; v8::ExtensionConfiguration backend_configuration( arraysize(backend_extensions), backend_extensions); TaskRunner backend_runner(&backend_configuration, false, &ready_semaphore); ready_semaphore.Wait(); SendMessageToBackendExtension::set_backend_task_runner(&backend_runner); + UtilsExtension::set_backend_task_runner(&backend_runner); const char* frontend_extensions[] = {"v8_inspector/utils", "v8_inspector/frontend"}; @@ -233,6 +385,9 @@ int main(int argc, char* argv[]) { &ready_semaphore); ready_semaphore.Wait(); + task_runners.push_back(&frontend_runner); + task_runners.push_back(&backend_runner); + for (int i = 1; i < argc; ++i) { if (argv[i][0] == '-') break; @@ -244,11 +399,10 @@ int main(int argc, char* argv[]) { argv[i]); Exit(); } - v8_inspector::String16 source = - v8_inspector::String16::fromUTF8(chars.start(), chars.length()); - frontend_runner.Append(new ExecuteStringTask(source)); + frontend_runner.Append(new ExecuteStringTask(chars)); } frontend_runner.Join(); + backend_runner.Join(); return 0; } diff --git a/deps/v8/test/inspector/inspector.gyp b/deps/v8/test/inspector/inspector.gyp index 21a75f9eef..8c96ae5d75 100644 --- a/deps/v8/test/inspector/inspector.gyp +++ b/deps/v8/test/inspector/inspector.gyp @@ -5,13 +5,6 @@ { 'variables': { 'v8_code': 1, - 'inspector_protocol_sources': [ - 'inspector-impl.cc', - 'inspector-impl.h', - 'inspector-test.cc', - 'task-runner.cc', - 'task-runner.h', - ], }, 'includes': ['../../gypfiles/toolchain.gypi', '../../gypfiles/features.gypi'], 'targets': [ @@ -20,22 +13,38 @@ 'type': 'executable', 'dependencies': [ '../../src/v8.gyp:v8_libplatform', + '../../src/v8.gyp:v8_libbase', + '../../src/v8.gyp:v8', ], 'include_dirs': [ '../..', ], 'sources': [ - '<@(inspector_protocol_sources)', - ], - 'conditions': [ - ['component=="shared_library"', { - # inspector-test can't be built against a shared library, so we - # need to depend on the underlying static target in that case. - 'dependencies': ['../../src/v8.gyp:v8_maybe_snapshot'], - }, { - 'dependencies': ['../../src/v8.gyp:v8'], - }], + 'inspector-impl.cc', + 'inspector-impl.h', + 'inspector-test.cc', + 'task-runner.cc', + 'task-runner.h', ], }, ], + 'conditions': [ + ['test_isolation_mode != "noop"', { + 'targets': [ + { + 'target_name': 'inspector-test_run', + 'type': 'none', + 'dependencies': [ + 'inspector-test', + ], + 'includes': [ + '../../gypfiles/isolate.gypi', + ], + 'sources': [ + 'inspector.isolate', + ], + }, + ], + }], + ], } diff --git a/deps/v8/test/inspector/inspector.isolate b/deps/v8/test/inspector/inspector.isolate new file mode 100644 index 0000000000..ca45911da3 --- /dev/null +++ b/deps/v8/test/inspector/inspector.isolate @@ -0,0 +1,27 @@ +# 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. +{ + 'conditions': [ + ['v8_enable_inspector==1', { + 'variables': { + 'files': [ + './console/', + './cpu-profiler/', + './debugger/', + './inspector.status', + './json-parse-expected.txt', + './json-parse.js', + './protocol-test.js', + './runtime/', + './testcfg.py', + '<(PRODUCT_DIR)/inspector-test<(EXECUTABLE_SUFFIX)', + ], + }, + }], + ], + 'includes': [ + '../../src/base.isolate', + '../../tools/testrunner/testrunner.isolate', + ], +}
\ No newline at end of file diff --git a/deps/v8/test/inspector/protocol-test.js b/deps/v8/test/inspector/protocol-test.js index 7eb822ae2e..9e18065201 100644 --- a/deps/v8/test/inspector/protocol-test.js +++ b/deps/v8/test/inspector/protocol-test.js @@ -31,12 +31,13 @@ Protocol = new Proxy({}, { InspectorTest.log = print.bind(null); -InspectorTest.logMessage = function(message) +InspectorTest.logMessage = function(originalMessage) { + var message = JSON.parse(JSON.stringify(originalMessage)); if (message.id) message.id = "<messageId>"; - const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp", "executionContextId", "callFrameId"]); + const nonStableFields = new Set(["objectId", "scriptId", "exceptionId", "timestamp", "executionContextId", "callFrameId", "breakpointId"]); var objects = [ message ]; while (objects.length) { var object = objects.shift(); @@ -49,7 +50,7 @@ InspectorTest.logMessage = function(message) } InspectorTest.logObject(message); - return message; + return originalMessage; } InspectorTest.logObject = function(object, title) @@ -96,11 +97,14 @@ InspectorTest.logObject = function(object, title) lines.push(prefix + "]"); } - dumpValue(object, "", title); + dumpValue(object, "", title || ""); InspectorTest.log(lines.join("\n")); } -InspectorTest.completeTest = quit.bind(null); +InspectorTest.completeTest = function() +{ + Protocol.Debugger.disable().then(() => quit()); +} InspectorTest.completeTestAfterPendingTimeouts = function() { @@ -109,18 +113,7 @@ InspectorTest.completeTestAfterPendingTimeouts = function() awaitPromise: true }).then(InspectorTest.completeTest); } -InspectorTest.addScript = function(string) -{ - return InspectorTest._sendCommandPromise("Runtime.evaluate", { "expression": string }).then(dumpErrorIfNeeded); - - function dumpErrorIfNeeded(message) - { - if (message.error) { - InspectorTest.log("Error while executing '" + string + "': " + message.error.message); - InspectorTest.completeTest(); - } - } -}; +InspectorTest.addScript = (string) => compileAndRunWithOrigin(string, "", 0, 0); InspectorTest.startDumpingProtocolMessages = function() { diff --git a/deps/v8/test/inspector/task-runner.cc b/deps/v8/test/inspector/task-runner.cc index c78d23b415..51fd110203 100644 --- a/deps/v8/test/inspector/task-runner.cc +++ b/deps/v8/test/inspector/task-runner.cc @@ -63,8 +63,9 @@ void TaskRunner::Run() { void TaskRunner::RunMessageLoop(bool only_protocol) { int loop_number = ++nested_loop_count_; - while (nested_loop_count_ == loop_number) { + while (nested_loop_count_ == loop_number && !is_terminated_.Value()) { TaskRunner::Task* task = GetNext(only_protocol); + if (!task) return; v8::Isolate::Scope isolate_scope(isolate_); if (catch_exceptions_) { v8::TryCatch try_catch(isolate_); @@ -93,8 +94,14 @@ void TaskRunner::Append(Task* task) { process_queue_semaphore_.Signal(); } +void TaskRunner::Terminate() { + is_terminated_.Increment(1); + process_queue_semaphore_.Signal(); +} + TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { for (;;) { + if (is_terminated_.Value()) return nullptr; if (only_protocol) { Task* task = nullptr; if (queue_.Dequeue(&task)) { @@ -108,7 +115,6 @@ TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { } process_queue_semaphore_.Wait(); } - UNREACHABLE(); return nullptr; } @@ -117,8 +123,29 @@ TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) { context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex)); } -ExecuteStringTask::ExecuteStringTask(const v8_inspector::String16& expression) - : expression_(expression) {} +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 + +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) + : expression_(expression), + name_(ToVector(name)), + line_offset_(line_offset.As<v8::Int32>()->Value()), + column_offset_(column_offset.As<v8::Int32>()->Value()) {} + +ExecuteStringTask::ExecuteStringTask( + const v8::internal::Vector<const char>& expression) + : expression_utf8_(expression), line_offset_(0), column_offset_(0) {} void ExecuteStringTask::Run(v8::Isolate* isolate, const v8::Global<v8::Context>& context) { @@ -128,12 +155,27 @@ void ExecuteStringTask::Run(v8::Isolate* isolate, v8::Local<v8::Context> local_context = context.Get(isolate); v8::Context::Scope context_scope(local_context); - v8::ScriptOrigin origin(v8::String::Empty(isolate)); - v8::Local<v8::String> source = - v8::String::NewFromTwoByte(isolate, expression_.characters16(), - v8::NewStringType::kNormal, - static_cast<int>(expression_.length())) + v8::Local<v8::String> name = + v8::String::NewFromTwoByte(isolate, name_.start(), + v8::NewStringType::kNormal, name_.length()) .ToLocalChecked(); + v8::Local<v8::Integer> line_offset = v8::Integer::New(isolate, line_offset_); + v8::Local<v8::Integer> column_offset = + v8::Integer::New(isolate, column_offset_); + + v8::ScriptOrigin origin(name, line_offset, column_offset); + v8::Local<v8::String> source; + if (expression_.length()) { + source = v8::String::NewFromTwoByte(isolate, expression_.start(), + v8::NewStringType::kNormal, + expression_.length()) + .ToLocalChecked(); + } else { + source = v8::String::NewFromUtf8(isolate, expression_utf8_.start(), + v8::NewStringType::kNormal, + expression_utf8_.length()) + .ToLocalChecked(); + } v8::ScriptCompiler::Source scriptSource(source, origin); v8::Local<v8::Script> script; diff --git a/deps/v8/test/inspector/task-runner.h b/deps/v8/test/inspector/task-runner.h index 88c36543d3..17385468be 100644 --- a/deps/v8/test/inspector/task-runner.h +++ b/deps/v8/test/inspector/task-runner.h @@ -8,10 +8,11 @@ #include "include/v8-inspector.h" #include "include/v8-platform.h" #include "include/v8.h" +#include "src/base/atomic-utils.h" #include "src/base/macros.h" #include "src/base/platform/platform.h" -#include "src/inspector/string-16.h" #include "src/locked-queue-inl.h" +#include "src/vector.h" class TaskRunner : public v8::base::Thread { public: @@ -39,6 +40,8 @@ class TaskRunner : public v8::base::Thread { static TaskRunner* FromContext(v8::Local<v8::Context>); + void Terminate(); + private: void InitializeContext(); Task* GetNext(bool only_protocol); @@ -51,28 +54,38 @@ class TaskRunner : public v8::base::Thread { v8::Global<v8::Context> context_; // deferred_queue_ combined with queue_ (in this order) have all tasks in the - // correct order. - // Sometimes we skip non-protocol tasks by moving them from queue_ to - // deferred_queue_. + // correct order. Sometimes we skip non-protocol tasks by moving them from + // queue_ to deferred_queue_. v8::internal::LockedQueue<Task*> queue_; v8::internal::LockedQueue<Task*> deffered_queue_; v8::base::Semaphore process_queue_semaphore_; int nested_loop_count_; + v8::base::AtomicNumber<int> is_terminated_; + DISALLOW_COPY_AND_ASSIGN(TaskRunner); }; class ExecuteStringTask : public TaskRunner::Task { public: - explicit ExecuteStringTask(const v8_inspector::String16& expression); + 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); + explicit ExecuteStringTask( + const v8::internal::Vector<const char>& expression); bool is_inspector_task() override { return false; } void Run(v8::Isolate* isolate, const v8::Global<v8::Context>& context) override; private: - v8_inspector::String16 expression_; + 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_; DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); }; |