Get a hold of the profile manager:
js> var Cc = Components.classes; js> var Ci = Components.interfaces; js> var rc = Cc["@mozilla.org/profile/manager;1"]; js> var rs = rc.getService(Ci.nsIProfile);
Now, we want to call getProfileList.
But getProfileList has a funky signature:
JavaScript? doesn't have pointers, so you can't pas a variable as the length argument, and end up with the value.
We use a trick instead; You pass it a blank object, and it will set the "value" attribute of the object.
js> var obj = Object(); js> obj [object Object] js> rs.getProfileList(obj) default js> obj.value 1
The "1" result means, "the returned array had one item in it."
See where it says "default" above, in response to rs.getProfileList? That "default" is not just a string, it's actually an array.
js> var ar = rs.getProfileList(obj) js> ar default
If you had multiple items in there, it might look like this:
js> ar default, Ned, Josh, Sally js> obj.value 4 You can learn more about how XPConnect binds XPCOM function signatures to Javascript objects:
http://www.mozilla.org/scriptable/faq.html