xpcom/tests/unit/test_hidden_files.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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_];
    10 }
    12 const isWin = checkOS("Win");
    13 const isMac = checkOS("Mac");
    14 const isUnix = !(isWin || isMac);
    16 var hiddenUnixFile;
    17 function createUNIXHiddenFile() {
    18   var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
    19   var tmpDir = dirSvc.get(NS_OS_TEMP_DIR, Ci.nsIFile);
    20   hiddenUnixFile = tmpDir.clone();
    21   hiddenUnixFile.append(".foo");
    22   // we don't care if this already exists because we don't care
    23   // about the file's contents (just the name)
    24   if (!hiddenUnixFile.exists())
    25     hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
    26   return hiddenUnixFile.exists();
    27 }
    29 function run_test() {
    30   // Skip this test on Windows
    31   if (isWin)
    32     return;
    34   do_check_true(createUNIXHiddenFile());
    35   do_check_true(hiddenUnixFile.isHidden());
    36 }

mercurial