Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

command line example from mozilla site doesn't work

5 views
Skip to first unread message

miles zarathustra

unread,
Nov 1, 2006, 8:57:19 PM11/1/06
to
I am trying to get the simplest case I can think of to work, without luck.
Following up on the instructions on:

http://developer.mozilla.org/en/docs/Chrome:_Command_Line

I have copied the entire example (verbatim) into a file called
myAppHandler.js, which I put into my firefox/components directory (actually
C:\Program Files\Mozilla Firefox\components).

Theoretically, this is one of the places that will cause mozilla to
"register" it. (right? 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.)

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.

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>

Nickolay Ponomarev

unread,
Nov 2, 2006, 5:23:22 AM11/2/06
to miles zarathustra, dev-ext...@lists.mozilla.org
On 11/2/06, miles zarathustra <nob...@nomail.com> wrote:
> I am trying to get the simplest case I can think of to work, without luck.
> Following up on the instructions on:
>
> http://developer.mozilla.org/en/docs/Chrome:_Command_Line
>
> I have copied the entire example (verbatim) into a file called
> myAppHandler.js, which I put into my firefox/components directory (actually
> C:\Program Files\Mozilla Firefox\components).
>
> Theoretically, this is one of the places that will cause mozilla to
> "register" it. (right?

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

miles zarathustra

unread,
Nov 2, 2006, 2:00:16 PM11/2/06
to
Nickolay Ponomarev wrote:


> 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.">&nbsp;
<input type=button onclick="showInterfaces();" value="show
interfaces.">&nbsp;
<input type=button onclick="showClasses();" value="show classes.">&nbsp;
<input type=button onclick="showEnumeration(window);" value="show window
enumeration.">&nbsp;
</body></html>

miles zarathustra

unread,
Nov 2, 2006, 3:04:01 PM11/2/06
to

For better or worse, I've edited the page:

http://developer.mozilla.org/en/docs/Chrome:_Command_Line

0 new messages