Bug 57913 - window.addEventListener("load", ...) and document.addEventListener("load", ...) do not work
Summary: window.addEventListener("load", ...) and document.addEventListener("load", .....
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-30 20:29 UTC by Jesse Pelton
Modified: 2004-12-29 01:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
test case (2.28 KB, text/html)
2003-04-30 20:30 UTC, Jesse Pelton
Details
Testcase for window.addEventListener, similar to the one above (1.79 KB, text/html)
2003-10-10 12:40 UTC, Stefan Raubal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Pelton 2003-04-30 20:29:15 UTC
Version:            (using KDE KDE 3.1.1)
Installed from:    Unlisted Binary Package
OS:          Linux

Summary: Konqueror fails to fire document and window load events established with addEventListener().

Demonstration: Load the attached page. It has two load event handlers for the window and two for the document.  For each object, the first handler is established with a call to addEventListener(), the second by setting the onload property. The second window event handler gets run, but the others do not.

Additional information:
- Mozilla calls the window load handlers but not the document load handlers.
- IE 6.0 does not support the DOM event model, so this test case fails.
- Opera 7.0 recognizes document.addEventListener but not window.addEventListener.

The DOM2 event spec is vague about what objects should support the load event, so it's not surprising that different browsers implement it differently.  I can deal with Mozilla's behavior (I only need one load event, and the window load event works just fine) and Opera's (because I can test for the value of window.addEventListener and use onload if it's null). Konqueror's behavior is problematic, because while window.addEventListener is a function, it doesn't have the desired effect.
Comment 1 Jesse Pelton 2003-04-30 20:30:14 UTC
Created attachment 1464 [details]
test case
Comment 2 Jesse Pelton 2003-04-30 20:52:00 UTC
Forgot to mention: I'm primarily a Windows developer, and I don't have a Linux
box to test with, so I'm running Knoppix from a CD.  I realize that this isn't
the absolutely most recent version of KDE, but it's recent (3.1.1), I've noticed
the behavior in previous releases, and I can't find any closed bugs that appear
similar.
Comment 3 Stefan Raubal 2003-10-10 12:40:29 UTC
Created attachment 2728 [details]
Testcase for window.addEventListener, similar to the one above

The current implementation of the <code>addEventListener</code> method (in
kjs_window.ccp) shows that the events are added to the <code>body</code>, which
does not exist in the <code>HEAD</code>: 
<pre>	   
01437	case Window::AddEventListener: {
01438	      JSEventListener *listener =
Window::retrieveActive(exec)->getJSEventListener(args[1]);
01439	      DOM::Document doc = part->document();
01440	      if (doc.isHTMLDocument()) {
01441		  DOM::HTMLDocument htmlDoc = doc;
01442		 
htmlDoc.body().addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));

01443	      }
01444	      else
01445		 
doc.addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));

01446	      return Undefined();
01447	  }	   
</pre>
(Remark: Testing showed that it works in Safari and Mozilla [one could argue
that it is not specified, but it would be really nice to have a unique event
implementation]!)

Stefan
Comment 4 Jesse Pelton 2004-03-17 14:19:31 UTC
Since this works in Safari (as I have confirmed), code exists somewhere to make this work as expected.  Maybe Apple needs a little nudge...?

Does anyone who voted for this bug have permission to change its status to NEW? Presumably you've encountered the same problem, so UNCONFIRMED seems inappropriate.
Comment 5 Jesse Pelton 2004-05-14 01:32:37 UTC
Still broken in 3.2.2.
Comment 6 Christophe Porteneuve 2004-09-01 12:07:57 UTC
The issue exists on Konqueror 3.3 on KDE 3.3 (Debian testing/unstable packages).

As a side note, the W3C DOM Level 2 Events spec is indeed unclear about whether it applies to window, document or both (it does apply to "object" elements, too). As per Mozilla/Opera implementation, it works on window, not document.

Either there still is this inadequate mapping to the body element (which makes no sense whatsoever, since lots of resources could be loaded from the HEAD anyway), or this is something else entirely. Note that I did not get a problem when adding listeners to other events than "load" for the window element.
Comment 7 Christophe Porteneuve 2004-09-01 12:08:43 UTC
*** This bug has been confirmed by popular vote. ***
Comment 8 Jesse Pelton 2004-09-29 02:48:37 UTC
Still broken in 3.3.
Comment 9 Richard Lärkäng 2004-10-25 01:46:52 UTC
This one seems to work in HEAD, I get 4 messageboxes for the first testcase, and 2 for the second one.
Comment 10 Allan Sandfeld 2004-10-25 13:18:59 UTC
Fixed by a recent commit by coolo
Comment 11 Jesse Pelton 2004-12-29 01:30:33 UTC
Works for me with 3.3.2.  As far as I'm concerned, this bug can be closed.