Bad display for XPCNativeWrapper and Event
The display code in the Console and DOM tabs doesn’t know how to
display an XPCNativeWrapper.
Test Case (in Console):
>xBody = new XPCNativeWrapper(document.body)
Displays the same as
>xBody.wrappedJSObject; // == document.body
With no indication that one is wrapped and the other is not and with
no way to inspect what is inside the wrapper.
Some might consider this a feature but I have found it a bug because
sometimes XPCNativeWrapper does automagical propagation of properties
between the wrapper and the wrapped object and sometimes it doesn’t -
I.e. setting a ‘.foo’ property on the wrapper may or may not set the
‘.foo’ property on the wrapped object, and getting the ‘.foo’ property
from a wrapper may or may not get the ’.foo’ property on the wrapped
object.
I ran into this when I tried creating simple ‘custom events’ as
illustrated below.
EVENT DISPLAY PROBLEMS
In the Console:
>ev = document.createEvent('Events') // -> blank
Works but returns nothing that can be inspected.
>ev.initEvent('funky', null, null) // -> blank
Works such that
>ev // -> funky
Returns the label ‘funky’ which is the event and can be inspected
>ev.tut = 'funky tut'
Works but
>ev
Still only displays as ‘funky’.
Maybe Firebug should display Events as something like
‘Event:’+’e.type’ for the case where e.type is not defined so that
something of the returned value will be displayed that can be
inspected.
THE INTERACTION
>wEv = new XPCNativeWrapper(ev) // -> blank
Works but displays nothing that can be inspected, Also the ’.tut’
property exists only on the wrapped object and not the wrapper:
>wEv.tut // -> blank (I.e. undefined)
>wEv.wrappedJSObject.tut // -> “funky tut”
I presume somewhere in an XPCNativeWrapper there is some information
about which properties are automagical but if Firebug doesn’t allow
you to inspect one directly you can’t see where the information is.
If you create a wrapper yourself, you can tell the creation about
automagical properties[1]
>wEv2 = new XPCNativeWrapper(ev, ‘type‘, ‘tut‘) // -> blank
Works but still displays as a blank even though
>wEv2.type // -> "funky"
>wEv2.tut // -> “funky tut”
Which means that even if I create a wrapped event as what I guess is
‘correctly’ it still doesn’t display in a form that is inspectable.
However I ran into this problem working with Greasemonkey/Sandboxing
which automagically creates XPCNativeWrappers where I have no control
over their auto magical properties.
I’ve looked in fbug but I don’t see anywhere where these problems are
mentioned. [2][3]
[1] http://kb.mozillazine.org/XPCNativeWrapper
[2]
http://code.google.com/p/fbug/issues/list?can=1&q=XPCNativeWrapper&colspec=ID+Type+Status+Owner+Test+Summary&cells=tiles
[3]
http://code.google.com/p/fbug/issues/list?can=1&q=event+display&colspec=ID+Type+Status+Owner+Test+Summary&cells=tiles
--
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/firebug?hl=en.