Summary: | Setting a frame src after appending it to the DOM makes the frame's load event be fired twice | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Timothée Pillard <tpillardpro> | ||||
Component: | Frames | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | NEW --- | ||||||
Severity: | Normal | CC: | aestes, ahmad.saleem792, ap, beidson, cdumez, jannis.rautenstrauch, rniwa, saetia, webkit-bug-importer | ||||
Priority: | P2 | Keywords: | BrowserCompat, InRadar | ||||
Version: | Safari 11 | ||||||
Hardware: | Mac | ||||||
OS: | Unspecified | ||||||
See Also: |
https://bugs.webkit.org/show_bug.cgi?id=243123 https://bugs.webkit.org/show_bug.cgi?id=245719 |
||||||
Attachments: |
|
Description
Timothée Pillard
2018-08-12 23:53:24 PDT
Quick note: Setting the `load` event handler on the iframe after appending it to the DOM fixes the problem as well. Created attachment 347527 [details]
Test case
On interesting, When an iframe is inserted into a document, it loads about:blank which in turn fires a load event. What makes WebKit and Blink's behavior different from the spec is that we synchronously fire a load event in this case. See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element When an iframe element is inserted into a document that has a browsing context, the user agent must create a new browsing context, set the element's nested browsing context to the newly-created browsing context, and then process the iframe attributes for the "first time". https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes Otherwise, if the element has no src attribute specified, and the user agent is processing the iframe's attributes for the "first time" Queue a task to run the iframe load event steps. The task source for this task is the DOM manipulation task source. My guess is that making the event load fire async won't be a Web compatible change at this point but we can try. I am able to reproduce this bug in Safari 16 / STP 153 on macOS 12.6 using attached test case and it shows two "Loaded Event" in Console compared to other browsers (Chrome Canary 107 and Firefox Nightly 106), which only shows one. Just wanted to share updated testing results. Thanks! Chromium (v117) also fires two load events. Testing v107 also shows two load events for me. Firefox only fires one load event. |