Bug 113245 - [test case]dispatchEvent on TextEvents doesnt seem to work
Summary: [test case]dispatchEvent on TextEvents doesnt seem to work
Status: RESOLVED DUPLICATE of bug 120408
Alias: None
Product: konqueror
Classification: Applications
Component: khtml event (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-24 21:47 UTC by Fredrik Johansson
Modified: 2006-01-21 20:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Test case attached (3.08 KB, text/html)
2005-09-25 14:30 UTC, Tommi Tervo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fredrik Johansson 2005-09-24 21:47:33 UTC
Version:           3.4.91 (using KDE 3.4.91 (beta1, >= 20050910), Kubuntu Package 4:3.4.91-0ubuntu0hoary1 )
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-8ubuntu2)
OS:                Linux (i686) release 2.6.10-5-386

I am trying to create a input field that forces uppercase, so I have tried changeing event.charCode, event.keyCode, event.shiftKey etc but as it says in documentation for khtml 3.4 these are constants and I Cant change them.

Next try was to stop the event and create a new one with the correct keydown.
However I can create a UIEvent, TextEvent and I can run initUIEvent and initTextEvent.
But I cant dispatch them to my input node.

Maybe I am doing something wrong, but If I am shouldnt I get a error then?

I have tried in kde 3.4.2 and 3.5 beta
Comment 1 Fredrik Johansson 2005-09-24 21:49:17 UTC
I wrote a testpage for you.
<html>
<script language="javascript">
 function testkey () 
 {
  var e = window.event;

  // clear debug info
  debug("<h1>"+e.type+"</h1>", true);
  
  var obj = {};
  for (ev in e) {
   obj[ev]= e[ev];
  }
  
//   window.event.preventDefault();
//   window.event.stopPropagation();


  var txtev = document.createEvent("TextEvents");
  txtev.initTextEvent("keydown",true, true, document.defaultView, 1, "A",97,0,true);//, 97, 0, true, false);

  /*void TextEvent::initTextEvent   (   const DOMString &   typeArg, 
   bool   canBubbleArg, 
   bool   cancelableArg, 
   const AbstractView &   viewArg, 
   long   detailArg, 
   const DOMString &   outputStringArg, 
   unsigned long   keyValArg, 
   unsigned long   virtKeyValArg, 
   bool   inputGeneratedArg, 
   bool   numPadArg
   ) */

  
  debug("<br/><b>name: pageevent &nbsp; &nbsp; createev.</b><br/>");
  for (o in obj) {
   debug (o+':'+obj[o]+'   '+ txtev[o] + '<br/>');
  };
  txtev.srcElement = document.getElementById("fill");
  //document.getElementById("test").dispatchEvent(txtev);


  /**
  * never gets dispatched?! what am I doing wrong
  */
  document.getElementById("fill").dispatchEvent(txtev);
  //document.getElementById("test").dispatchEvent(txtev); 

  debug('<br/>after dispatchEvent');
 };

 function testmouse (crashme) 
 { // borrowed from http://www.opendarwin.org/pipermail/webkit-changes/2005-August/000564.html
  var e = window.event;

  // clear debuginfo
  debug("<h1>"+e.type+"</h1>", true);

  var ev = document.createEvent("MouseEvents");  // need to add s
  var view = document.defaultView;
  if (typeof crashme !='undefined') {
   view = null;
  }

  ev.initMouseEvent("click", true, true, view, 1, 1, 1, 1, 1, false, false, false, false, 0, document);

  if (view==null) {
   debug("Successfully created a mouse event object without a view and didn't crash.");
  };


  // for some reason we cant iterate through these if we want dispatchEvent to work
  /*
  for (ev in e) {
   debug(ev+": "+e[ev]+"<br/>");
  };
  */

  document.getElementById("divclicked").dispatchEvent(ev);
  
 };

 function debug (str, clear) 
 {
  if (arguments.length>1) { // we should clear debug info
   document.getElementById("debug").innerHTML = "";
  };
  var tmp = document.createElement("span");
  tmp.innerHTML = str;
  document.getElementById("debug").appendChild(tmp);
 };
</script>
<style type="text/css">
 div#divclicked { 
  color: blue;
  font-weight: bold;
  cursor: hand;
 }
</style>
<body>
 <input type="button" onclick="testmouse()" value="Create mouseevent"/><br/>
 <input type="button" onclick="testmouse(true)" value="Crash me" /><br/>
 <input type="text" id="test" onkeydown="testkey()" /> Every keydown in here should print "A" in input below, least thats what I'm hopeing for
 <br>
 <input type="text" id="fill" />
 <div id="divclicked" onclick="alert('You have clicked on alert div with button '+window.event.button)" >alertdiv</div>
 <span id="debug"></span>
</body>
</html>
Comment 2 Tommi Tervo 2005-09-25 14:30:59 UTC
Created attachment 12698 [details]
Test case attached
Comment 3 Maksim Orlovich 2006-01-21 20:11:50 UTC

*** This bug has been marked as a duplicate of 120408 ***