-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow auto-resize on iframe #555
Comments
For cross-origin I suppose the embeddee would need to opt-in somehow (e.g. meta tag), to not expose new information cross-origin. |
@craigfrancis you might want to raise this on https://lists.w3.org/Archives/Public/www-style/. In theory this mostly seems like a problem with styling although if this needs to work cross-origin the problem is indeed a little bigger. |
Some discussion in www-style @annevk @mikewest do you have an opinion about using CORS to allow this for cross-origin? Or would it be better to use CSP or something else? |
CORS does not seem great since you only share the height, nothing else. CSP is about adding restrictions. I guess it would be something else. But perhaps we should first see if it gets implemented for the same-origin scenario. |
The iframe auto-resize (height) is more of a problem when it's cross origin, as on same origin you can hack this behaviour with:
It does fail when the iframes content changes (e.g. navigating to a new page), but there are ways around this:
Ideally we just want to replace all of this browser specific / buggy JavaScript with one line of CSS, the current suggestion being:
This will become even more powerful when cross origin... but as noted, CORS gives too many permissions, CSP is really to restrict access with So while I'll try to push for this to be implemented, do you have any ideas for handling this securely? |
A new header of sorts seems like the way to go. |
Thanks @annevk, I've posted it at https://lists.w3.org/Archives/Public/public-webappsec/2016Jan/0189.html |
I agree with @annevk; you need something to mitigate the kinds of leakage that this feature would expose.
|
Given that CORS is almost always safe, are we really concerned about "giving too much away"? The only case where a more restrictive header would be useful is if an intranet site wanted to expose its contents' height variation to height-variable iframes, but did not want to expose itself to the wider internet (except through a cross-origin iframe viewport). Is that enough of a use case to justify a new header? |
Well, |
@domenic: Consider a service like Disqus, which would love to use something like this (and were big advocates for |
Got it, credentials are the problem. Too bad there's no way to use CORS headers to automatically prevent credentials from being sent for cross-origin requests. |
Just to keep everything together, I've written my notes up at: https://github.com/craigfrancis/iframe-height This includes links to the different browsers feature requests. And a second thought did occur to me... we could look at a new CSS keyword for the resize property, which would be useful to automatically increase its height based on its content - another problem which requires JavaScript to solve. |
Thank you, excellent work! The resize property seems like a bad fit for this I think. It's about letting the end user resize an element, but this is not. In principle it could be defined that height: max-content "works" for textarea as well, but that should probably be a separate discussion (new thread on www-style). |
Fair point... last week I happened to be replacing some JavaScript that automatically resized a textarea (the JS turned out to be buggy), and I came across a discussion about the 'resize' property for end users (something I don't block, because I think users should be able to change this), and I was wondering if they are kind of exclusive... as in, if the textarea auto resizes, then the user won't need to resize it themselves. |
@zcorpan Any updates on this subject? |
@annevk , this question and quite a bit above is in focus of https://github.com/EPA-WG/embed-page |
Now that we have Feature Policy, I think that's the way to go about that. Similarly, there is a proposal to expose |
Content Security Policy (CSP) already has a mechanism, e.g. Note that this issue is marked "needs implementer interest." I encourage people building websites and people building third-party widgets to express their interest in this feature, as it would be a significant security improvement that would help eliminate much use of |
FWIW, w3c/csswg-drafts#1771 is probably the most significant other issue here and there should be some progress there too on a more formal definition of "contents" as I noted in a comment. |
How big of a problem is it that navigation of the |
Starting with consent, we have it both ways - The parent page will opt-in to re-sizing it's iframe via CSS And for a "first version", I'd still be happy if scrollbars appeared on navigation - as most use cases I can think of don't use navigation. That said, content can change, and while the browser would ideally change the height automatically, I recognise that it can get into some circular issues. So how about, the child page calls a method, such as It's not perfect, but the current iframe implementations currently require the child to do a In the case of third party widgets, this means it's much easier to give websites an un-safe |
The kind of use case I'm envisioning would require the use of several controls in concert. On the embedding side, at least: <iframe
src="https://my.domain.org.comments.example.com/my-url-slug"
sandbox="allow-scripts allow-top-navigation-by-user-activation"
csp="navigate-to 'none'; object-src 'none'">
</iframe> In particular, I expect the embedder would/should normally disable navigation within the frame using CSP-EE. On the embedded widget side, they'd need to opt into CSP-EE and also this iframe resizing thing. [Edited to change the CSP-EE and iframe sandbox directives]. |
I am a bit confused why the security concern is a blocker for |
I thought this proposal was for more than SVG? And it's not clear we'll keep the behavior for |
Almost 2 more years again. Any updates? |
Considering the removal of
<iframe seamless>
on issue #331.For me, the main feature of
@seamless
was the ability for theiframe
to resize based on the size of the child document (really just the height), so no scroll bars would appear.Currently this is "solved" with the use of some very messy JavaScript:
http://stackoverflow.com/search?q=resize+iframe
Which is more difficult cross-origin, which needs postMessage and custom JS running on every single page (both child and parent).
The suggestion of Shadow-DOM is interesting, but I don't believe this provides the same level of protection (and backwards compatibility), as often the child content is put in an iframe to keep it isolated from the current page (i.e. for security reasons).
Typically I put things in an iframe because they could easily be malicious, and I would really like to use a
sandbox
to blockallow-scripts
.The text was updated successfully, but these errors were encountered: