| OLD | NEW |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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.log('Checks Debugger.pause'); | 5 InspectorTest.log('Checks Debugger.pause'); |
| 6 let contextGroup1 = new InspectorTest.ContextGroup(); |
| 7 let session1 = contextGroup1.connect(); |
| 8 let Protocol1 = session1.Protocol; |
| 6 | 9 |
| 7 InspectorTest.setupScriptMap(); | 10 session1.setupScriptMap(); |
| 8 Protocol.Debugger.enable(); | 11 Protocol1.Debugger.enable(); |
| 9 InspectorTest.runAsyncTestSuite([ | 12 InspectorTest.runAsyncTestSuite([ |
| 10 async function testPause() { | 13 async function testPause() { |
| 11 Protocol.Debugger.pause(); | 14 Protocol1.Debugger.pause(); |
| 12 Protocol.Runtime.evaluate({expression: 'var a = 42;'}); | 15 Protocol1.Runtime.evaluate({expression: 'var a = 42;'}); |
| 13 await waitPauseAndDumpLocation(); | 16 await waitPauseAndDumpLocation(session1); |
| 14 await Protocol.Debugger.resume(); | 17 await Protocol1.Debugger.resume(); |
| 15 }, | 18 }, |
| 16 | 19 |
| 17 async function testSkipFrameworks() { | 20 async function testSkipFrameworks() { |
| 18 Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); | 21 Protocol1.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); |
| 19 Protocol.Debugger.pause(); | 22 Protocol1.Debugger.pause(); |
| 20 Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.
js'}); | 23 Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework
.js'}); |
| 21 Protocol.Runtime.evaluate({expression: 'var a = 239;'}); | 24 Protocol1.Runtime.evaluate({expression: 'var a = 239;'}); |
| 22 await waitPauseAndDumpLocation(); | 25 await waitPauseAndDumpLocation(session1); |
| 23 await Protocol.Debugger.resume(); | 26 await Protocol1.Debugger.resume(); |
| 24 }, | 27 }, |
| 25 | 28 |
| 26 async function testSkipOtherContext1() { | 29 async function testSkipOtherContext1() { |
| 27 let contextGroup = InspectorTest.createContextGroup(); | 30 let contextGroup2 = new InspectorTest.ContextGroup(); |
| 28 let session = InspectorTest.createSession(contextGroup); | 31 let session2 = contextGroup2.connect(); |
| 29 session.Protocol.Debugger.enable({}); | 32 let Protocol2 = session2.Protocol; |
| 30 Protocol.Debugger.pause(); | 33 Protocol2.Debugger.enable({}); |
| 31 Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.
js'}); | 34 Protocol1.Debugger.pause(); |
| 32 session.Protocol.Runtime.evaluate({expression: 'var a = 239;'}); | 35 Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework
.js'}); |
| 33 Protocol.Runtime.evaluate({expression: 'var a = 1;'}); | 36 Protocol2.Runtime.evaluate({expression: 'var a = 239;'}); |
| 34 await waitPauseAndDumpLocation(); | 37 Protocol1.Runtime.evaluate({expression: 'var a = 1;'}); |
| 35 await Protocol.Debugger.resume(); | 38 await waitPauseAndDumpLocation(session1); |
| 36 await session.Protocol.Debugger.disable({}); | 39 await Protocol1.Debugger.resume(); |
| 40 await Protocol2.Debugger.disable({}); |
| 37 }, | 41 }, |
| 38 | 42 |
| 39 async function testSkipOtherContext2() { | 43 async function testSkipOtherContext2() { |
| 40 let contextGroup = InspectorTest.createContextGroup(); | 44 let contextGroup2 = new InspectorTest.ContextGroup(); |
| 41 let session = InspectorTest.createSession(contextGroup); | 45 let session2 = contextGroup2.connect(); |
| 42 InspectorTest.setupScriptMap(session); | 46 let Protocol2 = session2.Protocol; |
| 43 session.Protocol.Debugger.enable({}); | 47 session2.setupScriptMap(); |
| 44 session.Protocol.Debugger.pause({}); | 48 Protocol2.Debugger.enable({}); |
| 45 Protocol.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.
js'}); | 49 Protocol2.Debugger.pause({}); |
| 46 session.Protocol.Runtime.evaluate({expression: 'var a = 239;'}); | 50 Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework
.js'}); |
| 47 Protocol.Runtime.evaluate({expression: 'var a = 1;'}); | 51 Protocol2.Runtime.evaluate({expression: 'var a = 239;'}); |
| 48 await waitPauseAndDumpLocation(session); | 52 Protocol1.Runtime.evaluate({expression: 'var a = 1;'}); |
| 53 await waitPauseAndDumpLocation(session2); |
| 49 // should not resume pause from different context group id. | 54 // should not resume pause from different context group id. |
| 50 Protocol.Debugger.resume(); | 55 Protocol1.Debugger.resume(); |
| 51 session.Protocol.Debugger.stepOver({}); | 56 Protocol2.Debugger.stepOver({}); |
| 52 await waitPauseAndDumpLocation(session); | 57 await waitPauseAndDumpLocation(session2); |
| 53 await session.Protocol.Debugger.resume({}); | 58 await Protocol2.Debugger.resume({}); |
| 54 await session.Protocol.Debugger.disable({}); | 59 await Protocol2.Debugger.disable({}); |
| 55 }, | 60 }, |
| 56 | 61 |
| 57 async function testWithNativeBreakpoint() { | 62 async function testWithNativeBreakpoint() { |
| 58 InspectorTest.contextGroup.schedulePauseOnNextStatement('', ''); | 63 contextGroup1.schedulePauseOnNextStatement('', ''); |
| 59 await Protocol.Debugger.pause(); | 64 await Protocol1.Debugger.pause(); |
| 60 InspectorTest.contextGroup.cancelPauseOnNextStatement(); | 65 contextGroup1.cancelPauseOnNextStatement(); |
| 61 Protocol.Runtime.evaluate({expression: 'var a = 42;'}); | 66 Protocol1.Runtime.evaluate({expression: 'var a = 42;'}); |
| 62 await waitPauseAndDumpLocation(); | 67 await waitPauseAndDumpLocation(session1); |
| 63 await Protocol.Debugger.resume(); | 68 await Protocol1.Debugger.resume(); |
| 64 | 69 |
| 65 await Protocol.Debugger.pause(); | 70 await Protocol1.Debugger.pause(); |
| 66 InspectorTest.contextGroup.schedulePauseOnNextStatement('', ''); | 71 contextGroup1.schedulePauseOnNextStatement('', ''); |
| 67 InspectorTest.contextGroup.cancelPauseOnNextStatement(); | 72 contextGroup1.cancelPauseOnNextStatement(); |
| 68 Protocol.Runtime.evaluate({expression: 'var a = 42;'}); | 73 Protocol1.Runtime.evaluate({expression: 'var a = 42;'}); |
| 69 await waitPauseAndDumpLocation(); | 74 await waitPauseAndDumpLocation(session1); |
| 70 await Protocol.Debugger.resume(); | 75 await Protocol1.Debugger.resume(); |
| 71 | 76 |
| 72 InspectorTest.contextGroup.schedulePauseOnNextStatement('', ''); | 77 contextGroup1.schedulePauseOnNextStatement('', ''); |
| 73 InspectorTest.contextGroup.cancelPauseOnNextStatement(); | 78 contextGroup1.cancelPauseOnNextStatement(); |
| 74 await Protocol.Debugger.pause(); | 79 await Protocol1.Debugger.pause(); |
| 75 Protocol.Runtime.evaluate({expression: 'var a = 42;'}); | 80 Protocol1.Runtime.evaluate({expression: 'var a = 42;'}); |
| 76 await waitPauseAndDumpLocation(); | 81 await waitPauseAndDumpLocation(session1); |
| 77 await Protocol.Debugger.resume(); | 82 await Protocol1.Debugger.resume(); |
| 78 }, | 83 }, |
| 79 | 84 |
| 80 async function testDisableBreaksShouldCancelPause() { | 85 async function testDisableBreaksShouldCancelPause() { |
| 81 await Protocol.Debugger.pause(); | 86 await Protocol1.Debugger.pause(); |
| 82 await Protocol.Debugger.setBreakpointsActive({active: false}); | 87 await Protocol1.Debugger.setBreakpointsActive({active: false}); |
| 83 Protocol.Runtime.evaluate({expression: 'var a = 42;'}) | 88 Protocol1.Runtime.evaluate({expression: 'var a = 42;'}) |
| 84 .then(() => Protocol.Debugger.setBreakpointsActive({active: true})) | 89 .then(() => Protocol1.Debugger.setBreakpointsActive({active: true})) |
| 85 .then(() => Protocol.Runtime.evaluate({expression: 'debugger'})); | 90 .then(() => Protocol1.Runtime.evaluate({expression: 'debugger'})); |
| 86 await waitPauseAndDumpLocation(); | 91 await waitPauseAndDumpLocation(session1); |
| 87 await Protocol.Debugger.resume(); | 92 await Protocol1.Debugger.resume(); |
| 88 } | 93 } |
| 89 ]); | 94 ]); |
| 90 | 95 |
| 91 async function waitPauseAndDumpLocation(session) { | 96 async function waitPauseAndDumpLocation(session) { |
| 92 session = session || InspectorTest.session; | |
| 93 var message = await session.Protocol.Debugger.oncePaused(); | 97 var message = await session.Protocol.Debugger.oncePaused(); |
| 94 InspectorTest.log('paused at:'); | 98 InspectorTest.log('paused at:'); |
| 95 await InspectorTest.logSourceLocation(message.params.callFrames[0].location, s
ession); | 99 await session.logSourceLocation(message.params.callFrames[0].location); |
| 96 return message; | 100 return message; |
| 97 } | 101 } |
| OLD | NEW |