window.navigator.userAgent is the user agent, with caveats.
-
It is considered non-standard and the recommendation is not to use it. It is still supported by all the main browsers, but you may get deprecation warnings.
-
It may not be the user agent sent in http headers. The preference general.useragent.override will be used in http headers, but not in window.navigator.userAgent.
nsIHttpProtocolHandler defines a userAgent getter which will give you the one that goes in the http header. Most of the time! The general.useragent.override preference takes precedence.
There is an interface nsISiteSpecificUserAgent which has a method GetUserAgentForURIAndWindow(). You might try calling this yourself, which is what the navigator.userAgent getter does if there is a specific window and URI. If there is no window or URI, or no site-specific override, then the protocol handler is used.