implement browser.stdout and browser.stderr

This commit is contained in:
Andrey Lushnikov 2017-07-06 21:05:38 -07:00
parent c8664319ed
commit e75f59210e

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
let {Duplex} = require('stream');
let http = require('http');
let path = require('path');
let removeRecursive = require('rimraf').sync;
@ -64,6 +65,9 @@ class Browser {
this._terminated = false;
this._chromeProcess = null;
this._launchPromise = null;
this.stderr = new ProxyStream();
this.stdout = new ProxyStream();
}
/**
@ -112,6 +116,8 @@ class Browser {
this._terminated = true;
removeRecursive(this._userDataDir);
});
this._chromeProcess.stderr.pipe(this.stderr);
this._chromeProcess.stdout.pipe(this.stdout);
await waitForChromeResponsive(this._remoteDebuggingPort, () => !this._terminated);
if (this._terminated)
@ -153,3 +159,11 @@ function waitForChromeResponsive(remoteDebuggingPort, shouldWaitCallback) {
req.end();
}
}
class ProxyStream extends Duplex {
_read(size) { }
_write(chunk, encoding, callback) {
this.push(chunk);
}
}