I'm trying to build an extension for Firefox. This extension uses an XPCOM component (a C++ dll). I'm compiling the DLL, compilation is OK.
The next step would be to use the component in Javascript from my extension. I added the code to register my component from my c++ file :
static const mozilla::Module::CategoryEntry kSampleCategories[] = {
{ JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY, "greenfox", NS_SAMPLE_CONTRACTID },
};
In my manifest, I declare the XPCOM :
component {03A6D0B4-22B9-11DF-B844-20D556D89593} components/GreenCodeLabFox.dll
The problem is, when I try to use the component in JS, it seems it is not registered :
try {
greenfox;
return true;
} catch( e ) {
alert( e );
return false;
}
This gives me the alert error:
ReferenceError: greenfox is not defined
In error console, I have no message.
How would I debug this if I have no error message ? By the way, my javascript.options.showInConsole is set to true.
Thanks !
Per https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0 you must use a
binary-component
directive to register a binary component.That page also links to an example; you only posted a part of the code required for registration.
If the component still doesn't work, I'd try to get it via Components.classes[contract id] from the Error Console - that will show if the problem is with the component registration or just with the global property part.
https://developer.mozilla.org/en/Troubleshooting_XPCOM_components_registration might be useful for troubleshooting, although it's a bit dated.