v8/test/inspector/sessions/runtime-evaluate.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

26 lines
1.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 multiple sessions share the context.');
(async function test() {
var contextGroup = new InspectorTest.ContextGroup();
var session1 = contextGroup.connect();
var session2 = contextGroup.connect();
InspectorTest.log('Assigning in 1');
await session1.Protocol.Runtime.evaluate({expression: 'var a = 42;'});
InspectorTest.log('Evaluating in 2');
InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: 'a'}));
InspectorTest.log('Awaiting in 1');
var promise = session1.Protocol.Runtime.evaluate({expression: 'var cb; new Promise(f => cb = f)', awaitPromise: true});
InspectorTest.log('Resolving in 2');
await session2.Protocol.Runtime.evaluate({expression: 'cb("foo")'});
InspectorTest.log('Should resolve in 1');
InspectorTest.logMessage(await promise);
InspectorTest.completeTest();
})();