DEV Community

Discussion on: How to use Puppeteer in a Chrome extension

 
tchan profile image
Travis • Edited

From memory, passing data between content, background and popup scopes was a real pain in the ass when dealing with Chrome extensions.

I believe that's one of the limitations of puppeteer-web in general is that it opens up a new web page as it only has access to the connect api as opposed to launch which can open up a brand new tab in your original instance. It looks like the link I posted initially to the official docs is 404'd :/ but I found my initial info here.

When I was debugging popup.js, I just clicked my chrome extension next to the url bar to open up the popup.html viewport, right click -> inspect and added a breakpoint to my popup.js file. That way when the new browser instance launched via puppeteer, the popup window doesn't close. Let me know if you've already tried that, sorry I couldn't be more help.

Thread Thread
 
mattduffield profile image
Matt Duffield

Okay, so it seems like everything is working as I expected. I am using Chrome Canary for my testing and it seems to be working but the debugger tools are not behaving perfectly. I can debug though.

Thanks for following up.