Can anyone explain what is going on, and how I can convince this to work?
I'll be glad to modify the page with the correct instructions (and explain
that this is an XPComm app) if I can get it to work.
Thanks,
-= miles =-
(Here is my file used to enumerate registered components; simply save it as
showStuff.html (or whatever you want to call it) and open it.)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>show stuff</title>
</head>
<script language="javascript">
function showClassesByID() {
for (el in Components.classesByID) {
cmp = Components.classesByID[el];
document.write('<hr>'+ el +'<br>');
showEnumeration(cmp);
}
}
function showInterfaces() {
for (el in Components.interfacesByID) {
cmp = Components.interfacesByID[el];
document.write('<hr>'+el +'<br>');
showEnumeration(cmp);
}
}
function showClasses() {
for (el in Components.classes) {
cmp = Components.classes[el];
document.write('<hr>'+el + '<br>');
showEnumeration(cmp);
}
}
function showEnumeration(obj) {
for (el in obj) {
cmp = obj[el];
document.write(el+' : '+cmp+'<br>');
}
}
function showStuff() {
// one or both of these may pop a dialog box
// need to do this to access Components.classesByID
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
/*
alert('classesByID = '+Components.classesByID);
alert('classesByID info = '
+Components.propertyIsEnumerable('classesByID'));
*/
//showInterfaces();
//showClassesByID();
showClasses();
//showEnumeration(window);
}
</script>
<body onload="showStuff();" ></body></html>
Right. In order to cause auto-registration process, you'll also need
to delete compreg.dat in your profile.
> At the URL above I read the phrase "register in a
> category," with no further explanation of what a "category" is or how to go
> about this.)
>
The call to nsICategory::addCategoryEntry in the example does it; but
it's not related to the problem at hand.
> Now I start up mozilla from scratch, then load "showStuff.html" (shown
> below) and, voila, the component is nowhere to be found. I believe it did
> not get registered.
>
Correct. Try deleting compreg.dat and looking in the JavaScript
console (after setting the development prefs) as I suggested.
> I'll be glad to modify the page with the correct instructions (and explain
> that this is an XPComm app) if I can get it to work.
>
Thanks for that.
> (Here is my file used to enumerate registered components; simply save it as
> showStuff.html (or whatever you want to call it) and open it.)
>
I recommend using the JS shell from the Extension Developer's
Extension instead. Lets you run JS with chrome privileges in the
context of any window easily.
Nickolay
> Right. In order to cause auto-registration process, you'll also need
> to delete compreg.dat in your profile.
I thought I had done that and it still didn't work, but things are getting
confusing around here because now I have both FF 1.5 and 2.0 on the same
machine, both with two profiles, so probably I just wasn't starting up the
way I thought I was.
Anyhow, now it does seem to be registered.
Below is a more useful version of showIt.html I hope someone finds it
helpful...
I'll check out the Extension Devlopers' Extension.
-= miles =-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>show stuff</title></head>
<script language="javascript">
function showObject(obj) {
var w=window.open();
for (el in obj) {
cmp = obj[el];
w.document.write('<hr>'+ el +'<br>');
showEnumeration(cmp, w);
}
w.document.close();
}
function showClassesByID() {
// calling the enable function here isn't sufficient to grant access.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
showObject(Components.classesByID);
}
function showClasses() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
showObject(Components.classes);
}
function showInterfaces() { showObject(Components.interfacesByID); }
function showEnumeration(obj, w) {
var c;
if (!w) { w = window.open(); c=true; }
for (el in obj) {
cmp = obj[el];
w.document.write(el+' : '+cmp+'<br>');
}
if (c) w.document.close();
}
function enable() {
// one or both of these may pop a dialog box
// need to do this to access Components.classesByID
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserAccess");
}
</script>
<body>
<input type=button onclick="showClassesByID();" value="show classes by
ID.">
<input type=button onclick="showInterfaces();" value="show
interfaces.">
<input type=button onclick="showClasses();" value="show classes.">
<input type=button onclick="showEnumeration(window);" value="show window
enumeration.">
</body></html>