v8/test/inspector/sessions/pause-on-console-assert.js
dgozman f5767bf6c4 [inspector] Make pausing on console.assert work with multiple sessions
Instead of going through debugger agent, this patch implements
console.assert pause similar to debugger statement and OOM break.

New test uncovered a bug, where pause on exceptions state mix up
between different context groups. Added a TODO to fix it.

BUG=chromium:590878

Review-Url: https://codereview.chromium.org/2916363002
Cr-Commit-Position: refs/heads/master@{#45711}
2017-06-05 18:41:00 +00:00

55 lines
2.4 KiB
JavaScript

// 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('Tests that multiple sessions pause once on console.assert.');
(async function test() {
var contextGroup1 = new InspectorTest.ContextGroup();
var session1 = await connect(contextGroup1, 1);
var session2 = await connect(contextGroup1, 2);
var contextGroup2 = new InspectorTest.ContextGroup();
var session3 = await connect(contextGroup2, 3);
InspectorTest.log('Pausing on exceptions in 1');
await session1.Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Asserting in 1');
await session1.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Asserting in 2');
await session2.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Pausing on exceptions in both');
await session2.Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Asserting in 1');
await session1.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Asserting in 2');
await session2.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Not pausing on exceptions');
await session1.Protocol.Debugger.setPauseOnExceptions({state: 'none'});
await session2.Protocol.Debugger.setPauseOnExceptions({state: 'none'});
InspectorTest.log('Asserting in 1');
await session1.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Asserting in 2');
await session2.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Pausing on exceptions in 3 (different context group)');
await session3.Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Asserting in 3');
await session3.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.log('Asserting in 1');
await session1.Protocol.Runtime.evaluate({expression: 'console.assert(false)'});
InspectorTest.completeTest();
})();
async function connect(contextGroup, num) {
var session = contextGroup.connect();
await session.Protocol.Debugger.enable();
session.Protocol.Debugger.onPaused(message => {
InspectorTest.log(`Paused in ${num} with reason ${message.params.reason}`);
session.Protocol.Debugger.resume();
});
return session;
}