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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/zipwriter/test/unit/test_bug425768.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 + */
     1.8 +
     1.9 +const DIRNAME = "test/";
    1.10 +const time = Date.now();
    1.11 +
    1.12 +function run_test()
    1.13 +{
    1.14 +  // Copy in the test file.
    1.15 +  var source = do_get_file("data/test.zip");
    1.16 +  source.copyTo(tmpFile.parent, tmpFile.leafName);
    1.17 +
    1.18 +  // Open it and add something so the CDS is rewritten.
    1.19 +  zipW.open(tmpFile, PR_RDWR | PR_APPEND);
    1.20 +  zipW.addEntryDirectory(DIRNAME, time * PR_USEC_PER_MSEC, false);
    1.21 +  do_check_true(zipW.hasEntry(DIRNAME));
    1.22 +  zipW.close();
    1.23 +
    1.24 +  var zipR = new ZipReader(tmpFile);
    1.25 +  do_check_true(zipR.hasEntry(DIRNAME));
    1.26 +  zipR.close();
    1.27 +
    1.28 +  // Adding the directory would have added a fixed amount to the file size.
    1.29 +  // Any difference suggests the CDS was written out incorrectly.
    1.30 +  var extra = ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
    1.31 +              (DIRNAME.length * 2) + (ZIP_EXTENDED_TIMESTAMP_SIZE * 2);
    1.32 +
    1.33 +  do_check_eq(source.fileSize + extra, tmpFile.fileSize);
    1.34 +}

mercurial