tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug425768.js (1049B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 */
      5 
      6 const DIRNAME = "test/";
      7 const time = Date.now();
      8 
      9 function run_test() {
     10  // Copy in the test file.
     11  var source = do_get_file("data/test.zip");
     12  source.copyTo(tmpFile.parent, tmpFile.leafName);
     13 
     14  // Open it and add something so the CDS is rewritten.
     15  zipW.open(tmpFile, PR_RDWR | PR_APPEND);
     16  zipW.addEntryDirectory(DIRNAME, time * PR_USEC_PER_MSEC, false);
     17  Assert.ok(zipW.hasEntry(DIRNAME));
     18  zipW.close();
     19 
     20  var zipR = new ZipReader(tmpFile);
     21  Assert.ok(zipR.hasEntry(DIRNAME));
     22  zipR.close();
     23 
     24  // Adding the directory would have added a fixed amount to the file size.
     25  // Any difference suggests the CDS was written out incorrectly.
     26  var extra =
     27    ZIP_FILE_HEADER_SIZE +
     28    ZIP_CDS_HEADER_SIZE +
     29    DIRNAME.length * 2 +
     30    ZIP_EXTENDED_TIMESTAMP_SIZE * 2;
     31 
     32  Assert.equal(source.fileSize + extra, tmpFile.fileSize);
     33 }