diff --git a/lib/Browser.js b/lib/Browser.js index f5a1a30f..c4115b42 100644 --- a/lib/Browser.js +++ b/lib/Browser.js @@ -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,17 @@ function waitForChromeResponsive(remoteDebuggingPort, shouldWaitCallback) { req.end(); } } + +class ProxyStream extends Duplex { + _read() { } + + /** + * @param {?} chunk + * @param {string} encoding + * @param {function()} callback + */ + _write(chunk, encoding, callback) { + this.push(chunk, encoding); + callback(); + } +}