fix: trace-startup crashing child process on macOS (#44257)

This commit is contained in:
Robo 2024-10-17 00:03:00 +09:00 committed by GitHub
parent df45474b58
commit af6e2fb257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 13 deletions

View file

@ -15,7 +15,7 @@ import * as path from 'node:path';
import { setTimeout } from 'node:timers/promises';
import * as url from 'node:url';
import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers';
import { ifit, ifdescribe, defer, itremote, listen, startRemoteControlApp } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { PipeTransport } from './pipe-transport';
@ -556,6 +556,36 @@ describe('command line switches', () => {
});
});
});
describe('--trace-startup switch', () => {
const outputFilePath = path.join(app.getPath('temp'), 'trace.json');
afterEach(() => {
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
});
it('creates startup trace', async () => {
const rc = await startRemoteControlApp(['--trace-startup=*', `--trace-startup-file=${outputFilePath}`, '--trace-startup-duration=1', '--enable-logging']);
const stderrComplete = new Promise<string>(resolve => {
let stderr = '';
rc.process.stderr!.on('data', (chunk) => {
stderr += chunk.toString('utf8');
});
rc.process.on('close', () => { resolve(stderr); });
});
rc.remotely(() => {
global.setTimeout(() => {
require('electron').app.quit();
}, 5000);
});
const stderr = await stderrComplete;
expect(stderr).to.match(/Completed startup tracing to/);
expect(fs.existsSync(outputFilePath)).to.be.true('output exists');
expect(fs.statSync(outputFilePath).size).to.be.above(0,
`the trace output file is empty, check "${outputFilePath}"`);
});
});
});
describe('chromium features', () => {