mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
implement browser.stdout and browser.stderr
This commit is contained in:
parent
c8664319ed
commit
e75f59210e
@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
let {Duplex} = require('stream');
|
||||||
let http = require('http');
|
let http = require('http');
|
||||||
let path = require('path');
|
let path = require('path');
|
||||||
let removeRecursive = require('rimraf').sync;
|
let removeRecursive = require('rimraf').sync;
|
||||||
@ -64,6 +65,9 @@ class Browser {
|
|||||||
this._terminated = false;
|
this._terminated = false;
|
||||||
this._chromeProcess = null;
|
this._chromeProcess = null;
|
||||||
this._launchPromise = null;
|
this._launchPromise = null;
|
||||||
|
|
||||||
|
this.stderr = new ProxyStream();
|
||||||
|
this.stdout = new ProxyStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,6 +116,8 @@ class Browser {
|
|||||||
this._terminated = true;
|
this._terminated = true;
|
||||||
removeRecursive(this._userDataDir);
|
removeRecursive(this._userDataDir);
|
||||||
});
|
});
|
||||||
|
this._chromeProcess.stderr.pipe(this.stderr);
|
||||||
|
this._chromeProcess.stdout.pipe(this.stdout);
|
||||||
|
|
||||||
await waitForChromeResponsive(this._remoteDebuggingPort, () => !this._terminated);
|
await waitForChromeResponsive(this._remoteDebuggingPort, () => !this._terminated);
|
||||||
if (this._terminated)
|
if (this._terminated)
|
||||||
@ -153,3 +159,11 @@ function waitForChromeResponsive(remoteDebuggingPort, shouldWaitCallback) {
|
|||||||
req.end();
|
req.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProxyStream extends Duplex {
|
||||||
|
_read(size) { }
|
||||||
|
|
||||||
|
_write(chunk, encoding, callback) {
|
||||||
|
this.push(chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user