mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
parent
b522ecaa65
commit
32f4c173c8
@ -97,6 +97,7 @@
|
|||||||
* [page.goForward(options)](#pagegoforwardoptions)
|
* [page.goForward(options)](#pagegoforwardoptions)
|
||||||
* [page.goto(url, options)](#pagegotourl-options)
|
* [page.goto(url, options)](#pagegotourl-options)
|
||||||
* [page.hover(selector)](#pagehoverselector)
|
* [page.hover(selector)](#pagehoverselector)
|
||||||
|
* [page.isClosed()](#pageisclosed)
|
||||||
* [page.keyboard](#pagekeyboard)
|
* [page.keyboard](#pagekeyboard)
|
||||||
* [page.mainFrame()](#pagemainframe)
|
* [page.mainFrame()](#pagemainframe)
|
||||||
* [page.metrics()](#pagemetrics)
|
* [page.metrics()](#pagemetrics)
|
||||||
@ -1180,6 +1181,12 @@ If there's no element matching `selector`, the method throws an error.
|
|||||||
|
|
||||||
Shortcut for [page.mainFrame().hover(selector)](#framehoverselector).
|
Shortcut for [page.mainFrame().hover(selector)](#framehoverselector).
|
||||||
|
|
||||||
|
#### page.isClosed()
|
||||||
|
|
||||||
|
- returns: boolean
|
||||||
|
|
||||||
|
Indicates that the page has been closed.
|
||||||
|
|
||||||
#### page.keyboard
|
#### page.keyboard
|
||||||
|
|
||||||
- returns: <[Keyboard]>
|
- returns: <[Keyboard]>
|
||||||
|
13
lib/Page.js
13
lib/Page.js
@ -72,6 +72,7 @@ class Page extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
constructor(client, target, frameTree, ignoreHTTPSErrors, screenshotTaskQueue) {
|
constructor(client, target, frameTree, ignoreHTTPSErrors, screenshotTaskQueue) {
|
||||||
super();
|
super();
|
||||||
|
this._closed = false;
|
||||||
this._client = client;
|
this._client = client;
|
||||||
this._target = target;
|
this._target = target;
|
||||||
this._keyboard = new Keyboard(client);
|
this._keyboard = new Keyboard(client);
|
||||||
@ -131,7 +132,10 @@ class Page extends EventEmitter {
|
|||||||
client.on('Inspector.targetCrashed', event => this._onTargetCrashed());
|
client.on('Inspector.targetCrashed', event => this._onTargetCrashed());
|
||||||
client.on('Performance.metrics', event => this._emitMetrics(event));
|
client.on('Performance.metrics', event => this._emitMetrics(event));
|
||||||
client.on('Log.entryAdded', event => this._onLogEntryAdded(this._client, 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}
|
* @return {!Mouse}
|
||||||
*/
|
*/
|
||||||
|
@ -54,6 +54,12 @@ module.exports.addTests = function({testRunner, expect, puppeteer, DeviceDescrip
|
|||||||
dialog.accept();
|
dialog.accept();
|
||||||
await waitEvent(newPage, 'close');
|
await waitEvent(newPage, 'close');
|
||||||
});
|
});
|
||||||
|
it('should set the page close state', async({ browser }) => {
|
||||||
|
const newPage = await browser.newPage();
|
||||||
|
expect(newPage.isClosed()).toBe(false);
|
||||||
|
await newPage.close();
|
||||||
|
expect(newPage.isClosed()).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Page.Events.error', function() {
|
describe('Page.Events.error', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user