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