nsISupports
Last changed in Gecko 1.0 nsIVariant getProperty(in AString name); |
| Attribute | Type | Description |
enumerator |
|
Get a nsISimpleEnumerator whose elements are nsIProperty objects. Read only. |
Get a property value for the given name.
nsIVariant getProperty( in AString name );
nameThe property matching the given name.
NS_ERROR_FAILUREThe 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).