Open
Bug 107048
Opened 23 years ago
Updated 2 years ago
Move event specific properties from nsEvent into the specific event classes
Categories
(Core :: DOM: Events, defect, P4)
Core
DOM: Events
Tracking
()
NEW
mozilla1.1alpha
People
(Reporter: dhtmlkitchen, Unassigned)
References
()
Details
Attachments
(1 file, 5 obsolete files)
1.09 KB,
text/html
|
Details |
From Bugzilla Helper: User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:0.9.5) Gecko/20011015 BuildID: 2001101516 using a for in loop to iterate through a domAttrModifed event. Used to work in Moz 0.9.2, but doesn't work anymore Copied the error from the terminal. Error: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js :: getProps :: line 4" data: no] Source File: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js Line: 4 Reproducible: Always Steps to Reproduce: 1. read and then follow the steps of the demo Actual Results: Error: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js :: getProps :: line 4" data: no] Source File: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js Line: 4 Expected Results: The properties of the event should be exposed. Here is the code that Moz has a problem with: showProps is the main function (see bottom). function getProps(event){ var i=0, props="<table cellpadding='1' cellspacing='1' >", ei; for(i in event){ ei= event[i]; if(typeof event[i] == "object") { ei= "<span style='font-weight: 800;color: #00f'>"+event[i]+"</span>"; } else ei= "<span style='font-weight: 800;'>"+event[i]+"</span>"; props+= "<tr><td>" +event +"." +i +" = </td><td>" +ei +"</td></tr>"; } return props+"</table>"; } function showProps(event){ var main= document.getElementById("main"); var newDiv= main.appendChild(document.createElement("div")); newDiv.className= "list" newDiv.innerHTML= getProps(event); }
Comment 2•23 years ago
|
||
Comment 3•23 years ago
|
||
There is only one problem with the code, main is not a valid node in the tree.. if you use document.body as I did in the testcase it works fine. To test click on the text in the testcase... What build are you using? It works for me on windows 98 2001-10-23-09-trunk
Reporter | ||
Comment 4•23 years ago
|
||
Reporter | ||
Comment 5•23 years ago
|
||
The test case does not use a domAttrModified event listener. When I used domAttrModified, the browser crashes.
Reporter | ||
Comment 6•23 years ago
|
||
Comment 7•23 years ago
|
||
I believe domAttrModified crashes because of recursion, which is a known issue in bug 77271...
Reporter | ||
Comment 8•23 years ago
|
||
Comment 9•23 years ago
|
||
So, do you see the bug still, for me the alert shows the properties....
Reporter | ||
Comment 10•23 years ago
|
||
Ah, The properties are displayed in the alert, but they cannot be displayed in the textarea (does not finish execution). Try changing the code in the source: function showProps(e){ //var df0= document.forms[0]; // if the showProperteis radio button is checked, // in alert (takes forever). //if(df0["show"][0].checked) alert(examineObjectProperties(e)); //else document.getElementById("traceout").value= examineObjectProperties(e); } This'll burn my processor. I have to force quit Moz. Back to the original report, I found that this file would not work in 0.9.5, but it does work in 0.9.2: http://dhtmlkitchen.com/dhtml/events/eventListener/load.html It has to do with a property (prototype) in the domAttrModified event (guess).
Comment 11•23 years ago
|
||
Comment 12•23 years ago
|
||
Again the hang/crash you are seeing is bug bug 77271 and the reason it is recursing is bug 97058 which fires domAttrModified event when text area is modified... *** This bug has been marked as a duplicate of 77271 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
Reporter | ||
Comment 13•23 years ago
|
||
Vladamir, This is NOT recursive! Read the code carefully. This is wrong: *** This bug has been marked as a duplicate of 77271 *** Recursion is when a function or method repeatedly calls upon itsself until a condition has been met. I use a control structure, a for(prop in obj) loop, NOT recursion. Again, read the code before jumping to conclusions. Garrett
Comment 14•23 years ago
|
||
Here is what happens: 1) the attr of body is modified - attrModified event handler is called -> The handler writes the attributes of the event into text area 2) The text area attribute is modified due to bug 97058 and handler is called -> The handler writes the attributes of the event into text area 3) The text area attribute is modified due to bug 97058 and handler is called -> The handler writes the attributes of the event into text area 4) The text area attribute is modified due to bug 97058 and handler is called .... so on 100 more times or so --- CRASH --- Thats what I ment by recursive event :)
Reporter | ||
Comment 15•23 years ago
|
||
Yeah, Vlad, I didn't see that. This is why: * "value" is a property of a textarea element. * "value" is an attribute of the text input element (and other input types). * "value" is not an attribute of a textarea element. You did a good job with finding that loop. (which has nothing to do with the original problem.) I just wanted to add that there are some problems with domAttrModified 1 (as discussed in another bug) --prevValue is empty string 2 Several Errors while accessing certain props (by checking the 'show errors' radio. On No. 2, the problem could be prevented by not allowing all properties from the event object to be inherited, or at least giving them a value of "undefined" --not throwing an error. My view: A textarea change should fire a different type of event. Technically speaking, the value of a textarea is a text node, the nodeValue of the the textarea's firstChild. I don't know what the best way to address this, but calling "value" an attribute of textarea is not the way. There's a lot of other events (domNodeInsertedIntoDocument, et c.) ...I ought to review the w3c spec more.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Comment 16•23 years ago
|
||
So Garrett, the original issue reported here works for me. I demonstrated in the attachment with the counter to work around recursion of events that the properties of the domAttrModified event are exposable. Can I resolve this bug as works for me?
Reporter | ||
Comment 17•23 years ago
|
||
There are really 3 bugs here. 1- Unless a try-catch is used, this error will be produced: Error: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js :: getProps :: line 4" data: no] Source File: file:///OS%20X/Users/garretts/Sites/DHTMLkitchen/dhtml/events/eventListener/showEvent.js Line: 4 --the original problem I reported 2- Recursion exposed another bug -value treated as an attribute of textarea (it isn't). 3- unstopped recursion --Vladimir, you brought our attention to this. Assign them as you see fit, or guide me to the source. With a little guidance, I might be able to work on them.
Comment 18•23 years ago
|
||
Attaching a testcase that avoids the looping problems (those are covered by bug 97058 and bug 77271 as vladimire@netscape.com pointed out). The problem seems to be the following. The MutationEvent produced has a bunch of properties ("screenX", "button", "view", etc) that just do not apply to mutation events (they apply to mouse events, or UI events, or the like). Trying to access those properties throws the exception Garrett noted. I'm seeing this on Linux, so OS to ALL.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: MacOS X → All
Hardware: Macintosh → All
Summary: MutationEvent --domAttrModified --examining props w/for in loop → Mutation events have properties that throw an exception on being accessed
Comment 19•23 years ago
|
||
Attachment #55344 -
Attachment is obsolete: true
Attachment #55348 -
Attachment is obsolete: true
Attachment #55349 -
Attachment is obsolete: true
Attachment #55646 -
Attachment is obsolete: true
Attachment #55654 -
Attachment is obsolete: true
Updated•23 years ago
|
Summary: Mutation events have properties that throw an exception on being accessed → Mutation Events should have their own class type without extra properties
Target Milestone: --- → mozilla1.1
Comment 20•22 years ago
|
||
FYI, typeof(object[blah]) seems only to throw exception when blah is a XUL-specific property. This happens to all objects (I could reproduce this with document object, for example)
Comment 21•22 years ago
|
||
just simple object[xul_property] (w/o typeof) also throws exception. not sure if this is by design, but could be useful to extract an array of XUL-only properties :p
Comment 22•22 years ago
|
||
Hmm. They do have a class of their own, but all that stuff is inherited from nsEvent. Its not only Mutation events that show properties of other event types, MouseEvents for example also show keyevent, and mutation event properties. I dont know enough about the architecture to make a judgement whether it would be a good idea to move these properties or not.
Priority: -- → P4
Comment 23•22 years ago
|
||
Changing description. Could potentially lower memory usage, but could also break a lot of dependent code.
Summary: Mutation Events should have their own class type without extra properties → Move event specific properties from nsEvent into the specific event classes
Reporter | ||
Comment 24•22 years ago
|
||
MouseEvent should have those props. citation: Object MouseEvent MouseEvent has the all the properties and methods of the UIEvent object as well as the properties and methods defined below. The MouseEvent object has the following properties: screenX This read-only property is a long object. screenY This read-only property is a long object. clientX This read-only property is a long object. clientY This read-only property is a long object. ctrlKey This read-only property is of type Boolean. shiftKey This read-only property is of type Boolean. altKey This read-only property is of type Boolean. metaKey This read-only property is of type Boolean. button This read-only property is of type Number. relatedTarget This read-only property is a EventTarget object. http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/ecma-script-binding.html Mutation Event, however, does not. The heirarchy may be off, I guess. It looks like there's too much stuff in the top level interface, Event.
Comment 25•22 years ago
|
||
I dont think keyCode, DOM_VK_** belong to mouse events..
Updated•21 years ago
|
Target Milestone: Future → mozilla1.1alpha
Updated•15 years ago
|
Assignee: joki → nobody
QA Contact: vladimire → events
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•