test_zipcomment.js (1063B)
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 DATA = "ZIP WRITER TEST COMMENT"; 7 const DATA2 = "ANOTHER ONE"; 8 9 function run_test() { 10 zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); 11 zipW.comment = DATA; 12 zipW.close(); 13 14 // Should have created a zip file 15 Assert.ok(tmpFile.exists()); 16 17 // Empty zip file should just be the end of central directory marker 18 // and comment 19 Assert.equal(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA.length); 20 21 zipW.open(tmpFile, PR_RDWR); 22 // Should have the set comment 23 Assert.equal(zipW.comment, DATA); 24 zipW.comment = DATA2; 25 zipW.close(); 26 27 // Certain platforms cache the file size so get a fresh file to check. 28 tmpFile = tmpFile.clone(); 29 30 // Empty zip file should just be the end of central directory marker 31 // and comment. This should now be shorter 32 Assert.equal(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA2.length); 33 }