Hi everyone, I have an XPCOM component (secclab) that exposes digital signature functionality through the javascript DOM.
I have taken the original source and compiled it against the mozilla 1.4 source.
(the only modification I made to the source was that I used the
nsIComponentManager
interface instead of calling do_CreateInstance).
There are problems, however, when I attempt to use this component in different
versions of mozilla. It works for all mozilla versions up to 1.7.2 - the
installation is successful,
the component shows up in mozilla registry, the javascript DOM is successfully
extended etc.
I then tried using the same build with mozilla firefox 1.0 (which I believe is
based on mozilla 1.7.3).
The installation is reported to be successful (install.log and the components
directory is modified correctly).
The component DOES show up in the registry (i can query the component version
through XPI install interfaces),
although I cannot see it in the extensions manager dialog.
I then restart firefox and the component still shows up as installed. I cannot
use the DOM extensions, however - it
says the class is not defined.
I have also noticed that the component does not seem to get written to the
components/compreq.dat
(which it does with other versions of mozilla).
Considering the installation is successful, I suspect something is wrong with
the registration code (the full module
code is enclosed and I also provide some snippets at the bottom of this
message).
I then built a debug version of firefox and tried the same procedure again.
Now, when the component is installed, it
gives the following error message:
"The component cannot be downloaded because: Restart to complete.".
I restart firefox and the component shows up as installed. But now, everything
else works as well (the DOM extensions
are correctly installed and I can use the component). Another problem occurs
when I try to shutdown mozilla - it crashes
on shutdown everytime I use the component.
So now I've got a debug version of firefox where I can use the component
(although it crashes on shutdown). If I then
fire up my installed release version and I repeat the installation,everything
works just like it does in the debug version (again,
crashing on shutdown).
Can anyone point me in the right direction for sorting out these two problems
(unsuccessful installation
and crashes on shutdown).
Thanks,
Matej
P.S.
Here are some snippets from the registration code:
1. The code uses the NS_DOMCI_EXTENSION macro to map to the DOM extension class
(CLABExtras) to the
object that it exposes to DOM (CLABSignString).
NS_DOMCI_EXTENSION(CLABExtras)
static NS_DEFINE_CID(kCLABSignStringCID, NS_CLABSIGNSTRING_CID);
NS_DOMCI_EXTENSION_ENTRY_BEGIN(CLABSignString)
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsICLABSignString)
NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(CLABSignString, PR_TRUE,
&kCLABSignStringCID)
NS_DOMCI_EXTENSION_END
2. The registration method uses the nsICategoryManager to add a
JAVASCRIPT_DOM_CLASS category entry.
static NS_METHOD
RegisterCLABExtras(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
nsresult rv = NS_OK;
int shutdown = 0;
nsCOMPtr<nsIServiceManager> mgr;
if (NS_GetServiceManager(getter_AddRefs(mgr)) == NS_ERROR_NOT_INITIALIZED){
rv = XPCOMGlueStartup(nsnull);
if (NS_SUCCEEDED(rv))
shutdown = 1;
}
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
goto FAIL;
// nsXPIDLCString previous;
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
"CLABSignString",
CLABEXTRAS_DOMCI_EXTENSION_CONTRACTID,
PR_TRUE, PR_TRUE,nsnull);//
getter_Copies(previous));
NS_ENSURE_SUCCESS(rv, rv);
FAIL:
if (shutdown){
XPCOMGlueShutdown();
}
return rv;
}
3. Here is the shutdown code that I think also causes the application to crash:
void PR_CALLBACK
CLABExtrasModuleDestructor(nsIModule* self)
{
NS_IF_RELEASE(NS_CLASSINFO_NAME(CLABSignString));
}
NS_IMPL_NSGETMODULE_WITH_DTOR("SECCLAB", components,
CLABExtrasModuleDestructor)
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.289 / Virus Database: 265.4.1 - Release Date: 19.11.2004
nsCLABModule.cpp
Description: nsCLABModule.cpp
