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