mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
committed by
Andrey Lushnikov
parent
04991ad025
commit
98bb2615ad
@@ -35,7 +35,6 @@ class Tracing {
|
||||
*/
|
||||
async start(options) {
|
||||
console.assert(!this._recording, 'Cannot start recording trace while already recording trace.');
|
||||
console.assert(options.path, 'Must specify a path to write trace file to.');
|
||||
|
||||
const defaultCategories = [
|
||||
'-*', 'devtools.timeline', 'v8.execute', 'disabled-by-default-devtools.timeline',
|
||||
@@ -73,15 +72,26 @@ class Tracing {
|
||||
*/
|
||||
async _readStream(handle, path) {
|
||||
let eof = false;
|
||||
const file = await openAsync(path, 'w');
|
||||
let file;
|
||||
if (path)
|
||||
file = await openAsync(path, 'w');
|
||||
const bufs = [];
|
||||
while (!eof) {
|
||||
const response = await this._client.send('IO.read', {handle});
|
||||
eof = response.eof;
|
||||
bufs.push(new Buffer(response.data));
|
||||
if (path)
|
||||
await writeAsync(file, response.data);
|
||||
}
|
||||
await closeAsync(file);
|
||||
if (path)
|
||||
await closeAsync(file);
|
||||
await this._client.send('IO.close', {handle});
|
||||
let resultBuffer = null;
|
||||
try {
|
||||
resultBuffer = Buffer.concat(bufs);
|
||||
} finally {
|
||||
return resultBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.tracePublicAPI(Tracing);
|
||||
|
||||
Reference in New Issue
Block a user