Bug 596580: Fix mozJSSubScriptLoader's version finding. (r=brendan)
[mozilla-central.git] / xpcom / tests / unit / test_hidden_files.js
blob46954590452af6147a0fa642e2e83345e5fdedc9
1 const Ci = Components.interfaces;
2 const Cc = Components.classes;
3 const NS_OS_TEMP_DIR = "TmpD";
5 const CWD = do_get_cwd();
6 function checkOS(os) {
7   const nsILocalFile_ = "nsILocalFile" + os;
8   return nsILocalFile_ in Components.interfaces &&
9          CWD instanceof Components.interfaces[nsILocalFile_];
12 const isWin = checkOS("Win");
13 const isOS2 = checkOS("OS2");
14 const isMac = checkOS("Mac");
15 const isUnix = !(isWin || isOS2 || isMac);
17 var hiddenUnixFile;
18 function createUNIXHiddenFile() {
19   var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
20   var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile);
21   hiddenUnixFile = tmpDir.clone();
22   hiddenUnixFile.append(".foo");
23   // we don't care if this already exists because we don't care
24   // about the file's contents (just the name)
25   if (!hiddenUnixFile.exists())
26     hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
27   return hiddenUnixFile.exists();
30 function run_test() {
31   // Skip this test on Windows
32   if (isWin || isOS2)
33     return;
35   do_check_true(createUNIXHiddenFile());
36   do_check_true(hiddenUnixFile.isHidden());