| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 InspectorTest.addScript( | 5 InspectorTest.log('Checks Protocol.Debugger.setBlackboxPatterns'); |
| 6 `function bar() | |
| 7 { | |
| 8 return 42; | |
| 9 }`); | |
| 10 | 6 |
| 11 InspectorTest.addScript( | 7 InspectorTest.addScript(` |
| 12 `function foo() | 8 function bar() { |
| 13 { | 9 return 42; |
| 14 var a = bar(); | 10 } |
| 15 return a + 1; | 11 //# sourceURL=bar.js`); |
| 12 |
| 13 InspectorTest.addScript(` |
| 14 function foo() { |
| 15 var a = bar(); |
| 16 return a + 1; |
| 16 } | 17 } |
| 17 //# sourceURL=foo.js`); | 18 //# sourceURL=foo.js`); |
| 18 | 19 |
| 19 InspectorTest.addScript( | 20 InspectorTest.addScript(` |
| 20 `function qwe() | 21 function qwe() { |
| 21 { | 22 var a = foo(); |
| 22 var a = foo(); | 23 return a + 1; |
| 23 return a + 1; | |
| 24 } | 24 } |
| 25 //# sourceURL=qwe.js`); | 25 //# sourceURL=qwe.js`); |
| 26 | 26 |
| 27 InspectorTest.addScript( | 27 InspectorTest.addScript(` |
| 28 `function baz() | 28 function baz() { |
| 29 { | |
| 30 var a = qwe(); | 29 var a = qwe(); |
| 31 return a + 1; | 30 return a + 1; |
| 32 } | 31 } |
| 33 //# sourceURL=baz.js`); | 32 //# sourceURL=baz.js`); |
| 34 | 33 |
| 34 InspectorTest.setupScriptMap(); |
| 35 InspectorTest.logProtocolCommandCalls('Debugger.pause'); |
| 36 InspectorTest.logProtocolCommandCalls('Debugger.stepInto'); |
| 37 InspectorTest.logProtocolCommandCalls('Debugger.stepOver'); |
| 35 Protocol.Debugger.enable(); | 38 Protocol.Debugger.enable(); |
| 36 Protocol.Debugger.setBlackboxPatterns({ patterns: [ "foo([" ] }).then(dumpError)
; | 39 InspectorTest.runAsyncTestSuite([ |
| 40 async function testIncorrectPattern() { |
| 41 let message = await Protocol.Debugger.setBlackboxPatterns({ |
| 42 patterns: [ "foo([" ] }); |
| 43 InspectorTest.log(message.error.message); |
| 44 }, |
| 37 | 45 |
| 38 function dumpError(message) | 46 async function testStepping() { |
| 39 { | 47 await Protocol.Debugger.setBlackboxPatterns({ |
| 40 InspectorTest.log(message.error.message); | 48 patterns: [ "baz\.js", "foo\.js" ] }); |
| 41 Protocol.Debugger.onPaused(dumpStackAndRunNextCommand); | 49 await Protocol.Debugger.pause(); |
| 42 Protocol.Debugger.setBlackboxPatterns({ patterns: [ "baz\.js", "foo\.js" ] }); | 50 Protocol.Runtime.evaluate({expression: 'baz()\n'}); |
| 43 Protocol.Runtime.evaluate({ "expression": "debugger;baz()" }); | 51 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 52 Protocol.Debugger.stepInto(); |
| 53 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 54 Protocol.Debugger.stepInto(); |
| 55 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 56 Protocol.Debugger.stepOut(); |
| 57 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 58 Protocol.Debugger.stepInto(); |
| 59 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 60 Protocol.Debugger.stepInto(); |
| 61 await logPauseLocation(await Protocol.Debugger.oncePaused()); |
| 62 await Protocol.Debugger.resume(); |
| 63 } |
| 64 ]); |
| 65 |
| 66 function logPauseLocation(message) { |
| 67 InspectorTest.log('\nStack:'); |
| 68 InspectorTest.logCallFrames(message.params.callFrames); |
| 69 InspectorTest.log('\nBreak location:'); |
| 70 return InspectorTest.logSourceLocation(message.params.callFrames[0].location); |
| 44 } | 71 } |
| 45 | |
| 46 var commands = [ "stepInto", "stepInto", "stepInto", "stepOut", "stepInto", "ste
pInto" ]; | |
| 47 function dumpStackAndRunNextCommand(message) | |
| 48 { | |
| 49 InspectorTest.log("Paused in"); | |
| 50 var callFrames = message.params.callFrames; | |
| 51 for (var callFrame of callFrames) | |
| 52 InspectorTest.log((callFrame.functionName || "(...)") + ":" + (callFrame.loc
ation.lineNumber + 1)); | |
| 53 var command = commands.shift(); | |
| 54 if (!command) { | |
| 55 InspectorTest.completeTest(); | |
| 56 return; | |
| 57 } | |
| 58 Protocol.Debugger[command](); | |
| 59 } | |
| OLD | NEW |