Bug 133887 - DOM event listener for DOMContentLoaded is called when a contextmenu event is dispatched on document
Summary: DOM event listener for DOMContentLoaded is called when a contextmenu event is...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-10 23:35 UTC by Fredrik Johansson
Modified: 2008-04-24 20:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
testcase that demoes this (688 bytes, text/html)
2006-09-10 23:36 UTC, Fredrik Johansson
Details
patch. Support for non-standard "DOMContentLoaded" event (1.76 KB, patch)
2007-11-12 23:49 UTC, Germain Garand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fredrik Johansson 2006-09-10 23:35:11 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          g++4.0.3 Kubuntu dapper x86_64 
OS:                Linux

When doing addEventListener("DOMContentLoaded", callback, null);

callback should never be called, as khtml doesnt support this *nonstandard* event.

But if you create another unsupported event like contextmenu event and dispatch it on document it calls the DOMContentLoaded callback.
Comment 1 Fredrik Johansson 2006-09-10 23:36:25 UTC
Created attachment 17696 [details]
testcase that demoes this
Comment 2 Maksim Orlovich 2006-09-11 01:00:19 UTC
Doh, makes sense. We just do fixed name -> id mapping (see EventImpl::typeToId, EventImpl::idToType), while I guess we need to add a dictionary for non-standard stuff, and not just map it to UNKNOWN internally. 

Any website we mess up on due to this?

[And I bet we'll be forced to support DOMContentLoaded at some point...)


Comment 3 Fredrik Johansson 2006-09-11 06:37:50 UTC
>Any website we mess up on due to this? 
 
I found it when bug fixing http://archive.dojotoolkit.org/dojo-2006-09-10/tests/widget/test_Tooltip.html

Dont know if it actually affects a live website somewhere, but odds are we do.

(I posted it here so it wont be forgotten, while I read up on C++ and try to get up to speed on bug fixing khtml and my commit privs..)

>[And I bet we'll be forced to support DOMContentLoaded at some point...)

Yes it would be nice, perhaps for KDE4?
/ Fredrik
Comment 4 Germain Garand 2007-11-12 23:48:12 UTC
Maksim, do you think it's OK to support DOMContentLoaded right now?
It seems at this point all other browsers (not necessarily stable version)
have some sort of early callback mechanism.

I have the patch ready if you will. 
Will attach here since if not really related, it would in effect fix the symptoms of this bug.
Comment 5 Germain Garand 2007-11-12 23:49:24 UTC
Created attachment 22041 [details]
patch. Support for non-standard "DOMContentLoaded" event
Comment 6 Maksim Orlovich 2007-11-13 00:11:46 UTC
I think it's not only OK but a good idea, assuming you figured out the right place to emit it. Since we may emit load event in the same spot, it's probably safe.. See also #137428
Comment 7 Germain Garand 2007-11-13 00:47:36 UTC
from the descriptions I've read, it's quite plain, it must just fire right after parsing, not waiting for any delayed content, so it's the best spot I can think of.

I have these passing:
http://weston.ruter.net/projects/pre-onload/?loadimage
http://tests.novemberborn.net/browsers/domcontentloaded/domcontentloaded.html
http://tests.novemberborn.net/browsers/domcontentloaded/readstyle-domcontentloaded.html

> See also #137428 

indeed, and yes, it appears to work fine with the patch
Comment 8 Germain Garand 2007-11-14 07:04:54 UTC
SVN commit 736409 by ggarand:

support non-standard Mozilla event DOMContentLoaded for
compatibility.
It fires as soon as the main document has finished parsing.

CCBUG: 133887
BUG: 137428


 M  +1 -0      khtml_part.cpp  
 M  +4 -0      xml/dom2_eventsimpl.cpp  
 M  +2 -1      xml/dom2_eventsimpl.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=736409
Comment 9 Mark Wubben 2007-12-04 19:07:18 UTC
Funny how I go look for DOMContentLoaded support in Konqueror, and I find a link back to my own test case :) I'm not fully up to speed on Konqueror release schedules, will this be in 3.5.9 / 3.6?
Comment 10 Maksim Orlovich 2007-12-04 19:11:11 UTC
It's inside 4.0-pre sources now... Probably not too much effort to include into 3.5.9 if that release were to take place.. 
Comment 11 Maksim Orlovich 2008-04-24 20:04:52 UTC
SVN commit 800710 by orlovich:

Fix handling of events with custom names, while proving some infrastructure
that is likely to be useful along the line..

That piece is the IDString template which simplies string<->ID mapping
when a chunk of IDs is pre-allocated, could potentially be used for
ID_ and ATTR_ as well

BUG:133887


 M  +2 -1      CMakeLists.txt  
 M  +5 -5      dom/dom_node.cpp  
 M  +2 -2      ecma/kjs_dom.cpp  
 M  +2 -2      ecma/kjs_window.cpp  
 M  +50 -179   xml/dom2_eventsimpl.cpp  
 M  +54 -50    xml/dom2_eventsimpl.h  
 M  +18 -8     xml/dom_docimpl.cpp  
 M  +10 -5     xml/dom_docimpl.h  
 M  +40 -33    xml/dom_nodeimpl.cpp  
 M  +24 -21    xml/dom_nodeimpl.h  
 M  +50 -1     xml/dom_stringimpl.cpp  
 M  +3 -0      xml/dom_stringimpl.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=800710
Comment 12 Maksim Orlovich 2008-04-24 20:15:43 UTC
SVN commit 800719 by orlovich:

Add regression test for #133887
CCBUG:133887


 A             baseline/events/custom-listeners.html-dom  
 AM            baseline/events/custom-listeners.html-dump.png  
 A             baseline/events/custom-listeners.html-render  
 A             tests/events/custom-listeners.html  


WebSVN link: http://websvn.kde.org/?view=rev&revision=800719