javascript setAttribute iframe allowfullscreen doesn't work
Reported by
peterejk...@gmail.com,
Jun 15 2018
|
||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 Steps to reproduce the problem: I have a map in an iframe (Chrome 67.0.3396.87). E.g. <iframe height="480px" src="http://brunob.github.io/leaflet.fullscreen/" width="450px"> </iframe> The CMS we use strips out the allowfullscreen attribute from the iframe, so I'm trying to inject them back in using Javascript. document.getElementsByTagName("iframe")[0].getAttribute("src") == "http://brunob.github.io/leaflet.fullscreen/" ? document.getElementsByTagName("iframe")[0].setAttribute("allowFullScreen", ""):null; What is the expected behavior? The allowfullscreen attribute will allow the map to go full screen. It does in IE 11 and Firefox 60.0.1 What went wrong? The javascript changes the DOM, but the fullscreen button still doesn't work. However, if you start with the iframe and allowfullscreen set, then it does work. <iframe height="480px" src="http://brunob.github.io/leaflet.fullscreen/" width="450px" allowfullscreen> </iframe> Did this work before? N/A Chrome version: 67.0.3396.87 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Shockwave Flash 30.0 r0 see also: https://stackoverflow.com/questions/50875766/javascript-setattribute-iframe-allowfullscreen-doesnt-work-in-chrome
,
Jun 15 2018
This functionality is different from IE and Firefox. Is there a workaround here?
,
Jun 15 2018
You need to set the attribute before the iframe starts loading, otherwise you'll have to reload the iframe contents. Chrome implements this spec: https://wicg.github.io/feature-policy/#integration-with-html The allowfullscreen attribute is a boolean attribute. When specified, it indicates that Document objects in the iframe element’s browsing context should be initialized with a feature policy which allows the fullscreen feature to be used from any origin It's not clear to me whether the spec explicitly disallows dynamic changing of this attribute. And if it does, why. From a layman's point of view, I'd say the embedder page has every right to change this attribute dynamically on an already loaded iframe. It'd be helpful if iclelland@ could clarify this.
,
Jun 15 2018
+iclelland@ to clarify, but I also think that this was an intentional change and you're seeing expected behavior. It also matches how the "sandbox" attribute and "allow" feature policy attribute work. For the allowfullscreen to take effect, you need to navigate the iframe (e.g., set the src to something else) after changing allowfullscreen.
,
Jun 15 2018
Yes, this is an intentional change to the platform to align with "sandbox" and "allow", and the existing "allowusermedia" and "allowpaymentrequest" attributes. The embedder certainly can change the attribute, but like sandbox, the result doesn't take effect until the frame navigates. As part of feature policy, one of the goals is for sites to have a consistent set of available features, which doesn't change over the lifetime of the document. The original intent thread on blink-dev for this is here: https://groups.google.com/a/chromium.org/d/msg/blink-dev/UKChYGBYvSk/dXXdHGyhBwAJ
,
Jun 17 2018
,
Jun 20 2018
iclelland@ Thanks for the update. As per comment #5, as this is an intentional change, can we close this issue? Thanks..
,
Jun 21 2018
As per comment #7 adding Needs-Feedback to it. Thanks.!
,
Jun 21 2018
Ian, I think we can close this as WAI. Please comment/confirm.
,
Jun 21 2018
Yes, this is WAI. The HTML spec is being updated with this behaviour, and I'm going to be filing browser bugs at that point for the other engines. The workaround is generally going to be to grant fullscreen access to the page before loading it, or to reload the frame after adding the attribute. (If you control the destination page, you can even have it stash any local state and reload itself once the container attribute has been updated)
,
Jun 21 2018
WontFixing per #10. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by woxxom@gmail.com
, Jun 15 2018