Bug 250072 - Resize event on iframe fired before rAF on parent document
Summary: Resize event on iframe fired before rAF on parent document
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2023-01-04 03:44 PST by Rune Lillesveen
Modified: 2023-03-22 14:56 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rune Lillesveen 2023-01-04 03:44:45 PST
In the case below the rAF on the parent document should be handled before the iframe re-layout is done, which means the resize event handler should be run after the parent document rAF handler. Safari outputs the "resize" before the "rAF":

<!doctype html>
<iframe id="frm" width="100"></iframe>
<script>
  setTimeout(() => {
    frm.contentWindow.addEventListener('resize', () => console.log("resize"));
    requestAnimationFrame(() => console.log("rAF"));
    frm.style.width = '200px';
  }, 1000);
</script>

Found this while looking at failures in Chrome for: http://wpt.live/css/mediaqueries/media-query-matches-in-iframe.html

Some of the expectations there seem wrong.
Comment 1 Radar WebKit Bug Importer 2023-01-04 16:55:04 PST
<rdar://problem/103893924>
Comment 2 Simon Fraser (smfr) 2023-01-04 20:08:45 PST
https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model says that the resize (step 7) happens before the animation frame callbacks (step 13).
Comment 3 Rune Lillesveen 2023-01-09 04:45:26 PST
> https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model says that the resize (step 7) happens before the animation frame callbacks (step 13).

Yes, but the resize of the iframe is a result of the layout of the top document that happens after the first rAF callback. The resize event should then trigger before the next rAF, IIUC?
Comment 4 Ryosuke Niwa 2023-03-22 14:56:28 PDT
(In reply to Rune Lillesveen from comment #3)
> > https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model says that the resize (step 7) happens before the animation frame callbacks (step 13).
> 
> Yes, but the resize of the iframe is a result of the layout of the top
> document that happens after the first rAF callback. The resize event should
> then trigger before the next rAF, IIUC?

I don't see how the spec reads that way. Fundamentally, spec basically assumes that the resize happens immediately once the width is set, not when rAF happens.