feat(page): add page.isClosed method (#2588)

Fixes #2501.
This commit is contained in:
Alex Veligura
2018-05-26 02:53:57 +03:00
committed by Andrey Lushnikov
parent b522ecaa65
commit 32f4c173c8
3 changed files with 25 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ class Page extends EventEmitter {
*/
constructor(client, target, frameTree, ignoreHTTPSErrors, screenshotTaskQueue) {
super();
this._closed = false;
this._client = client;
this._target = target;
this._keyboard = new Keyboard(client);
@@ -131,7 +132,10 @@ class Page extends EventEmitter {
client.on('Inspector.targetCrashed', event => this._onTargetCrashed());
client.on('Performance.metrics', event => this._emitMetrics(event));
client.on('Log.entryAdded', event => this._onLogEntryAdded(this._client, event));
this._target._isClosedPromise.then(() => this.emit(Page.Events.Close));
this._target._isClosedPromise.then(() => {
this.emit(Page.Events.Close);
this._closed = true;
});
}
/**
@@ -876,6 +880,13 @@ class Page extends EventEmitter {
}
}
/**
* @return {boolean}
*/
isClosed() {
return this._closed;
}
/**
* @return {!Mouse}
*/