2017-03-07 22:30:05 +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 createContext().');
|
|
|
|
|
|
|
|
var executionContextIds = new Set();
|
2017-05-19 00:35:45 +00:00
|
|
|
var contextGroup1 = new InspectorTest.ContextGroup();
|
|
|
|
var session1 = contextGroup1.connect();
|
|
|
|
setup(session1);
|
|
|
|
var contextGroup2 = new InspectorTest.ContextGroup();
|
|
|
|
var session2 = contextGroup2.connect();
|
|
|
|
setup(session2);
|
2017-05-18 23:11:20 +00:00
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
session1.Protocol.Runtime.enable()
|
|
|
|
.then(() => session2.Protocol.Runtime.enable({}))
|
|
|
|
.then(() => session1.Protocol.Debugger.enable())
|
|
|
|
.then(() => session2.Protocol.Debugger.enable({}))
|
2017-03-07 22:30:05 +00:00
|
|
|
.then(InspectorTest.logMessage)
|
|
|
|
.then(() => {
|
2017-05-19 00:35:45 +00:00
|
|
|
session1.Protocol.Runtime.evaluate({ expression: 'debugger;' });
|
|
|
|
session2.Protocol.Runtime.evaluate({expression: 'setTimeout(x => x * 2, 0)'});
|
|
|
|
session1.Protocol.Runtime.evaluate({ expression: 'setTimeout(x => x * 3, 0)' });
|
2017-03-07 22:30:05 +00:00
|
|
|
})
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => InspectorTest.waitForPendingTasks())
|
2017-03-07 22:30:05 +00:00
|
|
|
.then(() => {
|
|
|
|
InspectorTest.log(`Reported script's execution id: ${executionContextIds.size}`);
|
|
|
|
executionContextIds.clear();
|
|
|
|
})
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => session1.reconnect())
|
|
|
|
.then(() => session2.reconnect())
|
2017-03-07 22:30:05 +00:00
|
|
|
.then(() => {
|
2017-05-19 00:35:45 +00:00
|
|
|
session1.Protocol.Runtime.evaluate({ expression: 'debugger;' })
|
|
|
|
session2.Protocol.Runtime.evaluate({ expression: 'setTimeout(x => x * 2, 0)' });
|
|
|
|
session1.Protocol.Runtime.evaluate({ expression: 'setTimeout(x => x * 3, 0)' });
|
2017-03-07 22:30:05 +00:00
|
|
|
})
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => InspectorTest.waitForPendingTasks())
|
|
|
|
.then(() => session2.Protocol.Debugger.disable({}))
|
|
|
|
.then(() => session1.Protocol.Debugger.disable({}))
|
2017-03-07 22:30:05 +00:00
|
|
|
.then(() => InspectorTest.log(`Reported script's execution id: ${executionContextIds.size}`))
|
|
|
|
.then(InspectorTest.completeTest);
|
2017-05-18 23:11:20 +00:00
|
|
|
|
|
|
|
function setup(session) {
|
|
|
|
session.Protocol.Runtime.onExecutionContextCreated(InspectorTest.logMessage);
|
2017-05-19 00:35:45 +00:00
|
|
|
session.setupScriptMap();
|
2017-05-18 23:11:20 +00:00
|
|
|
session.Protocol.Debugger.onPaused((message) => {
|
2017-05-19 00:35:45 +00:00
|
|
|
session.logSourceLocation(message.params.callFrames[0].location);
|
2017-05-18 23:11:20 +00:00
|
|
|
session.Protocol.Debugger.stepOut();
|
|
|
|
});
|
|
|
|
session.Protocol.Debugger.onScriptParsed(message => executionContextIds.add(message.params.executionContextId));
|
|
|
|
}
|