Search code examples
firefoxxulxpcom

xul services is undefined


I start my app with firefox.exe --app application.ini -jsconsole and the first line of my script is:

Components.utils.import("resource://gre/modules/Services.jsm");

The second line is:

alert(typeof services);

And it alerts undefined. Nowhere in the documentation does it say how to get the services only that I need gecko 2.

My firefox version is 21.o for Windows but I think the xulrunner that comes with it might be lacking something.


Solution

  • Any module you import will be named exactly as its filename (excluding extension), so in this case you would've to call it Services and not services. Do not forget that JavaScript variables are case-sensitive.