зеркало из https://github.com/electron/electron.git
test: run script to help target discovery and reduce flakes (#44741)
This commit is contained in:
Родитель
54d53bfa51
Коммит
8223ebc111
|
@ -227,20 +227,25 @@ describe('debugger module', () => {
|
||||||
it('creates unique session id for each target', (done) => {
|
it('creates unique session id for each target', (done) => {
|
||||||
w.webContents.loadFile(path.join(__dirname, 'fixtures', 'sub-frames', 'debug-frames.html'));
|
w.webContents.loadFile(path.join(__dirname, 'fixtures', 'sub-frames', 'debug-frames.html'));
|
||||||
w.webContents.debugger.attach();
|
w.webContents.debugger.attach();
|
||||||
let session: String;
|
let debuggerSessionId: string;
|
||||||
|
|
||||||
w.webContents.debugger.on('message', (event, ...args) => {
|
w.webContents.debugger.on('message', (event, ...args) => {
|
||||||
const [method, params, sessionId] = args;
|
const [method, params, sessionId] = args;
|
||||||
if (method === 'Target.targetCreated') {
|
if (method === 'Target.targetCreated') {
|
||||||
w.webContents.debugger.sendCommand('Target.attachToTarget', { targetId: params.targetInfo.targetId, flatten: true }).then(result => {
|
w.webContents.debugger.sendCommand('Target.attachToTarget', { targetId: params.targetInfo.targetId, flatten: true }).then(result => {
|
||||||
session = result.sessionId;
|
debuggerSessionId = result.sessionId;
|
||||||
w.webContents.debugger.sendCommand('Debugger.enable', {}, result.sessionId);
|
w.webContents.debugger.sendCommand('Debugger.enable', {}, result.sessionId);
|
||||||
|
|
||||||
|
// Ensure debugger finds a script to pause to possibly reduce flaky
|
||||||
|
// tests.
|
||||||
|
w.webContents.mainFrame.executeJavaScript('void 0;');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (method === 'Debugger.scriptParsed') {
|
if (method === 'Debugger.scriptParsed') {
|
||||||
expect(sessionId).to.equal(session);
|
if (sessionId === debuggerSessionId) {
|
||||||
w.webContents.debugger.detach();
|
w.webContents.debugger.detach();
|
||||||
done();
|
done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
w.webContents.debugger.sendCommand('Target.setDiscoverTargets', { discover: true });
|
w.webContents.debugger.sendCommand('Target.setDiscoverTargets', { discover: true });
|
||||||
|
|
Загрузка…
Ссылка в новой задаче