-
Notifications
You must be signed in to change notification settings - Fork 9.3k
feat: JSHandles as argument for waitFor and return the success value #1712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7b093dd to
814126c
Compare
| * @param {number} timeout | ||
| */ | ||
| constructor(frame, predicateBody, polling, timeout) { | ||
| constructor(frame, predicateBody, polling, timeout, ...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing jsdoc for args
lib/FrameManager.js
Outdated
| return await pollInterval(polling); | ||
|
|
||
| /** | ||
| * @return {!Promise} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@return {!Promise<*>}
lib/FrameManager.js
Outdated
| if (polling === 'raf') | ||
| await pollRaf(); | ||
| return await pollRaf(); | ||
| else if (polling === 'mutation') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: drop elses
lib/FrameManager.js
Outdated
|
|
||
| if (this._terminated || runCount !== this._runCount) | ||
| if (this._terminated || runCount !== this._runCount) { | ||
| success && await success.dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (success)
..
lib/FrameManager.js
Outdated
| const polling = options.polling || 'raf'; | ||
| const predicateCode = 'return ' + helper.evaluationString(pageFunction, ...args); | ||
| return new WaitTask(this, predicateCode, polling, timeout).promise; | ||
| if (helper.isString(pageFunction)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this to the waitTask
This patch: - teaches page.waitFor* methods to accept JSHandles - starts returning JSHandles from page.waitFor* calls. BREAKING CHANGE: this patch starts allocating `JSHandle`/`ElementHandle` instances for every call to `page.waitFor*` functions. These handles should be disposed manually to avoid memory consumption. Fixes puppeteer#1703, fixes puppeteer#1654, fixes puppeteer#1724.
#1703
#1654