From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../libjar/zipwriter/test/unit/test_bug446708.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 modules/libjar/zipwriter/test/unit/test_bug446708.js (limited to 'modules/libjar/zipwriter/test/unit/test_bug446708.js') diff --git a/modules/libjar/zipwriter/test/unit/test_bug446708.js b/modules/libjar/zipwriter/test/unit/test_bug446708.js new file mode 100644 index 0000000000..cff67d848a --- /dev/null +++ b/modules/libjar/zipwriter/test/unit/test_bug446708.js @@ -0,0 +1,39 @@ +function run_test() { + var testBundle = do_get_file("data/test_bug446708"); + + RecursivelyZipDirectory(testBundle); +} + +// Add |file| to the zip. |path| is the current path for the file. +function AddToZip(zipWriter, path, file) { + var currentPath = path + file.leafName; + + if (file.isDirectory()) { + currentPath += "/"; + } + + // THIS IS WHERE THE ERROR OCCURS, FOR THE FILE "st14-1.tiff" IN "test_bug446708" + zipWriter.addEntryFile( + currentPath, + Ci.nsIZipWriter.COMPRESSION_DEFAULT, + file, + false + ); + + // if it's a dir, continue adding its contents recursively... + if (file.isDirectory()) { + var entries = file.QueryInterface(Ci.nsIFile).directoryEntries; + while (entries.hasMoreElements()) { + var entry = entries.nextFile; + AddToZip(zipWriter, currentPath, entry); + } + } + + // ...otherwise, we're done +} + +function RecursivelyZipDirectory(bundle) { + zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE); + AddToZip(zipW, "", bundle); + zipW.close(); +} -- cgit v1.2.3