modules/libjar/zipwriter/test/unit/test_bug446708.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 function run_test() {
     2   var testBundle = do_get_file("data/test_bug446708");
     4   RecursivelyZipDirectory(testBundle);
     5 }
     7 // Add |file| to the zip. |path| is the current path for the file.
     8 function AddToZip(zipWriter, path, file)
     9 {
    10   var currentPath = path + file.leafName;
    12   if (file.isDirectory()) {
    13     currentPath += "/";
    14   }
    16   // THIS IS WHERE THE ERROR OCCURS, FOR THE FILE "st14-1.tiff" IN "test_bug446708"
    17   zipWriter.addEntryFile(currentPath, Ci.nsIZipWriter.COMPRESSION_DEFAULT, file, false);
    19   // if it's a dir, continue adding its contents recursively...
    20   if (file.isDirectory()) {
    21     var entries = file.QueryInterface(Components.interfaces.nsIFile).directoryEntries;
    22     while (entries.hasMoreElements()) {
    23       var entry = entries.getNext().QueryInterface(Components.interfaces.nsIFile);
    24       AddToZip(zipWriter, currentPath, entry);
    25     }
    26   }
    28   // ...otherwise, we're done
    29 }
    31 function RecursivelyZipDirectory(bundle)
    32 {
    33   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
    34   AddToZip(zipW, "", bundle); 
    35   zipW.close();
    36 }

mercurial