Services.jsm

The Services.jsm JavaScript code module offers a wide assortment of lazy getters that simplify the process of obtaining references to commonly used services.

To use it, you first need to import the code module into your JavaScript scope:

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

Then you can obtain references to services by simply accessing them from the Services object exported by the code module. For example, to obtain a reference to the preferences service:

var prefsService = Services.prefs;

Provided service getters

Service accessor Service interface Service name
androidBridge nsIAndroidBridge 1
appinfo nsIXULAppInfo
nsIXULRuntime
Application information service
appShell nsIAppShellService Application shell service
blocklist nsIBlocklistService Blocklist service
cache nsICacheService Cache service
cache2 nsICacheStorageService Cache storage service
clipboard nsIClipboard Clipboard
console nsIConsoleService Error console service
contentPrefs nsIContentPrefService Content Preferences service
cookies nsICookieManager2 Cookie Manager 2 service
cpmm nsIMessageSender Child process message manager4
crashmanager CrashManager.jsm  
dirsvc nsIDirectoryService
nsIProperties
Directory service
domStorageManager nsIDOMStorageManager DOM Storage Manager
DOMRequest nsIDOMRequestService DOMRequest service
downloads nsIDownloadManager Download manager
droppedLinkHandler nsIDroppedLinkHandler Dropped link handler service
els nsIEventListenerService Event listener service
eTLD nsIEffectiveTLDService EffectiveTLD service
focus nsIFocusManager Focus manager
io nsIIOService
nsIIOService2
I/O Service
locale nsILocaleService Locale service
logins nsILoginManager Password Manager service
metro nsIWinMetroUtils 2
mm nsIMessageBroadcaster
nsIFrameScriptLoader
Global frame message manager3
obs nsIObserverService Observer service
perms nsIPermissionManager Permission manager service
ppmm nsIMessageBroadcaster
nsIProcessScriptLoader
Global parent process message manager3
prefs nsIPrefBranch
nsIPrefBranch2
nsIPrefService
Preferences service
prompt nsIPromptService Prompt service
scriptloader mozIJSSubScriptLoader JavaScript subscript loader service
scriptSecurityManager nsIScriptSecurityManager Script security manager
search nsIBrowserSearchService Browser search service
startup nsIAppStartup Application startup service
storage mozIStorageService Storage API service
strings nsIStringBundleService String bundle service
sysinfo nsIPropertyBag2 System info service
telemetry nsITelemetry Telemetry service
tm nsIThreadManager Thread Manager service
uriFixup nsIURIFixup URI Fixup service
urlFormatter nsIURLFormatter URL Formatter service
vc nsIVersionComparator Version comparator service
wm nsIWindowMediator Window mediator service
ww nsIWindowWatcher Window watcher service

1 Mobile only
2 Windows only
3 Main process only
4 Child process only

See also

Document Tags and Contributors

 Last updated by: wbamberg,