diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /modules/libjar/zipwriter/test/unit/head_zipwriter.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/libjar/zipwriter/test/unit/head_zipwriter.js')
-rw-r--r-- | modules/libjar/zipwriter/test/unit/head_zipwriter.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/modules/libjar/zipwriter/test/unit/head_zipwriter.js b/modules/libjar/zipwriter/test/unit/head_zipwriter.js new file mode 100644 index 0000000000..f12933d664 --- /dev/null +++ b/modules/libjar/zipwriter/test/unit/head_zipwriter.js @@ -0,0 +1,61 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +const NS_ERROR_IN_PROGRESS = 2152398863; + +const PR_RDONLY = 0x01; +const PR_WRONLY = 0x02; +const PR_RDWR = 0x04; +const PR_CREATE_FILE = 0x08; +const PR_APPEND = 0x10; +const PR_TRUNCATE = 0x20; +const PR_SYNC = 0x40; +const PR_EXCL = 0x80; + +const ZIP_EOCDR_HEADER_SIZE = 22; +const ZIP_FILE_HEADER_SIZE = 30; +const ZIP_CDS_HEADER_SIZE = 46; +const ZIP_METHOD_STORE = 0; +const ZIP_METHOD_DEFLATE = 8; +const ZIP_EXTENDED_TIMESTAMP_SIZE = 9; + +const PR_USEC_PER_MSEC = 1000; +const PR_USEC_PER_SEC = 1000000; +const PR_MSEC_PER_SEC = 1000; + +const DATA_DIR = "data/"; + +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +var ioSvc = Services.io; + +var ZipWriter = Components.Constructor( + "@mozilla.org/zipwriter;1", + "nsIZipWriter" +); +var ZipReader = Components.Constructor( + "@mozilla.org/libjar/zip-reader;1", + "nsIZipReader", + "open" +); + +var tmpDir = do_get_profile(); +var tmpFile = tmpDir.clone(); +tmpFile.append("zipwriter-test.zip"); +if (tmpFile.exists()) { + tmpFile.remove(true); +} + +var zipW = new ZipWriter(); + +registerCleanupFunction(function() { + try { + zipW.close(); + } catch (e) { + // Just ignore a failure here and attempt to delete the file anyway. + } + if (tmpFile.exists()) { + tmpFile.remove(true); + } +}); |