How can I get the os version?

How can I get the os version (Windows, Linux, Mac ) in my Thunderbird add-on JavaScript code ?
I tried to use [runtime.PlatformOs]( but it does not work, my add-on is a legacy extension.

You should do something like this:
var { AppConstants } = ChromeUtils.import(“resource://gre/modules/AppConstants.jsm”);
Then you can use for instance AppConstants.platformIsMac
See also

Hmz, the constant platformIsMac isn’t defined in AppConstants.jsm. It was defined in steelApplication.js before TB57, see bug 1278067.

With AppConstants, you need to compare AppConstants.platform, which can be “linux”, “win”, “macosx”, “android”, or “other”, see

Or you can do it the way, it was done in steelApplication.js by by checking for specific component classes or interfaces:

// for steelIApplication
platformIsMac: "nsILocalFileMac" in Ci,
platformIsLinux: ((";1" in Cc) ||
                 (";1" in Cc) ||
                     .getProperty("name") == "Linux")),
platformIsWindows: ";1" in Cc
1 Like