Bug 7161

Summary: <iframe src=""> load event is dispatched synchronously unlike Chrome Canary and Firefox
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, cdumez, ian, rniwa, techrazy.yang, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, HasReduction, InRadar
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
test case none

Description Alexey Proskuryakov 2006-02-09 11:30:32 PST
See the attached test case (which works as expected in Firefox and WinIE).

The document body has an element:
<p id=console>FAILURE</p>

For whatever reason, document.getElementById("console") returns null if called from an IFrame onload handler.
Comment 1 Alexey Proskuryakov 2006-02-09 11:31:07 PST
Created attachment 6367 [details]
test case
Comment 2 Alexey Proskuryakov 2006-02-09 11:45:19 PST
Starts to work if the iframe is moved below <p>.

"onclick handler" in the alert was supposed to be "onload handler", of course. It is there to indicate that the handler is called at all (didn't fire before, bug 3609).
Comment 3 Ahmad Saleem 2022-07-30 05:49:35 PDT
I am able to reproduce this bug in Safari 15.6 on macOS 12.5 using attached test case and Safari is only browser - which shows "FAILURE" while all other browsers return "SUCCESS" on this test case. I tested it in "Private Window" to avoid any cache issue as well.

Just wanted to share updated test results. Thanks!
Comment 4 Ahmad Saleem 2022-07-30 05:50:04 PDT
Other browsers which show "SUCCESS" - Chrome Canary 106 and Firefox Nightly 105. Forgot to add them.
Comment 5 Ryosuke Niwa 2022-07-30 13:36:25 PDT
Ah, this is an issue of when load event is fired. Safari is loading iframe synchronously before p element has been inserted into the document.
Comment 6 Radar WebKit Bug Importer 2022-07-30 13:43:27 PDT
<rdar://problem/97844849>
Comment 7 Ryosuke Niwa 2022-07-31 01:01:31 PDT
Hm... Chrome stable (103.0.5060.134) also fails the test. I suppose Chrome changed its behavior very recently.
Comment 8 Ahmad Saleem 2022-07-31 02:18:20 PDT
So I just tested this in Chrome Beta (104.0.5112.65) and Chrome Dev (105.0.5195.10) and both also show "FAILURE" for this test case, so indeed, it is something which got fixed in Chrome just in Canary branch.

I tried to also look for some such iframe related bugs and only came across following (This is just guess work - so ignore, if irrelevant):

-> Fixed just 19 days ago:

https://chromium.googlesource.com/chromium/src/+/cf2f72ac8431c836b7ecb92a87018ee7f3c2db64
Comment 9 Ahmad Saleem 2023-08-18 11:33:37 PDT
Is this code segment in question:

https://searchfox.org/wubkat/source/Source/WebCore/loader/PolicyChecker.cpp#259

// We ignore the response from the client for initial empty document loads and proceed with the load synchronously.