mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: use non-deprecated tracing categories api (#7413)
This commit is contained in:
parent
f04ffdbe2c
commit
040a0e561b
@ -87,11 +87,19 @@ export class Tracing {
|
|||||||
|
|
||||||
if (screenshots) categories.push('disabled-by-default-devtools.screenshot');
|
if (screenshots) categories.push('disabled-by-default-devtools.screenshot');
|
||||||
|
|
||||||
|
const excludedCategories = categories
|
||||||
|
.filter((cat) => cat.startsWith('-'))
|
||||||
|
.map((cat) => cat.slice(1));
|
||||||
|
const includedCategories = categories.filter((cat) => !cat.startsWith('-'));
|
||||||
|
|
||||||
this._path = path;
|
this._path = path;
|
||||||
this._recording = true;
|
this._recording = true;
|
||||||
await this._client.send('Tracing.start', {
|
await this._client.send('Tracing.start', {
|
||||||
transferMode: 'ReturnAsStream',
|
transferMode: 'ReturnAsStream',
|
||||||
categories: categories.join(','),
|
traceConfig: {
|
||||||
|
excludedCategories,
|
||||||
|
includedCategories,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,15 +56,38 @@ describeChromeOnly('Tracing', function () {
|
|||||||
it('should run with custom categories if provided', async () => {
|
it('should run with custom categories if provided', async () => {
|
||||||
await page.tracing.start({
|
await page.tracing.start({
|
||||||
path: outputFile,
|
path: outputFile,
|
||||||
categories: ['disabled-by-default-v8.cpu_profiler.hires'],
|
categories: ['-*', 'disabled-by-default-v8.cpu_profiler.hires'],
|
||||||
});
|
});
|
||||||
await page.tracing.stop();
|
await page.tracing.stop();
|
||||||
|
|
||||||
const traceJson = JSON.parse(
|
const traceJson = JSON.parse(
|
||||||
fs.readFileSync(outputFile, { encoding: 'utf8' })
|
fs.readFileSync(outputFile, { encoding: 'utf8' })
|
||||||
);
|
);
|
||||||
expect(traceJson.metadata['trace-config']).toContain(
|
const traceConfig = JSON.parse(traceJson.metadata['trace-config']);
|
||||||
'disabled-by-default-v8.cpu_profiler.hires'
|
expect(traceConfig.included_categories).toEqual([
|
||||||
|
'disabled-by-default-v8.cpu_profiler.hires',
|
||||||
|
]);
|
||||||
|
expect(traceConfig.excluded_categories).toEqual(['*']);
|
||||||
|
expect(traceJson.traceEvents).not.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
cat: 'toplevel',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should run with default categories', async () => {
|
||||||
|
await page.tracing.start({
|
||||||
|
path: outputFile,
|
||||||
|
});
|
||||||
|
await page.tracing.stop();
|
||||||
|
|
||||||
|
const traceJson = JSON.parse(
|
||||||
|
fs.readFileSync(outputFile, { encoding: 'utf8' })
|
||||||
|
);
|
||||||
|
expect(traceJson.traceEvents).toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
cat: 'toplevel',
|
||||||
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should throw if tracing on two pages', async () => {
|
it('should throw if tracing on two pages', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user