2017-03-24 02:44:25 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
InspectorTest.log('Checks Debugger.pause');
|
2017-05-19 00:35:45 +00:00
|
|
|
let contextGroup1 = new InspectorTest.ContextGroup();
|
|
|
|
let session1 = contextGroup1.connect();
|
|
|
|
let Protocol1 = session1.Protocol;
|
2017-03-24 02:44:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
session1.setupScriptMap();
|
|
|
|
Protocol1.Debugger.enable();
|
2017-03-24 02:44:25 +00:00
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
|
|
async function testPause() {
|
2017-05-19 00:35:45 +00:00
|
|
|
Protocol1.Debugger.pause();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async function testSkipFrameworks() {
|
2017-05-19 00:35:45 +00:00
|
|
|
Protocol1.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
|
|
|
|
Protocol1.Debugger.pause();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 239;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async function testSkipOtherContext1() {
|
2017-05-19 00:35:45 +00:00
|
|
|
let contextGroup2 = new InspectorTest.ContextGroup();
|
|
|
|
let session2 = contextGroup2.connect();
|
|
|
|
let Protocol2 = session2.Protocol;
|
|
|
|
Protocol2.Debugger.enable({});
|
|
|
|
Protocol1.Debugger.pause();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
|
|
|
|
Protocol2.Runtime.evaluate({expression: 'var a = 239;'});
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 1;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
|
|
|
await Protocol2.Debugger.disable({});
|
2017-03-24 02:44:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async function testSkipOtherContext2() {
|
2017-05-19 00:35:45 +00:00
|
|
|
let contextGroup2 = new InspectorTest.ContextGroup();
|
|
|
|
let session2 = contextGroup2.connect();
|
|
|
|
let Protocol2 = session2.Protocol;
|
|
|
|
session2.setupScriptMap();
|
|
|
|
Protocol2.Debugger.enable({});
|
|
|
|
Protocol2.Debugger.pause({});
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42; //# sourceURL=framework.js'});
|
|
|
|
Protocol2.Runtime.evaluate({expression: 'var a = 239;'});
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 1;'});
|
|
|
|
await waitPauseAndDumpLocation(session2);
|
2017-04-25 21:35:59 +00:00
|
|
|
// should not resume pause from different context group id.
|
2017-05-19 00:35:45 +00:00
|
|
|
Protocol1.Debugger.resume();
|
|
|
|
Protocol2.Debugger.stepOver({});
|
|
|
|
await waitPauseAndDumpLocation(session2);
|
|
|
|
await Protocol2.Debugger.resume({});
|
|
|
|
await Protocol2.Debugger.disable({});
|
2017-03-24 02:44:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async function testWithNativeBreakpoint() {
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup1.schedulePauseOnNextStatement('', '');
|
|
|
|
await Protocol1.Debugger.pause();
|
|
|
|
contextGroup1.cancelPauseOnNextStatement();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
await Protocol1.Debugger.pause();
|
|
|
|
contextGroup1.schedulePauseOnNextStatement('', '');
|
|
|
|
contextGroup1.cancelPauseOnNextStatement();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
contextGroup1.schedulePauseOnNextStatement('', '');
|
|
|
|
contextGroup1.cancelPauseOnNextStatement();
|
|
|
|
await Protocol1.Debugger.pause();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
},
|
|
|
|
|
2017-06-06 18:45:52 +00:00
|
|
|
async function testResumeAnotherGroup() {
|
|
|
|
let contextGroup2 = new InspectorTest.ContextGroup();
|
|
|
|
let session2 = contextGroup2.connect();
|
|
|
|
session2.setupScriptMap();
|
|
|
|
let Protocol2 = session2.Protocol;
|
|
|
|
Protocol2.Debugger.enable();
|
|
|
|
Protocol1.Debugger.pause();
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'});
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
InspectorTest.logMessage(await Protocol2.Debugger.resume());
|
|
|
|
InspectorTest.logMessage(await Protocol2.Debugger.stepOver());
|
|
|
|
InspectorTest.logMessage(await Protocol2.Debugger.stepInto());
|
|
|
|
InspectorTest.logMessage(await Protocol2.Debugger.stepOut());
|
|
|
|
await Protocol1.Debugger.resume();
|
|
|
|
await Protocol2.Debugger.disable();
|
|
|
|
},
|
|
|
|
|
2017-03-24 02:44:25 +00:00
|
|
|
async function testDisableBreaksShouldCancelPause() {
|
2017-05-19 00:35:45 +00:00
|
|
|
await Protocol1.Debugger.pause();
|
|
|
|
await Protocol1.Debugger.setBreakpointsActive({active: false});
|
|
|
|
Protocol1.Runtime.evaluate({expression: 'var a = 42;'})
|
|
|
|
.then(() => Protocol1.Debugger.setBreakpointsActive({active: true}))
|
|
|
|
.then(() => Protocol1.Runtime.evaluate({expression: 'debugger'}));
|
|
|
|
await waitPauseAndDumpLocation(session1);
|
|
|
|
await Protocol1.Debugger.resume();
|
2017-03-24 02:44:25 +00:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
2017-05-18 23:11:20 +00:00
|
|
|
async function waitPauseAndDumpLocation(session) {
|
|
|
|
var message = await session.Protocol.Debugger.oncePaused();
|
2017-03-24 02:44:25 +00:00
|
|
|
InspectorTest.log('paused at:');
|
2017-05-19 00:35:45 +00:00
|
|
|
await session.logSourceLocation(message.params.callFrames[0].location);
|
2017-03-24 02:44:25 +00:00
|
|
|
return message;
|
|
|
|
}
|