Inconsistent behavior with iframe resize events cross origin
Reported by
rassina...@gmail.com,
Aug 15 2016
|
|||||||||||
Issue description
Chrome Version : 52.0.2743.116 (Official Build) (64-bit)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
Safari: OK (Version 9.1 (11601.5.17.1))
Firefox: FAIL: (only second and third iframe fires event) (48.0)
What steps will reproduce the problem?
(1) Get first-iframe.html and iframe-holder.html code from https://gist.github.com/Rhathe/9e04aab4d3e55346ab8b6c8b55d71007
(2) Host both files locally, go to iframe-holder.html
(3) Manually change the window size and note the console logs
(4) Copy the iframe-holder.html iframe and embed on any site with a different domain
What is the expected result?
The console should log 'second-iframe resize', 'third-iframe resize', 'fourth-iframe resize', and 'fifth-iframe resize'.
What happens instead?
If all the iframes and pages are in the same domain, then it works correctly. If the iframes and the page are different domains however, only the third and fifth iframe will log a resize event.
,
Aug 16 2016
brajkumar@chromium.org - That snapshot is the expected behavior
,
Aug 18 2016
,
Aug 19 2016
Updated the gist to add a sixth-iframe. This iframe is a 10px, 100% width iframe that would normally be visible except for its -50px margin-top, which effectively puts it above the browser view. Again, when all the domains are the same the sixth-iframe resize gets logged, but if they're different then it is not logged.
,
Aug 28 2016
Thank you for providing more feedback. Adding requester "brajkumar@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 12 2016
I'm attaching the files I got from the repro for posterity since the gists may change.
Interesting bug! This is to do with resize events in iframe windows. 'resize' is part of CSSOMView, FWIW.
The next step is to debug this and work out how negative margins and cross-origin interact to stop an event being dispatched. Lots of moving parts. tkent, would you be able to take a look at this?
The iframe's contents' document client{Width,Height} properties, etc. are changing so we probably should be firing resize events. We do when same origin. When cross-origin, we don't when one of the child iframes is pushed off the screen by a negative margin. (I reproduced this in Chrome Linux 55.0.2883.75 (Official Build) (64-bit) logs 2-3-4-5 but not 6th.)
FF 50.0.2 logs 2, 3, 6 in different orders. I guess Firefox doesn't resize *hidden* iframes (but it does opacity 0 or height 0 ones.) We probably shouldn't rely on studying Firefox too closely in this case.
brajkumar, let's use "expected behavior" to describe what the product should be doing. It gets confusing when you talk about the expected behavior of the bug repro; it makes it sound like the buggy behavior is the desired behavior.
,
Dec 12 2016
This probably has to with throttling rendering in offscreen or hidden cross-origin frames. Does this test case work in Safari 10? A lot of browsers are experimenting with behavior here. Is there a site that's broken because of this? Next step here is to see what latest version of each browser does and start a discussion at https://github.com/WICG/interventions/issues/8 about what behavior we should all try to converge on.
,
Dec 12 2016
,
Dec 13 2016
I'm a little confused. If the target frame is cross-origin, then you won't be able to observe the resize event (i.e., contentWindow.addEventListener(...)) from the parent frame. Is the bug here that we're treating about:blank as cross origin?
,
Dec 16 2016
I suspect it's not a cross origin thing about:blank thing. If you look at the properties on the frames in the repro, it's experimenting with making them "invisible" various ways (negative margin, 0 height, etc.) and observing that different combinations of these suppress different events in different browsers. In Chrome's case origins also come into play. High-level, something's wrong here because FF and Chrome behave quite differently. It would be good to see what other browsers do.
,
Dec 16 2016
This is just frame throttling, we dispatch resize events inside the same system that runs rAf, which is throttled for off screen cross origin iframes. The event might even be queued there if you force a layout, it'll just not be dispatched until the next frame. This is a frame throttling system design question.
,
Dec 16 2016
Right. I'd be inclined to say this is by design, since you won't be able to do that many useful things with the resize event anyway because we'll be throttling painting while the frame is offscreen. Unlike Chrome, FF doesn't completely block offscreen rAF but instead ticks it at 1 Hz. That might explain why you're seeing the resize events there.
,
Dec 16 2016
Forgot to task: is there a (non-synthetic) example page that is broken by this?
,
Dec 30 2016
Reporter@ Could you please let us know your observations on Comment#13. Thank you.
,
Jan 19 2017
@ dominicc: Gentle ping, Can we have an update on this issue as requested in comment#13. Issue is tagged with bisect label from a long period. Thanks.!
,
Jan 19 2017
There is no longer an example page because the code changed to avoid this issue. We have a javascript widget that can either be injected directly into the DOM or used in an iframe. This widget listens to an inner iframe being resized so it can adjust accordingly. This allows the widget to not need to poll its dimensions periodically to adjust itself. Originally only the width was needed, so the iframe was given a 0 height.
,
Mar 13 2017
Cleaning up sheriffbot label "Needs-Review" label as a part of modified "Needs-Feedback" sheriffbot rule. [ref bug for cleanup 684919]
,
Jul 31 2017
There is no valid updates happened in the last few months, closing the issue. Feel free to reopen if needed. |
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by brajkumar@chromium.org
, Aug 16 2016Labels: Needs-Feedback OS-Windows
841 KB
841 KB View Download