XPCOM component extension compile IDL

Hi,

I’m developing extension that export “JavaScript global property” to content scripts.
The exported object implements an interface described in IDL file.
The add-on is https://addons.mozilla.org/en-US/firefox/addon/js-print-setup/.
Till now I have used xpidl/typelib.py from xulrunner-sdk to compile IDL to XPT.
But now xulrunner-sdk is discontinued and I can’t find way to compile my IDL file into XPT to the latest mozilla sources.

How I can compile my IDL file?

Thank you for all help!

Regards,

Dimitar Angelov

Is exporting global javascript property to content scripts e10s safe?

Would transferring to give the content script a MessagePort be e10s safe? would it be feasible that if a content screen need anything they can send requests over that port?

https://developer.mozilla.org/en-US/docs/Web/API/MessagePort

Thank you for response!

I’m not sure, but I think that is not e10s safe.
The addon creates global object ‘jsPrintSetup’ which implements some useful methods to adjust and control print process (like set header/footer and other print options, calling silent print and so on).
https://github.com/edabg/jsprintsetup/blob/master/src/components/jsPrintSetup.idl
For that functionality jsPrintSetup uses nsIPrint* interfaces.
I’m not familiar with MessagePort, but if I understand this mean that calling of some method of javascript object can be replaced with Messages.
Can I achieve with MessagePort following current prototype of use addon in client javaScript?

jsPrintSetup.setOption(‘marginTop’, 15);

Regards,

Dimitar

As long as you don’t need an immediate reply (as in synchronous execution), using MessagePort or any other messaging system would work perfectly fine. You could even write a wrapper object for your content-scripts that would then do the message passing things in the background.

I see that you have some getter methods. Those would have to be async (so you need listener functions).

Can you suggest me some example code, guide or some pure JavaScript add-on that realize this?
If I understand correctly You recommend to use wrapper object instead XPCOM interface?

Yep I’m recommending this over XPCOM because XPCOM is marked for deprecation. The messaging method will work in the future.

The MessagePort transfer method requires they be on the same content process. And to talk between other content processes, you’ll have to inject a framescript which adds an event listener or something for your event or message.

Here is framescript - https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFrameScriptLoader#loadFrameScript()

Here is example of framescript - https://github.com/Noitidart/modtools

This repository here:

Is an excellent example, it shows how to do it multiple ways. The old way is not to be done anymore, but just shown so dev knows what to change.

1 Like

Thank you! This is very useful for me.
I also have another thing to consider. XUL will be deprecated.
My addon have options dialog (xul window) for addon settings.
This must be replaced with panel and use contentScript or use simple-prefs to manage related preferences of addon. Am I right?
But I can’t find solution of problem related to FF permissions manager.
At this time I use chrome://browser/content/preferences/permissions.xul to manage permissions.
Which is best replacement of this in case of XUL deprecation?

What I do right now is change the optionsURL field in the install.rdf and point to a html page I register with my addon. I actually register about:. Then I set optionsType to 3 so it opens that link in a new tab. You can try this out, heres an example addon of mine that does it - https://addons.mozilla.org/en-US/firefox/addon/topick/ and on github - https://github.com/Noitidart/Topick