The extension I'm working on contains an XPCOM component implemented in JavaScript and a number of XUL overlays. The overlays access the component in the usual way:
var component = Components.classes['@example.com/extension/component;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
Now I have defined the wrappedJSObject property of the component as a getter method. That seems to work in general, but there is one very weird (to me) phenomenon. Every time an overlay runs the code above, the getter method is called twice. I'm wondering if what I'm doing is "legal" at all? Is it supposed to work this way (call the getter twice)? If yes, can I reasonably rely on this behavior in the future?
If anyone can shed some light on this I would appreciate that a lot.
--
Thanks and kind regards,
Sergei.
> The extension I'm working on contains an XPCOM component implemented
> in JavaScript and a number of XUL overlays. The overlays access the
> component in the usual way:
>
> var component =
> Components.classes['@example.com/extension/component;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
>
>
> Now I have defined the wrappedJSObject property of the component as a
> getter method. That seems to work in general, but there is one very
> weird (to me) phenomenon. Every time an overlay runs the code above,
> the getter method is called twice.
I couldn't quite reproduce this. The first time, the getter was called
twice, but after that, only once. But this may depend on other factors
such as there may be a cache of what feature a particular xpconnect
wrapped object supports; if you lose your original cache then you get an
extra call to populate the cache for next time, but my code was hitting
the cache so I only saw the double getter the first time.
--
Warning: May contain traces of nuts.