xpcom/ds/nsIPropertyBag.idlScriptable
This interface is used to store a set of properties.
Inherits from: nsISupports Last changed in Gecko 1.0

Method overview

nsIVariant getProperty(in AString name);

Attributes

Attribute Type Description
enumerator nsISimpleEnumerator Get a nsISimpleEnumerator whose elements are nsIProperty objects. Read only.

Methods

getProperty()

Get a property value for the given name.

nsIVariant getProperty(
  in AString name
);
Parameters
name
The name to return the matching property.
Return value

The property matching the given name.

Exceptions thrown
NS_ERROR_FAILURE
If a property with that name doesn't exist.

Examples

Get User Agent Information (Operating System Specifics.

The window scope is not always accessible so the window.navigator cannot be accessed. Goodies obtained from window.navigator are:

appCodeName:"Mozilla"
appName:"Netscape"
appVersion:"5.0 (Windows)"
battery:BatteryManager
buildID:"20140529161749"
cookieEnabled:true
doNotTrack:"yes"
geolocation:Geolocation
language:"en-US"
mimeTypes:MimeTypeArray
mozAlarms:null
mozApps:XPCWrappedNative_NoHelper
mozCameras:CameraManager
mozConnection:MozConnection
mozContacts:ContactManager
mozId:null
mozKeyboard:XPCWrappedNative_NoHelper
mozPay:null
mozPermissionSettings:null
mozPhoneNumberService:PhoneNumberService
mozPower:MozPowerManager
mozTCPSocket:null
onLine:true
oscpu:"Windows NT 5.1"
platform:"Win32"
plugins:PluginArray
product:"Gecko"
productSub:"20100101"
userAgent:"Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0"
vendor:""
vendorSub:""
__proto__:NavigatorPrototype

From here we can easily see the Operating System version. Services.appinfo.OS simply tells us WINNT only, this is not helpful to differentiate between Windows XP, Vista, 7, etc. To do this use nsIPropertyBag:

Services.sysinfo.getProperty("version"); //output 5.1
Services.sysinfo.getProperty("name"); //output Windows_NT
Services.sysinfo.getProperty("arch"); //output x86
Services.sysinfo.getProperty("hasWindowsTouchInterface"); //outputs false or true if windows touch is there

Consult the DXR (https://dxr.mozilla.org/mozilla-release/source/xpcom/base/nsSystemInfo.cpp) for the properties supported. Also pay attention to their platform-specific meaning (e.g. on Android there is version and kernel_version).