puppeteer / puppeteer

JavaScript API for Chrome and Firefox
https://pptr.dev
Apache License 2.0
88.93k stars 9.09k forks source link

[Feature]: Map chrome extension frame into puppeeter frame #13281

Open zibsonzs opened 2 weeks ago

zibsonzs commented 2 weeks ago

Feature description

I don't think there is an easy way to find puppeter frame by chrome extension frame. Example: const currentChromeFrame = await chrome.webNavigation.getFrame({ tabId, frameId }); const puppeterFrame = page.frames().find((x) => x.url() === currentChromeFrame.url);

This is an example to find it by url, but what if we have multiple iframes with the same url? Is there a way to map it by id? FrameId in chrome frame is a number in the format of 1234, whereas puppeeter is a string.

OrKoN commented 1 week ago

So CDP operates on a lower level (e.g., CDP still works if a browser implementation does not ship with extensions like chrome-headless-shell) and has its own identifiers. I think it's fairly unlikely that those will be aligned but it might be possible that we implement some sort of lookup mechanism via the extensions domain in the future https://chromedevtools.github.io/devtools-protocol/tot/Extensions/.