OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 InspectorTest.log('Tests that creating multiple sessions works.'); |
| 6 |
| 7 function connect(contextGroup, num) { |
| 8 var session = contextGroup.connect(); |
| 9 var executionContextId; |
| 10 session.Protocol.Runtime.onExecutionContextCreated(message => { |
| 11 InspectorTest.log('From session ' + num); |
| 12 InspectorTest.logMessage(message); |
| 13 executionContextId = message.params.context.id; |
| 14 }); |
| 15 session.Protocol.Runtime.onExecutionContextDestroyed(message => { |
| 16 InspectorTest.log('From session ' + num); |
| 17 InspectorTest.logMessage(message); |
| 18 InspectorTest.log('id matching: ' + (message.params.executionContextId === e
xecutionContextId)); |
| 19 }); |
| 20 return session; |
| 21 } |
| 22 |
| 23 (async function test() { |
| 24 var contextGroup = new InspectorTest.ContextGroup(); |
| 25 InspectorTest.log('Connecting session 1'); |
| 26 var session1 = connect(contextGroup, 1); |
| 27 await session1.Protocol.Runtime.enable(); |
| 28 |
| 29 InspectorTest.log('Connecting session 2'); |
| 30 var session2 = connect(contextGroup, 2); |
| 31 await session2.Protocol.Runtime.enable(); |
| 32 |
| 33 InspectorTest.log('Reconnecting session 2'); |
| 34 session2.reconnect(); |
| 35 await session2.Protocol.Runtime.enable(); |
| 36 |
| 37 InspectorTest.log('Reconnecting session 1'); |
| 38 session1.reconnect(); |
| 39 await session1.Protocol.Runtime.enable(); |
| 40 |
| 41 InspectorTest.log('Connecting session 3'); |
| 42 var session3 = connect(contextGroup, 3); |
| 43 await session3.Protocol.Runtime.enable(); |
| 44 |
| 45 InspectorTest.log('Destroying and creating context'); |
| 46 await session2.Protocol.Runtime.evaluate({expression: 'inspector.fireContextDe
stroyed(); inspector.fireContextCreated(); '}); |
| 47 |
| 48 InspectorTest.log('Disconnecting all sessions'); |
| 49 session1.disconnect(); |
| 50 session2.disconnect(); |
| 51 session3.disconnect(); |
| 52 |
| 53 InspectorTest.log('Connecting session 4'); |
| 54 var session4 = connect(contextGroup, 4); |
| 55 await session4.Protocol.Runtime.enable(); |
| 56 |
| 57 InspectorTest.completeTest(); |
| 58 })(); |
OLD | NEW |