Skip to content
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

page.waitForFunction fails because of whitespace #3723

Closed
fringd opened this issue Jan 3, 2019 · 4 comments
Closed

page.waitForFunction fails because of whitespace #3723

fringd opened this issue Jan 3, 2019 · 4 comments
Labels
bug chromium Issues with Puppeteer-Chromium

Comments

@fringd
Copy link
Contributor

fringd commented Jan 3, 2019

Steps to reproduce

await page.waitForFunction(`
  (() => true)()`);

never returns, but

await page.waitForFunction(`(() => true)()`);

does. I expect them both to return immediately.

Tell us about your environment:

  • Puppeteer version: 1.11.0
  • Platform / OS version: MacOS
  • URLs (if applicable):
  • Node.js version: 8.9.1
@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jan 3, 2019

It seems this is due to automatic semicolon insertion (i.e. undefined is returned) in this fragment:

https://github.com/GoogleChrome/puppeteer/blob/3d82465f667f0585ae8cb3dbb45ebe76bbc80ec7/lib/FrameManager.js#L980

cc @aslushnikov

@fringd
Copy link
Contributor Author

fringd commented Jan 3, 2019

this behavior is different than page.evaluate, which was rather suprising.

@fringd
Copy link
Contributor Author

fringd commented Jan 3, 2019

Maybe just adding parentheses would fix it? like this:

this._predicateBody = helper.isString(predicateBody) ? 'return (' + predicateBody + ')': 'return (' + predicateBody + ')(...args)'; 

@fringd fringd closed this as completed Jan 3, 2019
@fringd
Copy link
Contributor Author

fringd commented Jan 3, 2019

sorry didn't mean to close.

@fringd fringd reopened this Jan 3, 2019
fringd added a commit to fringd/puppeteer that referenced this issue Jan 4, 2019
@aslushnikov aslushnikov added bug chromium Issues with Puppeteer-Chromium labels Jan 10, 2019
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jan 11, 2019
aslushnikov added a commit that referenced this issue Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium
Projects
None yet
Development

No branches or pull requests

3 participants