michael@0: const Ci = Components.interfaces; michael@0: const Cc = Components.classes; michael@0: michael@0: const CWD = do_get_cwd(); michael@0: function checkOS(os) { michael@0: const nsILocalFile_ = "nsILocalFile" + os; michael@0: return nsILocalFile_ in Components.interfaces && michael@0: CWD instanceof Components.interfaces[nsILocalFile_]; michael@0: } michael@0: michael@0: const isWin = checkOS("Win"); michael@0: michael@0: function run_test() { michael@0: var envVar = isWin ? "USERPROFILE" : "HOME"; michael@0: michael@0: var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); michael@0: var homeDir = dirSvc.get("Home", Ci.nsIFile); michael@0: michael@0: var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); michael@0: var expected = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); michael@0: expected.initWithPath(env.get(envVar)); michael@0: michael@0: do_check_eq(homeDir.path, expected.path); michael@0: }