rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.76k stars 127 forks source link

Can not access iFrames with a src attribute that has a different host. #479

Open aarondufall opened 3 months ago

aarondufall commented 3 months ago

Describe the bug

When the browser finds an iframe in the DOM, it publishes a Page.frameAttached event, then Ferrum takes the params and uses them to create a Frame object that adds to a collection of frames on the current Page object. When the src URL for the iFrame contains a URL with a different host to the parent, it fires a Page.frameDetached with reason swap . Then, a Target.targetCreated with type IFrame is published, followed by a Target.targetInfoChanged event. From what I can tell, looking at the Ferrum source code, it doesn't handle type IFrame.

In the contexts#subscribe, all the event handlers have this line, causing type IFrame to be ignored

next unless info["type"] == "page"

To Reproduce Goto a page where the iframe src attribute has a different host to the main page.

Expected behavior Access the iframe using the target id in the collection of Frame objects on the main Page object

sebyx07 commented 1 week ago

any updates on this?

sebyx07 commented 1 week ago

I tried to work on a pr, but wasn't successful

aarondufall commented 1 week ago

This issue was with the headless browser service we were using. They didn't have the same flags for Chrome that Ferrum uses by default. Once the flags were changed, this issue was solved.

The flag required for us was --disable-site-isolation-trials.