How can I get the os version (Windows, Linux, Mac ) in my Thunderbird add-on JavaScript code ?
I tried to use [runtime.PlatformOs](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/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 https://developer.mozilla.org/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests#Platform-specific_tests
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 https://searchfox.org/mozilla-central/rev/a0333927deabfe980094a14d0549b589f34cbe49/toolkit/modules/AppConstants.jsm#148
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: (("@mozilla.org/gnome-gconf-service;1" in Cc) ||
("@mozilla.org/gio-service;1" in Cc) ||
(Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2)
.getProperty("name") == "Linux")),
platformIsWindows: "@mozilla.org/windows-registry-key;1" in Cc