Index: test/inspector/debugger/set-breakpoint.js |
diff --git a/test/inspector/debugger/set-breakpoint.js b/test/inspector/debugger/set-breakpoint.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..60762b5a540e3932edbfad07e5d62cb9c17a5f8f |
--- /dev/null |
+++ b/test/inspector/debugger/set-breakpoint.js |
@@ -0,0 +1,111 @@ |
+// Copyright 2017 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+print('Checks protocol methods related to breakpoints'); |
+ |
+InspectorTest.addScript(` |
+function foo() { |
+ return 42; |
+} |
+//# sourceURL=test.js`, 7, 26); |
+ |
+InspectorTest.setupScriptMap(); |
+Protocol.Debugger.onPaused(message => { |
+ InspectorTest.logCallFrames(message.params.callFrames); |
+ delete message.params.callFrames; |
+ InspectorTest.logMessage(message); |
+ Protocol.Debugger.resume(); |
+}); |
+ |
+Protocol.Debugger.enable(); |
+InspectorTest.runTestSuite([ |
+ function oneBreakpointTwoScripts(next) { |
+ var source = ` |
+ var arr = arr || []; |
+ arr.push(function foo() { |
+ return 42; |
+ }); |
+ //# sourceURL=oneBreakpointTwoScripts.js`; |
+ |
+ Protocol.Debugger.onBreakpointResolved(InspectorTest.logMessage); |
+ var breakpointId; |
+ Protocol.Debugger.setBreakpointByUrl({ lineNumber: 3, url: 'oneBreakpointTwoScripts.js'}) |
+ .then(message => breakpointId = message.result.breakpointId) |
+ .then(() => Protocol.Runtime.evaluate({ expression: source })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: source })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'arr.map(f => f())'})) |
+ .then(() => Protocol.Debugger.removeBreakpoint({ breakpointId: breakpointId })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'arr.map(f => f())'})) |
+ .then(() => Protocol.Debugger.onBreakpointResolved(undefined)) |
+ .then(next); |
+ }, |
+ |
+ function debugCommandAndRegularBreakpoint(next) { |
+ Protocol.Debugger.onBreakpointResolved(InspectorTest.logMessage); |
+ var breakpointId; |
+ Protocol.Runtime.evaluate({ expression: 'debug(foo); monitor(foo);', includeCommandLineAPI: true }) |
+ .then(() => Protocol.Debugger.setBreakpointByUrl({ lineNumber: 8, columnNumber: 12, url: 'test.js' })) |
+ .then(message => breakpointId = message.result.breakpointId) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'foo()' })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'undebug(foo); unmonitor(foo);', includeCommandLineAPI: true })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'foo()' })) |
+ .then(() => Protocol.Debugger.removeBreakpoint({ breakpointId: breakpointId })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'foo()' })) |
+ .then(() => Protocol.Debugger.onBreakpointResolved(undefined)) |
+ .then(next); |
+ }, |
+ |
+ function setBreakpointByRawLocation(next) { |
+ var scriptId; |
+ var breakpointId; |
+ Protocol.Debugger.onceScriptParsed() |
+ .then(message => scriptId = message.params.scriptId) |
+ .then(() => Protocol.Debugger.setBreakpoint({ location: { scriptId: scriptId, lineNumber: 2 } })) |
+ .then(message => breakpointId = message.result.breakpointId) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'boo()' })) |
+ .then(() => Protocol.Debugger.setBreakpoint({ location: { scriptId: scriptId, lineNumber: 2 } })) |
+ .then(InspectorTest.logMessage) |
+ .then(() => Protocol.Debugger.removeBreakpoint({ breakpointId: breakpointId })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'boo()' })) |
+ .then(() => Protocol.Debugger.setBreakpoint({ location: { scriptId: scriptId, lineNumber: 42 } })) |
+ .then(InspectorTest.logMessage) |
+ .then(next); |
+ |
+ var source = ` |
+ function boo() { |
+ return 42; |
+ } |
+ //# sourceURL=setBreakpointByRawLocation.js`; |
+ Protocol.Runtime.evaluate({ expression: source }); |
+ }, |
+ |
+ function setBreakpointArgumentsChecks(next) { |
+ Protocol.Debugger.setBreakpointByUrl({ lineNumber: 42 }) |
+ .then(InspectorTest.logMessage) |
+ .then(() => Protocol.Debugger.setBreakpointByUrl({ lineNumber: 42, url: 'random.url' })) |
+ .then(() => Protocol.Debugger.setBreakpointByUrl({ lineNumber: 42, url: 'random.url' })) |
+ .then(InspectorTest.logMessage) |
+ .then(next); |
+ }, |
+ |
+ function setBreakpointByRegex(next) { |
+ var source = ` |
+ var arr = arr || []; |
+ arr.push(function foo() { |
+ return 42; |
+ });`; |
+ |
+ Protocol.Debugger.onBreakpointResolved(InspectorTest.logMessage); |
+ var breakpointId; |
+ Protocol.Debugger.setBreakpointByUrl({ lineNumber: 3, urlRegex: 'setBreakpointByRegex-[0-9]\\.js'}) |
+ .then(message => breakpointId = message.result.breakpointId) |
+ .then(() => Protocol.Runtime.evaluate({ expression: source + '//# sourceURL=setBreakpointByRegex-1.js'})) |
+ .then(() => Protocol.Runtime.evaluate({ expression: source + '//# sourceURL=setBreakpointByRegex-2.js'})) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'arr.map(f => f())'})) |
+ .then(() => Protocol.Debugger.removeBreakpoint({ breakpointId: breakpointId })) |
+ .then(() => Protocol.Runtime.evaluate({ expression: 'arr.map(f => f())'})) |
+ .then(() => Protocol.Debugger.onBreakpointResolved(undefined)) |
+ .then(next); |
+ } |
+]); |