mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(browser): add browser.disconnected event (#960)
This patch adds a 'disconnected' event for the browser. The event is issued when the "browser" loses connection to the chrome process. References #952
This commit is contained in:
committed by
Andrey Lushnikov
parent
88ba52a363
commit
03fefb53f8
@@ -75,6 +75,13 @@ class Connection extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function()} callback
|
||||
*/
|
||||
setClosedCallback(callback) {
|
||||
this._closeCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
*/
|
||||
@@ -108,6 +115,10 @@ class Connection extends EventEmitter {
|
||||
}
|
||||
|
||||
_onClose() {
|
||||
if (this._closeCallback) {
|
||||
this._closeCallback();
|
||||
this._closeCallback = null;
|
||||
}
|
||||
this._ws.removeAllListeners();
|
||||
for (const callback of this._callbacks.values())
|
||||
callback.reject(new Error(`Protocol error (${callback.method}): Target closed.`));
|
||||
|
||||
Reference in New Issue
Block a user