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

Same origin <iframe> rendering #6

Open
rsify opened this issue Apr 14, 2020 · 2 comments
Open

Same origin <iframe> rendering #6

rsify opened this issue Apr 14, 2020 · 2 comments
Labels
priority 2 research Further research is required

Comments

@rsify
Copy link
Owner

rsify commented Apr 14, 2020

Some apps with micro frontends utilize tons of <iframe> elements to render out their UI.

This is yet to be tested, but as far as I know trying to embed any <iframe> into the exported image will result in a transparent box in place of its contents.

Possible solution would be either to clone the frame via contentWindow/contentDocument or we'd need to make users load a helper library inside the frame and communicate with it via iframe.postMessage.

@rsify rsify added priority 1 research Further research is required labels Apr 14, 2020
@rsify
Copy link
Owner Author

rsify commented May 28, 2020

Real world example: text editor in https://collabuml.com.

@pauldijou
Copy link

I tried to use Pico and ran into that issue (our whole app is running inside an iframe during development for some... valid reasons). So using Pico would only screenshot all the devtools we have around the iframe and not the app itself inside it.

I wanted to only screenshot the iframe itself next, since that's what I actually care about, doing something like:

pico.objectURL(document.querySelector("#myIframe").contentWindow).then(url => {})

But this crashed due to getWindowInfo checking the instanceof compared to the global ones. Can be solved by doing:

	if (!($html instanceof $window.HTMLHtmlElement)) {
		return left(err('Failed to get HTMLHtmlElement'))
	}

	if (!($body instanceof $window.HTMLBodyElement)) {
		return left(err('Failed to get HTMLBodyElement'))
	}

(there is a Typescript error but that's actually valid)

This will now screenshot the content of the iframe but without the correct rendering. Seems like most CSS (if not all) is missing.

That's how far I could go :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority 2 research Further research is required
Projects
None yet
Development

No branches or pull requests

2 participants