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

[Feature]: Expose Frame for JSHandle (and ElementHandle) #8882

Closed
stevenwdv opened this issue Sep 1, 2022 · 3 comments
Closed

[Feature]: Expose Frame for JSHandle (and ElementHandle) #8882

stevenwdv opened this issue Sep 1, 2022 · 3 comments

Comments

@stevenwdv
Copy link

JSHandle#executionContext() was removed in v17, but with it also the ability to get the Frame or Page from a handle was removed. Previously one could use handle.executionContext().frame(), but now there is no way to get the Frame anymore. I would propose adding a JSHandle#frame() method to get the Frame from an element.

Note: ElementHandle#contentFrame() is for <iframe>s, this does not return the Frame that an element is on or a JSHandle is part of.

@OrKoN
Copy link
Collaborator

OrKoN commented Sep 1, 2022

@stevenwdv do you mean this #8875? Note that the getter is on the ElementHandle at runtime but was not exported via types until that PR.

@stevenwdv
Copy link
Author

@OrKoN Ah, hadn't seen that. Yes that would cover my current needs, although I wonder what the reason is for not exposing it for all JSHandles?

stevenwdv added a commit to stevenwdv/leak-detect that referenced this issue Sep 1, 2022
…nge puppeteer imports to `import type` to make sure we use TRCs puppeteer version for actual calls
@OrKoN
Copy link
Collaborator

OrKoN commented Sep 1, 2022

@stevenwdv JSHandles could come from service workers or workers and, thus, might not have a frame associated with them. In general, if you have a JS handle you should be able to do :

  const handle = await page.evaluateHandle(() => 1 + 2);
  console.log((await handle.evaluateHandle(() => document.body)).frame);

to see if JSHandle's context has DOM and has a frame. I guess the issue is then resolved? Let me know if there are additional use cases we overlooked.

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants