mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(Page): teach Page.setContent to wait for resources to load (#1152)
This patch adds "options" parameter to the `page.setContent` method. The parameter is the same as a navigation parameter and allows to specify maximum timeout to wait for resources to be loaded, as well as to describe events that should be emitted before the setContent operation would be considered successful. Fixes #728.
This commit is contained in:
16
lib/Page.js
16
lib/Page.js
@@ -437,13 +437,17 @@ class Page extends EventEmitter {
|
||||
|
||||
/**
|
||||
* @param {string} html
|
||||
* @param {!Object=} options
|
||||
*/
|
||||
async setContent(html) {
|
||||
await this.evaluate(html => {
|
||||
document.open();
|
||||
document.write(html);
|
||||
document.close();
|
||||
}, html);
|
||||
async setContent(html, options) {
|
||||
await Promise.all([
|
||||
this.evaluate(html => {
|
||||
document.open();
|
||||
document.write(html);
|
||||
document.close();
|
||||
}, html),
|
||||
this.waitForNavigation(options),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user