v8/test/inspector/sessions/create-session.js
dgozman 375bea1c45 [inspector] Support multiple sessions per context group
This patch adds ability to connect multiple sessions to a single context group. This is an experimental feature, which is already supported in test harness.

So far covered runtime domain with tests (and found a bug thanks to the test). More tests to follow in next patches, probably with code adjustments as well.

BUG=chromium:590878

Review-Url: https://codereview.chromium.org/2906153002
Cr-Commit-Position: refs/heads/master@{#45667}
2017-06-01 21:33:59 +00:00

59 lines
2.0 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 creating multiple sessions works.');
function connect(contextGroup, num) {
var session = contextGroup.connect();
var executionContextId;
session.Protocol.Runtime.onExecutionContextCreated(message => {
InspectorTest.log('From session ' + num);
InspectorTest.logMessage(message);
executionContextId = message.params.context.id;
});
session.Protocol.Runtime.onExecutionContextDestroyed(message => {
InspectorTest.log('From session ' + num);
InspectorTest.logMessage(message);
InspectorTest.log('id matching: ' + (message.params.executionContextId === executionContextId));
});
return session;
}
(async function test() {
var contextGroup = new InspectorTest.ContextGroup();
InspectorTest.log('Connecting session 1');
var session1 = connect(contextGroup, 1);
await session1.Protocol.Runtime.enable();
InspectorTest.log('Connecting session 2');
var session2 = connect(contextGroup, 2);
await session2.Protocol.Runtime.enable();
InspectorTest.log('Reconnecting session 2');
session2.reconnect();
await session2.Protocol.Runtime.enable();
InspectorTest.log('Reconnecting session 1');
session1.reconnect();
await session1.Protocol.Runtime.enable();
InspectorTest.log('Connecting session 3');
var session3 = connect(contextGroup, 3);
await session3.Protocol.Runtime.enable();
InspectorTest.log('Destroying and creating context');
await session2.Protocol.Runtime.evaluate({expression: 'inspector.fireContextDestroyed(); inspector.fireContextCreated(); '});
InspectorTest.log('Disconnecting all sessions');
session1.disconnect();
session2.disconnect();
session3.disconnect();
InspectorTest.log('Connecting session 4');
var session4 = connect(contextGroup, 4);
await session4.Protocol.Runtime.enable();
InspectorTest.completeTest();
})();