Tuesday, August 6, 2013

exposing XPCOM C++ interface on a DOM

So there was a need for me to write a C++ add-on for Firefox and make it possible to use it's functionality from the webpage Javascript code.
Firefox provides XPCOM object model which can be employed by add-ons. Unfortunate to me, the majority of information is sparse and highly out-dated and this post is dedicated to all this pain developers like me experience trying to understand and assemble these pieces of information together. One should also note, that XPCOM is rapidly changing interface and with time passing, the code from this post can no longer be a working example.

The main problem was the privileges - one can't simply execute XPCOM C++ code from the webpage.
I've tried numerous different approaches which failed to work, unless all the new knowledge in my head produced one idea which appeared to work as I expected.