michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: const DATA = "ZIP WRITER TEST COMMENT"; michael@0: const DATA2 = "ANOTHER ONE"; michael@0: michael@0: function run_test() michael@0: { michael@0: zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); michael@0: zipW.comment = DATA; michael@0: zipW.close(); michael@0: michael@0: // Should have created a zip file michael@0: do_check_true(tmpFile.exists()); michael@0: michael@0: // Empty zip file should just be the end of central directory marker michael@0: // and comment michael@0: do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA.length); michael@0: michael@0: zipW.open(tmpFile, PR_RDWR); michael@0: // Should have the set comment michael@0: do_check_eq(zipW.comment, DATA); michael@0: zipW.comment = DATA2; michael@0: zipW.close(); michael@0: michael@0: // Certain platforms cache the file size so get a fresh file to check. michael@0: tmpFile = tmpFile.clone(); michael@0: michael@0: // Empty zip file should just be the end of central directory marker michael@0: // and comment. This should now be shorter michael@0: do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA2.length); michael@0: }