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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c7195e158085
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 {
11 // Copy in the test file.
12 var source = do_get_file("data/test.zip");
13 source.copyTo(tmpFile.parent, tmpFile.leafName);
14
15 // Open it and add something so the CDS is rewritten.
16 zipW.open(tmpFile, PR_RDWR | PR_APPEND);
17 zipW.addEntryDirectory(DIRNAME, time * PR_USEC_PER_MSEC, false);
18 do_check_true(zipW.hasEntry(DIRNAME));
19 zipW.close();
20
21 var zipR = new ZipReader(tmpFile);
22 do_check_true(zipR.hasEntry(DIRNAME));
23 zipR.close();
24
25 // Adding the directory would have added a fixed amount to the file size.
26 // Any difference suggests the CDS was written out incorrectly.
27 var extra = ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
28 (DIRNAME.length * 2) + (ZIP_EXTENDED_TIMESTAMP_SIZE * 2);
29
30 do_check_eq(source.fileSize + extra, tmpFile.fileSize);
31 }

mercurial