Bug 3609

Summary: onload event never called for iframe element with empty or about:blank src
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: VERIFIED FIXED    
Severity: Normal CC: ap, darin, gavin.sharp
Priority: P2    
Version: 412   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
Test case
none
Handy in-browser test case
none
patch for an existing test case
darin: review+
Handy in-browser test case (no race condition) none

Description David Kilzer (:ddkilzer) 2005-06-18 21:24:38 PDT
Summary: 

The onload event of an iframe element is never called, even after the content of the iframe element has 
been loaded.

Steps to Reproduce: 

See attached test case.

Expected Results: 

The onload event of the iframe element is called if it exists.

Actual Results: 

The onload event of the iframe element is never called.

Regression: 

N/A

Notes: 

N/A
Comment 1 David Kilzer (:ddkilzer) 2005-06-18 21:26:46 PDT
As originally noted in this message to webkit-dev:

http://www.opendarwin.org/pipermail/webkit-dev/2005-June/000125.html

I also found this bug on W3C's Bugzilla site that provides a work-around:

http://www.w3.org/Bugs/Public/show_bug.cgi?id=228
Comment 2 David Kilzer (:ddkilzer) 2005-06-18 21:41:28 PDT
Created attachment 2469 [details]
Test case

Test case which currently breaks (as it should since this issue hasn't been
fixed).
Comment 3 David Kilzer (:ddkilzer) 2005-06-18 21:45:17 PDT
Regarding Comment 1, the W3C Bugzilla bug provides a workaround in their JavaScript (ECMAScript) test 
suite, which uses JSUnit.  Fixing this bug may also make JSUnit work better with Safari.

http://www.edwardh.com/jsunit/
Comment 4 David Kilzer (:ddkilzer) 2005-06-18 21:47:10 PDT
Created attachment 2470 [details]
Handy in-browser test case

The text on the screen should change to "IFrame OnLoad Event Called" when the
test page is loaded, but doesn't.
Comment 5 Eric Seidel (no email) 2005-12-28 22:21:07 PST
I just ran into this today.  This is really annoying... :(
Comment 6 Eric Seidel (no email) 2005-12-28 22:32:03 PST
Part of what might make this hard, is that currently sometimes the RenderTree does the loading, and 
sometimes the DOMTree does the loading for <object> tags.  Although I'm still not familiar enough with 
how onload events work to know.

HTMLObjectElementImpl::parseMappedAttribute() definitely creates an onload event listener if specified.  
I'm not sure how that onload event listener is supposed to be fired however.

It looks like Image onload events are special cased.  Those seem to be the only ones we support other 
than <body> onload event listeners.

SVG will need generic onload handing as well.
Comment 7 Geoffrey Garen 2005-12-31 10:18:57 PST
I suspect the same bug applies to onunload, onbeforeunload, etc.
Comment 8 Alexey Proskuryakov 2006-02-09 14:13:29 PST
This problem has been fixed very recently (between revisions r12598 and r12724). I'm not closing this bug yet, because:
1) according to comment 7, investigation of onunload/onbeforeunload/etc behavior may be needed;
2) if the fix was an unintentional side effect, landing an additional test case for this would be highly desirable.

Please note that the attached test case still fails because of bug 7161 - but the onload handler now gets actually called (you can add an alert() to verify).
Comment 9 Alexey Proskuryakov 2006-02-11 11:18:48 PST
Created attachment 6414 [details]
patch for an existing test case

This was fixed intentionally in r12638 - this bug was mentioned in the log entry, and a test was included. There is a small typo in the test; the attached patch fixes it.

Apparently, onunload and onbeforeunload are not supposed to work (they don't in WinIE, Firefox and Opera).
Comment 10 Darin Adler 2006-02-11 15:20:33 PST
Comment on attachment 6414 [details]
patch for an existing test case

Oops! r=me
Comment 11 David Kilzer (:ddkilzer) 2006-02-25 05:30:18 PST
Created attachment 6728 [details]
Handy in-browser test case (no race condition)
Comment 12 David Kilzer (:ddkilzer) 2006-02-25 05:30:58 PST
Verified bug is fixed.