summaryrefslogtreecommitdiffstats
path: root/modules/libjar/zipwriter/test
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /modules/libjar/zipwriter/test
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'modules/libjar/zipwriter/test')
-rw-r--r--modules/libjar/zipwriter/test/unit/data/emptyfile.txt0
-rw-r--r--modules/libjar/zipwriter/test/unit/data/smallfile.txt1
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test.pngbin0 -> 3402 bytes
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test.txt5
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test.zipbin0 -> 3824 bytes
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test_bug399727.html160
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test_bug399727.zlibbin0 -> 1959 bytes
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test_bug446708/thumbs/st14-1.tiffbin0 -> 4940 bytes
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test_bug717061.gzbin0 -> 1275 bytes
-rw-r--r--modules/libjar/zipwriter/test/unit/data/test_bug717061.html16
-rw-r--r--modules/libjar/zipwriter/test/unit/head_zipwriter.js46
-rw-r--r--modules/libjar/zipwriter/test/unit/tail_zipwriter.js14
-rw-r--r--modules/libjar/zipwriter/test/unit/test_alignment.js113
-rw-r--r--modules/libjar/zipwriter/test/unit/test_asyncadd.js107
-rw-r--r--modules/libjar/zipwriter/test/unit/test_asyncbadadd.js35
-rw-r--r--modules/libjar/zipwriter/test/unit/test_asyncbadremove.js31
-rw-r--r--modules/libjar/zipwriter/test/unit/test_asyncremove.js47
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug399727.js86
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug419769_1.js70
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug419769_2.js64
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug425768.js31
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug433248.js73
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug446708.js37
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug467740.js29
-rw-r--r--modules/libjar/zipwriter/test/unit/test_bug717061.js92
-rw-r--r--modules/libjar/zipwriter/test/unit/test_createempty.js16
-rw-r--r--modules/libjar/zipwriter/test/unit/test_deflatedata.js53
-rw-r--r--modules/libjar/zipwriter/test/unit/test_directory.js27
-rw-r--r--modules/libjar/zipwriter/test/unit/test_editexisting.js62
-rw-r--r--modules/libjar/zipwriter/test/unit/test_storedata.js78
-rw-r--r--modules/libjar/zipwriter/test/unit/test_sync.js57
-rw-r--r--modules/libjar/zipwriter/test/unit/test_undochange.js42
-rw-r--r--modules/libjar/zipwriter/test/unit/test_zipcomment.js34
-rw-r--r--modules/libjar/zipwriter/test/unit/test_zippermissions.js83
-rw-r--r--modules/libjar/zipwriter/test/unit/xpcshell.ini37
35 files changed, 1546 insertions, 0 deletions
diff --git a/modules/libjar/zipwriter/test/unit/data/emptyfile.txt b/modules/libjar/zipwriter/test/unit/data/emptyfile.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/emptyfile.txt
diff --git a/modules/libjar/zipwriter/test/unit/data/smallfile.txt b/modules/libjar/zipwriter/test/unit/data/smallfile.txt
new file mode 100644
index 000000000..e068fcf81
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/smallfile.txt
@@ -0,0 +1 @@
+Small (16 bytes) \ No newline at end of file
diff --git a/modules/libjar/zipwriter/test/unit/data/test.png b/modules/libjar/zipwriter/test/unit/data/test.png
new file mode 100644
index 000000000..c648f7299
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test.png
Binary files differ
diff --git a/modules/libjar/zipwriter/test/unit/data/test.txt b/modules/libjar/zipwriter/test/unit/data/test.txt
new file mode 100644
index 000000000..1040981a3
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test.txt
@@ -0,0 +1,5 @@
+This is a test text file for the zipwriter component.
+It will be made available in the unit test directory.
+It will also be compressed into a testcase zip file
+made by a 3rd party zip tool to test the opening of
+existing zip files.
diff --git a/modules/libjar/zipwriter/test/unit/data/test.zip b/modules/libjar/zipwriter/test/unit/data/test.zip
new file mode 100644
index 000000000..96581fe8b
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test.zip
Binary files differ
diff --git a/modules/libjar/zipwriter/test/unit/data/test_bug399727.html b/modules/libjar/zipwriter/test/unit/data/test_bug399727.html
new file mode 100644
index 000000000..a6556274f
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test_bug399727.html
@@ -0,0 +1,160 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Content-Language" content="en-gb"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="generator" content="Fog Creek CityDesk 2.0.19"><meta name="citydesk" content="BB40F561/251"><title>TK's Sleater-Kinney pages</title><style type="text/css">
+<!--
+body {
+ font-family: verdana, arial;
+ font-size: 10pt;
+ color: black;
+ background-color: #D0E8E8;
+}
+td {
+ font-family: verdana, arial;
+ font-size: 10pt;
+}
+hr {
+ color: #808080;
+ height: 1px;
+}
+caption {
+ font-family: verdana, arial;
+ font-size: 8pt;
+ color: #808080;
+ background-color: white;
+}
+.bigText {
+ font-family: verdana, arial;
+ font-size: 18pt;
+ font-weight: bold;
+ color: black;
+ padding-bottom: 10px;
+}
+.smallText {
+ font-family: verdana, arial;
+ font-size: 7pt;
+ color: #808080;
+}
+.tabText {
+ font-family: Courier, "Courier New", monospace;
+ font-size: 7pt;
+ color: #808080;
+}
+.emphasis
+{
+ font-weight: bold;
+ color: #000000;
+}
+.articleHeader {
+ padding-bottom: 4px;
+ border-bottom: #808080 dotted 1px;
+}
+.headerCell {
+ background-color: #689090;
+ color: white;
+ padding: 4px;
+}
+.navbarText {
+ color: white;
+ font-weight: bold;
+}
+.articleTable {
+ border: #808080 solid 1px;
+ background-color: white;
+ padding: 15px;
+}
+
+
+
+-->
+</style></head><body>
+
+
+
+
+
+
+
+
+
+
+<div align="center">
+ <center>
+ <table border="0" cellpadding="0" cellspacing="0" width="700">
+ <tbody><tr>
+ <td><p class="bigText">TK's Sleater-Kinney pages</p>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <table class="articleTable" border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tbody><tr>
+ <td class="headerCell" align="right"><p class="navbarText">
+ : <a class="navbarText" href="http://tk-jk.net/S-K/index.html"> <span class="1home">Home</span></a>
+ : <a class="navbarText" href="http://tk-jk.net/S-K/blog/general/Archive.html"> <span class="2archive">Archive</span></a>
+ : <a class="navbarText" href="http://tk-jk.net/S-K/blog/general/Tabs.html"> <span class="3tabs">Tabs</span></a>
+ : <a class="navbarText" href="http://tk-jk.net/S-K/blog/general/Drumtabs.html"> <span class="4drumtabs">Drum tabs</span></a>
+ : <a class="navbarText" href="http://tk-jk.net/S-K/blog/general/SetLists.html"> <span class="5setlists">Set Lists</span></a>
+ : <a class="navbarText" href="http://tk-jk.net/S-K/blog/general/About.html"> <span class="6about">About</span></a> :
+</p>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <div align="left">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tbody><tr>
+ <td width="100%">
+<p class="bigText"><strong>All Hands on the Bad One</strong>
+</p>
+<p></p><p><strong>All Hands on the Bad One, <em>"All Hands on the Bad One"</em></strong></p>
+<p dir="ltr">This, followed by <a href="http://tk-jk.net/S-K/Tabs/YouthDecay.html">Youth Decay</a>&nbsp;- wow - most bands would be happy just to have just one of these songs.&nbsp; S-K has a boatload.</p>
+<p dir="ltr">Tabbing this was very frustrating.&nbsp;Riff 3 is a
+masterpiece of guitar and vocal harmony, rhythm and guitar
+interplay.&nbsp; It has a bass intro and stacks guitars and vocals on
+top. This is the definition of Sleater-Kinney magic. You can't&nbsp;get
+it all done on two guitars.&nbsp; You can get close.&nbsp;&nbsp; I
+haven't done it justice.</p>
+<p dir="ltr">As usual the guitar 2's rhythms are vital to the S-K sound.&nbsp; It's still good if you don't get it just right.</p>
+<p dir="ltr">I sure hope I've done this well enough for you to figure out.</p>
+<ul dir="ltr">
+<li>
+<div style="margin-right: 0px;">Quarter note =&nbsp;153 or so.</div>
+</li><li>
+<div style="margin-right: 0px;">Standard tuning. But tuning down 3 half steps makes Riff 3 easier and more authentic.</div>
+</li><li>
+<div style="margin-right: 0px;">Tabbed&nbsp;where it felt good&nbsp;on the fretboard but there are alternatives.</div>
+</li><li>
+<div style="margin-right: 0px;">Tuning down is required for authenticity but it sounds great in standard tuning</div></li></ul><strong>
+</strong><p dir="ltr"><strong><br>1:</strong></p>
+<p></p><span><img alt="All Hands on the Bad One Riff 1" src="AllHandsontheBadOne_files/AHOTBO1.jpg" cd:pos="2" align="left" border="0" height="500" hspace="4" width="580"><br clear="all"></span>
+<p><strong></strong>&nbsp;</p>
+<p><strong>2:</strong></p><span><img alt="All Hands on the Bad One Riff 2" src="AllHandsontheBadOne_files/AHOTBO2.jpg" cd:pos="2" align="left" border="0" height="257" hspace="4" width="580"><br clear="all"></span>
+<p><strong></strong>&nbsp;</p>
+<p><strong>Riff 3 (3a and 3b) is a little masterpeice:</strong></p><span><img alt="All Hands on the Bad One Riff 3a" src="AllHandsontheBadOne_files/AHOTBO3a.jpg" cd:pos="2" align="left" border="0" height="446" hspace="4" width="580"><br clear="all"></span>
+<p><span><img alt="All Hands on the Bad One Riff 3b" src="AllHandsontheBadOne_files/AHOTBO3b.jpg" cd:pos="2" align="left" border="0" height="179" hspace="4" width="580"><br clear="all"></span></p>
+<p>&nbsp;</p>
+<p>The Outro</p>
+<p><span><img alt="All Hands on the Bad One Riff 4" src="AllHandsontheBadOne_files/AHOTBO4.jpg" cd:pos="2" align="left" border="0" height="216" hspace="4" width="580"><br clear="all"></span></p><p></p>
+ </td>
+ </tr>
+ </tbody></table>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <hr>
+ <center>
+ <div class="smallText">
+ The views expressed within this site pretty much represent those of the author.<br>
+ Copyright (c) 2002 <a href="http://tk-jk.net/">Terry Kearns</a>. All rights reserved.
+ </div>
+ </center>
+ </td>
+ </tr>
+ </tbody></table>
+ </td>
+ </tr>
+ </tbody></table>
+ </center>
+</div>
+</body></html> \ No newline at end of file
diff --git a/modules/libjar/zipwriter/test/unit/data/test_bug399727.zlib b/modules/libjar/zipwriter/test/unit/data/test_bug399727.zlib
new file mode 100644
index 000000000..080b63c52
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test_bug399727.zlib
Binary files differ
diff --git a/modules/libjar/zipwriter/test/unit/data/test_bug446708/thumbs/st14-1.tiff b/modules/libjar/zipwriter/test/unit/data/test_bug446708/thumbs/st14-1.tiff
new file mode 100644
index 000000000..6b0465758
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test_bug446708/thumbs/st14-1.tiff
Binary files differ
diff --git a/modules/libjar/zipwriter/test/unit/data/test_bug717061.gz b/modules/libjar/zipwriter/test/unit/data/test_bug717061.gz
new file mode 100644
index 000000000..f990c6e51
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test_bug717061.gz
Binary files differ
diff --git a/modules/libjar/zipwriter/test/unit/data/test_bug717061.html b/modules/libjar/zipwriter/test/unit/data/test_bug717061.html
new file mode 100644
index 000000000..80ce0319b
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/data/test_bug717061.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Content-Language" content="en-us"><title>Lorem Ipsum</title><style type="text/css">
+body {
+ font-family: verdana, arial;
+ font-size: 10pt;
+ color: black;
+ background-color: #D0E8E8;
+}
+</style></head><body>
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
+
+<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
+
+</body></html>
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 000000000..bc77455a5
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/head_zipwriter.js
@@ -0,0 +1,46 @@
+/* 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/.
+ */
+
+var Ci = Components.interfaces;
+var Cc = Components.classes;
+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/";
+
+var ioSvc = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+
+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();
diff --git a/modules/libjar/zipwriter/test/unit/tail_zipwriter.js b/modules/libjar/zipwriter/test/unit/tail_zipwriter.js
new file mode 100644
index 000000000..033cc23c2
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/tail_zipwriter.js
@@ -0,0 +1,14 @@
+/* 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/.
+ */
+
+try {
+ zipW.close();
+}
+catch (e) {
+ // Just ignore a failure here and attempt to delete the file anyway.
+}
+
+if (tmpFile.exists())
+ tmpFile.remove(true);
diff --git a/modules/libjar/zipwriter/test/unit/test_alignment.js b/modules/libjar/zipwriter/test/unit/test_alignment.js
new file mode 100644
index 000000000..da497253c
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_alignment.js
@@ -0,0 +1,113 @@
+/* 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 DATA = "ZIP WRITER TEST DATA";
+const FILENAME = "test_data.txt";
+const CRC = 0xe6164331;
+const time = 1199145600000; // Jan 1st 2008
+
+var TESTS = [
+ {
+ name: "test.txt",
+ compression: Ci.nsIZipWriter.COMPRESSION_DEFAULT
+ },
+ {
+ name: "test.png",
+ compression: Ci.nsIZipWriter.COMPRESSION_NONE
+ }
+];
+
+function swap16(n)
+{
+ return (((n >> 8) & 0xFF) << 0) |
+ (((n >> 0) & 0xFF) << 8);
+}
+
+function swap32(n)
+{
+ return (((n >> 24) & 0xFF) << 0) |
+ (((n >> 16) & 0xFF) << 8) |
+ (((n >> 8) & 0xFF) << 16) |
+ (((n >> 0) & 0xFF) << 24);
+}
+
+function move_to_data(bis, offset)
+{
+ bis.readBytes(18); // Move to compressed size
+ var size = swap32(bis.read32());
+ bis.readBytes(4);
+ var file_len = swap16(bis.read16());
+ var extra_len = swap16(bis.read16());
+ var file = bis.readBytes(file_len);
+ bis.readBytes(extra_len);
+ offset += ZIP_FILE_HEADER_SIZE + file_len + extra_len;
+
+ return {offset: offset, size: size};
+}
+
+function test_alignment(align_size)
+{
+ // Create zip for testing.
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR + TESTS[i].name);
+ zipW.addEntryFile(TESTS[i].name, TESTS[i].compression, source, false);
+ }
+ var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+ .createInstance(Ci.nsIStringInputStream);
+ stream.setData(DATA, DATA.length);
+ zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
+ Ci.nsIZipWriter.COMPRESSION_NONE, stream, false);
+ zipW.alignStoredFiles(align_size);
+ zipW.close();
+
+ // Check data can be decompressed.
+ var zipR = new ZipReader(tmpFile);
+ var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ stream.init(zipR.getInputStream(FILENAME));
+ var result = stream.read(DATA.length);
+ do_check_eq(result, DATA);
+ stream.close();
+ zipR.close();
+
+ // Check data is correct and aligned.
+ var fis = Cc["@mozilla.org/network/file-input-stream;1"]
+ .createInstance(Ci.nsIFileInputStream);
+ fis.init(tmpFile, -1, -1, null);
+ let bis = Cc["@mozilla.org/binaryinputstream;1"]
+ .createInstance(Ci.nsIBinaryInputStream);
+ bis.setInputStream(fis);
+ var offset = 0;
+
+ var ret = move_to_data(bis, offset); // "test.txt"
+ offset = ret.offset;
+ bis.readBytes(ret.size);
+ offset += ret.size;
+
+ ret = move_to_data(bis, offset); // "test.png"
+ offset = ret.offset;
+ do_check_eq(offset % align_size, 0);
+ bis.readBytes(ret.size);
+ offset += ret.size;
+
+ ret = move_to_data(bis, offset); // "test_data.txt"
+ offset = ret.offset;
+ var result = bis.readBytes(DATA.length);
+ do_check_eq(result, DATA);
+ do_check_eq(offset % align_size, 0);
+
+ fis.close();
+ bis.close();
+}
+
+function run_test()
+{
+ test_alignment(2);
+ test_alignment(4);
+ test_alignment(16);
+ test_alignment(4096);
+ test_alignment(32768);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_asyncadd.js b/modules/libjar/zipwriter/test/unit/test_asyncadd.js
new file mode 100644
index 000000000..a6659f61a
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_asyncadd.js
@@ -0,0 +1,107 @@
+/* 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/.
+ */
+
+var Cu = Components.utils;
+Cu.import("resource://gre/modules/NetUtil.jsm");
+
+// Values taken from using zipinfo to list the test.zip contents
+var TESTS = [
+ {
+ name: "test.txt",
+ size: 232,
+ crc: 0x0373ac26
+ },
+ {
+ name: "test.png",
+ size: 3402,
+ crc: 0x504a5c30
+ }
+];
+
+var size = 0;
+
+var observer = {
+ onStartRequest: function(request, context)
+ {
+ },
+
+ onStopRequest: function(request, context, status)
+ {
+ do_check_eq(status, Components.results.NS_OK);
+
+ zipW.close();
+ size += ZIP_EOCDR_HEADER_SIZE;
+
+ do_check_eq(size, tmpFile.fileSize);
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR + TESTS[i].name);
+ for (let method in methods) {
+ var entryName = method + "/" + TESTS[i].name;
+ do_check_true(zipR.hasEntry(entryName));
+
+ var entry = zipR.getEntry(entryName);
+ do_check_eq(entry.realSize, TESTS[i].size);
+ do_check_eq(entry.size, TESTS[i].size);
+ do_check_eq(entry.CRC32, TESTS[i].crc);
+ do_check_eq(Math.floor(entry.lastModifiedTime / PR_USEC_PER_SEC),
+ Math.floor(source.lastModifiedTime / PR_MSEC_PER_SEC));
+
+ zipR.test(entryName);
+ }
+ }
+
+ zipR.close();
+ do_test_finished();
+ }
+};
+
+var methods = {
+ file: function method_file(entry, source)
+ {
+ zipW.addEntryFile(entry, Ci.nsIZipWriter.COMPRESSION_NONE, source,
+ true);
+ },
+ channel: function method_channel(entry, source)
+ {
+ zipW.addEntryChannel(entry, source.lastModifiedTime * PR_MSEC_PER_SEC,
+ Ci.nsIZipWriter.COMPRESSION_NONE,
+ NetUtil.newChannel({
+ uri: ioSvc.newFileURI(source),
+ loadUsingSystemPrincipal: true
+ }), true);
+ },
+ stream: function method_stream(entry, source)
+ {
+ zipW.addEntryStream(entry, source.lastModifiedTime * PR_MSEC_PER_SEC,
+ Ci.nsIZipWriter.COMPRESSION_NONE,
+ NetUtil.newChannel({
+ uri: ioSvc.newFileURI(source),
+ loadUsingSystemPrincipal: true
+ }).open2(), true);
+ }
+}
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR+TESTS[i].name);
+ for (let method in methods) {
+ var entry = method + "/" + TESTS[i].name;
+ methods[method](entry, source);
+ size += ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
+ (ZIP_EXTENDED_TIMESTAMP_SIZE * 2) +
+ (entry.length*2) + TESTS[i].size;
+ }
+ }
+ do_test_pending();
+ zipW.processQueue(observer, null);
+ do_check_true(zipW.inQueue);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_asyncbadadd.js b/modules/libjar/zipwriter/test/unit/test_asyncbadadd.js
new file mode 100644
index 000000000..2f8ebe644
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_asyncbadadd.js
@@ -0,0 +1,35 @@
+/* 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 FILENAME = "missing.txt";
+
+var observer = {
+ onStartRequest: function(request, context)
+ {
+ },
+
+ onStopRequest: function(request, context, status)
+ {
+ do_check_eq(status, Components.results.NS_ERROR_FILE_NOT_FOUND);
+ zipW.close();
+ do_check_eq(ZIP_EOCDR_HEADER_SIZE, tmpFile.fileSize);
+ do_test_finished();
+ }
+};
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ var source = tmpDir.clone();
+ source.append(FILENAME);
+ zipW.addEntryFile(FILENAME, Ci.nsIZipWriter.COMPRESSION_NONE, source, true);
+
+ do_test_pending();
+ zipW.processQueue(observer, null);
+
+ // With nothing to actually do the queue would have completed immediately
+ do_check_false(zipW.inQueue);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_asyncbadremove.js b/modules/libjar/zipwriter/test/unit/test_asyncbadremove.js
new file mode 100644
index 000000000..609d4345d
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_asyncbadremove.js
@@ -0,0 +1,31 @@
+/* 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 FILENAME = "missing.txt";
+
+var observer = {
+ onStartRequest: function(request, context)
+ {
+ },
+
+ onStopRequest: function(request, context, status)
+ {
+ do_check_eq(status, Components.results.NS_ERROR_FILE_NOT_FOUND);
+ zipW.close();
+ do_check_eq(ZIP_EOCDR_HEADER_SIZE, tmpFile.fileSize);
+ do_test_finished();
+ }
+};
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+ zipW.removeEntry(FILENAME, true);
+ do_test_pending();
+ zipW.processQueue(observer, null);
+
+ // With nothing to actually do the queue would have completed immediately
+ do_check_false(zipW.inQueue);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_asyncremove.js b/modules/libjar/zipwriter/test/unit/test_asyncremove.js
new file mode 100644
index 000000000..c44ff3354
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_asyncremove.js
@@ -0,0 +1,47 @@
+/* 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/.
+ */
+
+var TESTS = [
+ "test.txt",
+ "test.png"
+];
+
+var observer = {
+ onStartRequest: function(request, context)
+ {
+ },
+
+ onStopRequest: function(request, context, status)
+ {
+ do_check_eq(status, Components.results.NS_OK);
+
+ zipW.close();
+
+ // Empty zip file should just be the end of central directory marker
+ var newTmpFile = tmpFile.clone();
+ do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
+ do_test_finished();
+ }
+};
+
+function run_test()
+{
+ // Copy our test zip to the tmp dir so we can modify it
+ var testzip = do_get_file(DATA_DIR + "test.zip");
+ testzip.copyTo(tmpDir, tmpFile.leafName);
+
+ do_check_true(tmpFile.exists());
+
+ zipW.open(tmpFile, PR_RDWR);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ do_check_true(zipW.hasEntry(TESTS[i]));
+ zipW.removeEntry(TESTS[i], true);
+ }
+
+ do_test_pending();
+ zipW.processQueue(observer, null);
+ do_check_true(zipW.inQueue);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug399727.js b/modules/libjar/zipwriter/test/unit/test_bug399727.js
new file mode 100644
index 000000000..065cacae3
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug399727.js
@@ -0,0 +1,86 @@
+/* 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/.
+ */
+
+function BinaryComparer(file, callback) {
+ var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fstream.init(file, -1, 0, 0);
+ this.length = file.fileSize;
+ this.fileStream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ this.fileStream.setInputStream(fstream);
+ this.offset = 0;
+ this.callback = callback;
+}
+
+BinaryComparer.prototype = {
+ fileStream: null,
+ offset: null,
+ length: null,
+ callback: null,
+
+ onStartRequest: function(aRequest, aContext) {
+ },
+
+ onStopRequest: function(aRequest, aContext, aStatusCode) {
+ this.fileStream.close();
+ do_check_eq(aStatusCode, Components.results.NS_OK);
+ do_check_eq(this.offset, this.length);
+ this.callback();
+ },
+
+ onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+ var stream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ stream.setInputStream(aInputStream);
+ var source, actual;
+ for (var i = 0; i < aCount; i++) {
+ try {
+ source = this.fileStream.read8();
+ }
+ catch (e) {
+ do_throw("Unable to read from file at offset " + this.offset + " " + e);
+ }
+ try {
+ actual = stream.read8();
+ }
+ catch (e) {
+ do_throw("Unable to read from converted stream at offset " + this.offset + " " + e);
+ }
+ if (source != actual)
+ do_throw("Invalid value " + actual + " at offset " + this.offset + ", should have been " + source);
+ this.offset++;
+ }
+ }
+}
+
+function comparer_callback()
+{
+ do_test_finished();
+}
+
+function run_test()
+{
+ var source = do_get_file(DATA_DIR + "test_bug399727.html");
+ var comparer = new BinaryComparer(do_get_file(DATA_DIR + "test_bug399727.zlib"),
+ comparer_callback);
+
+ // Prepare the stream converter
+ var scs = Cc["@mozilla.org/streamConverters;1"].
+ getService(Ci.nsIStreamConverterService);
+ var converter = scs.asyncConvertData("uncompressed", "deflate", comparer, null);
+
+ // Open the expected output file
+ var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fstream.init(source, -1, 0, 0);
+
+ // Set up a pump to push data from the file to the stream converter
+ var pump = Cc["@mozilla.org/network/input-stream-pump;1"].
+ createInstance(Ci.nsIInputStreamPump);
+ pump.init(fstream, -1, -1, 0, 0, true);
+ pump.asyncRead(converter, null);
+ do_test_pending();
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug419769_1.js b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js
new file mode 100644
index 000000000..cd81a31c3
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js
@@ -0,0 +1,70 @@
+/* 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 DATA = "";
+const FILENAME = "test.txt";
+const CRC = 0x00000000;
+// XXX Must use a constant time here away from DST changes. See bug 402434.
+const time = 1199145600000; // Jan 1st 2008
+
+function testpass(source)
+{
+ // Should exist.
+ do_check_true(source.hasEntry(FILENAME));
+
+ var entry = source.getEntry(FILENAME);
+ do_check_neq(entry, null);
+
+ do_check_false(entry.isDirectory);
+
+ // Should be stored
+ do_check_eq(entry.compression, ZIP_METHOD_DEFLATE);
+
+ do_check_eq(entry.lastModifiedTime / PR_USEC_PER_MSEC, time);
+
+ // File size should match our data size.
+ do_check_eq(entry.realSize, DATA.length);
+
+ // Check that the CRC is accurate
+ do_check_eq(entry.CRC32, CRC);
+}
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ // Shouldn't be there to start with.
+ do_check_false(zipW.hasEntry(FILENAME));
+
+ do_check_false(zipW.inQueue);
+
+ var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+ .createInstance(Ci.nsIStringInputStream);
+ stream.setData(DATA, DATA.length);
+ zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
+ Ci.nsIZipWriter.COMPRESSION_BEST, stream, false);
+
+ // Check that zip state is right at this stage.
+ testpass(zipW);
+ zipW.close();
+
+ // Check to see if we get the same results loading afresh.
+ zipW.open(tmpFile, PR_RDWR);
+ testpass(zipW);
+ zipW.close();
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+ testpass(zipR);
+ zipR.test(FILENAME);
+ var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ stream.init(zipR.getInputStream(FILENAME));
+ var result = stream.read(DATA.length);
+ stream.close();
+ zipR.close();
+
+ do_check_eq(result, DATA);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug419769_2.js b/modules/libjar/zipwriter/test/unit/test_bug419769_2.js
new file mode 100644
index 000000000..f46ab395e
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug419769_2.js
@@ -0,0 +1,64 @@
+/* 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 DATA = "";
+const FILENAME = "test.txt";
+const CRC = 0x00000000;
+const time = Date.now();
+
+function testpass(source)
+{
+ // Should exist.
+ do_check_true(source.hasEntry(FILENAME));
+
+ var entry = source.getEntry(FILENAME);
+ do_check_neq(entry, null);
+
+ do_check_false(entry.isDirectory);
+
+ // Should be stored
+ do_check_eq(entry.compression, ZIP_METHOD_DEFLATE);
+
+ // File size should match our data size.
+ do_check_eq(entry.realSize, DATA.length);
+
+ // Check that the CRC is accurate
+ do_check_eq(entry.CRC32, CRC);
+}
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ // Shouldn't be there to start with.
+ do_check_false(zipW.hasEntry(FILENAME));
+
+ do_check_false(zipW.inQueue);
+
+ var file = do_get_file(DATA_DIR + "emptyfile.txt");
+ zipW.addEntryFile(FILENAME, Ci.nsIZipWriter.COMPRESSION_BEST, file, false);
+
+ // Check that zip state is right at this stage.
+ testpass(zipW);
+ zipW.close();
+
+ // Check to see if we get the same results loading afresh.
+ zipW.open(tmpFile, PR_RDWR);
+ testpass(zipW);
+ zipW.close();
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+ testpass(zipR);
+ zipR.test(FILENAME);
+ var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ stream.init(zipR.getInputStream(FILENAME));
+ var result = stream.read(DATA.length);
+ stream.close();
+ zipR.close();
+
+ do_check_eq(result, DATA);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug425768.js b/modules/libjar/zipwriter/test/unit/test_bug425768.js
new file mode 100644
index 000000000..f59767342
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug425768.js
@@ -0,0 +1,31 @@
+/* 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 DIRNAME = "test/";
+const time = Date.now();
+
+function run_test()
+{
+ // Copy in the test file.
+ var source = do_get_file("data/test.zip");
+ source.copyTo(tmpFile.parent, tmpFile.leafName);
+
+ // Open it and add something so the CDS is rewritten.
+ zipW.open(tmpFile, PR_RDWR | PR_APPEND);
+ zipW.addEntryDirectory(DIRNAME, time * PR_USEC_PER_MSEC, false);
+ do_check_true(zipW.hasEntry(DIRNAME));
+ zipW.close();
+
+ var zipR = new ZipReader(tmpFile);
+ do_check_true(zipR.hasEntry(DIRNAME));
+ zipR.close();
+
+ // Adding the directory would have added a fixed amount to the file size.
+ // Any difference suggests the CDS was written out incorrectly.
+ var extra = ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
+ (DIRNAME.length * 2) + (ZIP_EXTENDED_TIMESTAMP_SIZE * 2);
+
+ do_check_eq(source.fileSize + extra, tmpFile.fileSize);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug433248.js b/modules/libjar/zipwriter/test/unit/test_bug433248.js
new file mode 100644
index 000000000..15f2e4970
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug433248.js
@@ -0,0 +1,73 @@
+/* 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/.
+ */
+
+function run_test()
+{
+ var test;
+ // zipW is an uninitialised zipwriter at this point.
+ try {
+ test = zipW.file;
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ test = zipW.comment;
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.comment = "test";
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.addEntryDirectory("test", 0, false);
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.addEntryFile("test", Ci.nsIZipWriter.COMPRESSION_DEFAULT, tmpDir, false);
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.removeEntry("test", false);
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.processQueue(null, null);
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+
+ try {
+ zipW.close();
+ do_throw("Should have thrown uninitialized error.");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_NOT_INITIALIZED);
+ }
+}
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 000000000..2b4e7a0ce
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug446708.js
@@ -0,0 +1,37 @@
+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(Components.interfaces.nsIFile).directoryEntries;
+ while (entries.hasMoreElements()) {
+ var entry = entries.getNext().QueryInterface(Components.interfaces.nsIFile);
+ 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();
+}
+
diff --git a/modules/libjar/zipwriter/test/unit/test_bug467740.js b/modules/libjar/zipwriter/test/unit/test_bug467740.js
new file mode 100644
index 000000000..cdb2b6042
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug467740.js
@@ -0,0 +1,29 @@
+/* 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/.
+ */
+
+function run_test()
+{
+ // In this test we try to open some files that aren't archives:
+ // - An empty file, that is certainly not an archive.
+ // - A file that couldn't be mistaken for archive, since it is too small.
+ // - A file that could be mistaken for archive, if we checked only the file
+ // size, but is invalid since it contains no ZIP signature.
+ var invalidArchives = ["emptyfile.txt", "smallfile.txt", "test.png"];
+
+ invalidArchives.forEach(function(invalidArchive) {
+ // Get a reference to the invalid file
+ var invalidFile = do_get_file(DATA_DIR + invalidArchive);
+
+ // Opening the invalid file should fail (but not crash)
+ try {
+ zipW.open(invalidFile, PR_RDWR);
+ do_throw("Should have thrown NS_ERROR_FILE_CORRUPTED on " +
+ invalidArchive + " !");
+ } catch (e if (e instanceof Ci.nsIException &&
+ e.result == Components.results.NS_ERROR_FILE_CORRUPTED)) {
+ // do nothing
+ }
+ });
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_bug717061.js b/modules/libjar/zipwriter/test/unit/test_bug717061.js
new file mode 100644
index 000000000..35163a464
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_bug717061.js
@@ -0,0 +1,92 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0
+ */
+
+function BinaryComparer(file, callback) {
+ var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fstream.init(file, -1, 0, 0);
+ this.length = file.fileSize;
+ this.fileStream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ this.fileStream.setInputStream(fstream);
+ this.offset = 0;
+ this.callback = callback;
+}
+
+BinaryComparer.prototype = {
+ fileStream: null,
+ offset: null,
+ length: null,
+ callback: null,
+
+ onStartRequest: function(aRequest, aContext) {
+ },
+
+ onStopRequest: function(aRequest, aContext, aStatusCode) {
+ this.fileStream.close();
+ do_check_eq(aStatusCode, Components.results.NS_OK);
+ do_check_eq(this.offset, this.length);
+ this.callback();
+ },
+
+ onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+ var stream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ stream.setInputStream(aInputStream);
+ var source, actual;
+ for (var i = 0; i < aCount; i++) {
+ try {
+ source = this.fileStream.read8();
+ }
+ catch (e) {
+ do_throw("Unable to read from file at offset " + this.offset + " " + e);
+ }
+ try {
+ actual = stream.read8();
+ }
+ catch (e) {
+ do_throw("Unable to read from converted stream at offset " + this.offset + " " + e);
+ }
+ // The byte at offset 9 is the OS byte (see RFC 1952, section 2.3), which
+ // can legitimately differ when the source is compressed on different
+ // operating systems. The actual .gz for this test was created on a Unix
+ // system, but we want the test to work correctly everywhere. So ignore
+ // the byte at offset 9.
+ if (this.offset == 9)
+ ;
+ else if (source != actual)
+ do_throw("Invalid value " + actual + " at offset " + this.offset + ", should have been " + source);
+ this.offset++;
+ }
+ }
+}
+
+function comparer_callback()
+{
+ do_test_finished();
+}
+
+function run_test()
+{
+ var source = do_get_file(DATA_DIR + "test_bug717061.html");
+ var comparer = new BinaryComparer(do_get_file(DATA_DIR + "test_bug717061.gz"),
+ comparer_callback);
+
+ // Prepare the stream converter
+ var scs = Cc["@mozilla.org/streamConverters;1"].
+ getService(Ci.nsIStreamConverterService);
+ var converter = scs.asyncConvertData("uncompressed", "gzip", comparer, null);
+
+ // Open the expected output file
+ var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+ fstream.init(source, -1, 0, 0);
+
+ // Set up a pump to push data from the file to the stream converter
+ var pump = Cc["@mozilla.org/network/input-stream-pump;1"].
+ createInstance(Ci.nsIInputStreamPump);
+ pump.init(fstream, -1, -1, 0, 0, true);
+ pump.asyncRead(converter, null);
+ do_test_pending();
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_createempty.js b/modules/libjar/zipwriter/test/unit/test_createempty.js
new file mode 100644
index 000000000..4de1992e4
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_createempty.js
@@ -0,0 +1,16 @@
+/* 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/.
+ */
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+ zipW.close();
+
+ // Should have created a zip file
+ do_check_true(tmpFile.exists());
+
+ // Empty zip file should just be the end of central directory marker
+ do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_deflatedata.js b/modules/libjar/zipwriter/test/unit/test_deflatedata.js
new file mode 100644
index 000000000..6c0f39bc2
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_deflatedata.js
@@ -0,0 +1,53 @@
+/* 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 DATA = "ZIP WRITER TEST DATA";
+const FILENAME = "test.txt";
+const CRC = 0xe6164331;
+// XXX Must use a constant time here away from DST changes. See bug 402434.
+const time = 1199145600000; // Jan 1st 2008
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ // Shouldn't be there to start with.
+ do_check_false(zipW.hasEntry(FILENAME));
+
+ do_check_false(zipW.inQueue);
+
+ var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+ .createInstance(Ci.nsIStringInputStream);
+ stream.setData(DATA, DATA.length);
+ zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
+ Ci.nsIZipWriter.COMPRESSION_BEST, stream, false);
+
+ var entry = zipW.getEntry(FILENAME);
+
+ do_check_true(entry != null);
+
+ // Check entry seems right.
+ do_check_eq(entry.compression, ZIP_METHOD_DEFLATE);
+ do_check_eq(entry.CRC32, CRC);
+ do_check_eq(entry.realSize, DATA.length);
+ do_check_eq(entry.lastModifiedTime / PR_USEC_PER_MSEC, time);
+
+ zipW.close();
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+ do_check_true(zipR.hasEntry(FILENAME));
+
+ zipR.test(FILENAME);
+
+ var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ stream.init(zipR.getInputStream(FILENAME));
+ var result = stream.read(DATA.length);
+ stream.close();
+ zipR.close();
+
+ do_check_eq(result, DATA);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_directory.js b/modules/libjar/zipwriter/test/unit/test_directory.js
new file mode 100644
index 000000000..3196ebed9
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_directory.js
@@ -0,0 +1,27 @@
+/* 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 DIRNAME1 = "test";
+const DIRNAME1_CORRECT = "test/";
+const DIRNAME2 = "test2/";
+const time = Date.now();
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ zipW.addEntryDirectory(DIRNAME1, time * PR_USEC_PER_MSEC, false);
+ do_check_false(zipW.hasEntry(DIRNAME1));
+ do_check_true(zipW.hasEntry(DIRNAME1_CORRECT));
+ var entry = zipW.getEntry(DIRNAME1_CORRECT);
+ do_check_true(entry.isDirectory);
+
+ zipW.addEntryDirectory(DIRNAME2, time * PR_USEC_PER_MSEC, false);
+ do_check_true(zipW.hasEntry(DIRNAME2));
+ entry = zipW.getEntry(DIRNAME2);
+ do_check_true(entry.isDirectory);
+
+ zipW.close();
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_editexisting.js b/modules/libjar/zipwriter/test/unit/test_editexisting.js
new file mode 100644
index 000000000..84b20690b
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_editexisting.js
@@ -0,0 +1,62 @@
+/* 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/.
+ */
+
+// Values taken from using zipinfo to list the test.zip contents
+var TESTS = [
+ {
+ name: "test.txt",
+ size: 232,
+ crc: 0x0373ac26,
+ time: Date.UTC(2007, 4, 1, 20, 44, 55)
+ },
+ {
+ name: "test.png",
+ size: 3402,
+ crc: 0x504a5c30,
+ time: Date.UTC(2007, 4, 1, 20, 49, 39)
+ }
+];
+var BADENTRY = "unknown.txt";
+
+function run_test()
+{
+ // Copy our test zip to the tmp dir so we can modify it
+ var testzip = do_get_file(DATA_DIR + "test.zip");
+ testzip.copyTo(tmpDir, tmpFile.leafName);
+
+ do_check_true(tmpFile.exists());
+
+ zipW.open(tmpFile, PR_RDWR);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ do_check_true(zipW.hasEntry(TESTS[i].name));
+ var entry = zipW.getEntry(TESTS[i].name);
+ do_check_true(entry != null);
+
+ do_check_eq(entry.realSize, TESTS[i].size);
+ do_check_eq(entry.CRC32, TESTS[i].crc);
+ do_check_eq(entry.lastModifiedTime / PR_USEC_PER_MSEC, TESTS[i].time);
+ }
+
+ try {
+ zipW.removeEntry(BADENTRY, false);
+ do_throw("shouldn't be able to remove an entry that doesn't exist");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_FILE_NOT_FOUND);
+ }
+
+ for (var i = 0; i < TESTS.length; i++) {
+ zipW.removeEntry(TESTS[i].name, false);
+ }
+
+ zipW.close();
+
+ // Certain platforms cache the file size so get a fresh file to check.
+ tmpFile = tmpFile.clone();
+
+ // Empty zip file should just be the end of central directory marker
+ do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_storedata.js b/modules/libjar/zipwriter/test/unit/test_storedata.js
new file mode 100644
index 000000000..d3fbc6ba5
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_storedata.js
@@ -0,0 +1,78 @@
+/* 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 DATA = "ZIP WRITER TEST DATA";
+const FILENAME = "test.txt";
+const FILENAME2 = "test2.txt";
+const CRC = 0xe6164331;
+// XXX Must use a constant time here away from DST changes. See bug 402434.
+const time = 1199145600000; // Jan 1st 2008
+
+function testpass(source)
+{
+ // Should exist.
+ do_check_true(source.hasEntry(FILENAME));
+
+ var entry = source.getEntry(FILENAME);
+ do_check_neq(entry, null);
+
+ do_check_false(entry.isDirectory);
+
+ // Should be stored
+ do_check_eq(entry.compression, ZIP_METHOD_STORE);
+
+ do_check_eq(entry.lastModifiedTime / PR_USEC_PER_MSEC, time);
+
+ // File size should match our data size.
+ do_check_eq(entry.realSize, DATA.length);
+ // When stored sizes should match.
+ do_check_eq(entry.size, entry.realSize);
+
+ // Check that the CRC is accurate
+ do_check_eq(entry.CRC32, CRC);
+}
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ // Shouldn't be there to start with.
+ do_check_false(zipW.hasEntry(FILENAME));
+
+ do_check_false(zipW.inQueue);
+
+ var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+ .createInstance(Ci.nsIStringInputStream);
+ stream.setData(DATA, DATA.length);
+ zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
+ Ci.nsIZipWriter.COMPRESSION_NONE, stream, false);
+
+ // Check that zip state is right at this stage.
+ testpass(zipW);
+ zipW.close();
+
+ do_check_eq(tmpFile.fileSize,
+ DATA.length + ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
+ (ZIP_EXTENDED_TIMESTAMP_SIZE * 2) +
+ (FILENAME.length * 2) + ZIP_EOCDR_HEADER_SIZE);
+
+ // Check to see if we get the same results loading afresh.
+ zipW.open(tmpFile, PR_RDWR);
+ testpass(zipW);
+ zipW.close();
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+ testpass(zipR);
+ zipR.test(FILENAME);
+ var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ stream.init(zipR.getInputStream(FILENAME));
+ var result = stream.read(DATA.length);
+ stream.close();
+ zipR.close();
+
+ do_check_eq(result, DATA);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_sync.js b/modules/libjar/zipwriter/test/unit/test_sync.js
new file mode 100644
index 000000000..b2b6e7f6e
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_sync.js
@@ -0,0 +1,57 @@
+/* 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/.
+ */
+
+// Values taken from using zipinfo to list the test.zip contents
+var TESTS = [
+ {
+ name: "test.txt",
+ size: 232,
+ crc: 0x0373ac26
+ },
+ {
+ name: "test.png",
+ size: 3402,
+ crc: 0x504a5c30
+ }
+];
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ var size = 0;
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR + TESTS[i].name);
+ zipW.addEntryFile(TESTS[i].name, Ci.nsIZipWriter.COMPRESSION_NONE, source,
+ false);
+ size += ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
+ (ZIP_EXTENDED_TIMESTAMP_SIZE * 2) +
+ (TESTS[i].name.length*2) + TESTS[i].size;
+ }
+
+ zipW.close();
+ size += ZIP_EOCDR_HEADER_SIZE;
+
+ do_check_eq(size, tmpFile.fileSize);
+
+ // Test the stored data with the zipreader
+ var zipR = new ZipReader(tmpFile);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR + TESTS[i].name);
+ do_check_true(zipR.hasEntry(TESTS[i].name));
+
+ var entry = zipR.getEntry(TESTS[i].name);
+ do_check_eq(entry.realSize, TESTS[i].size);
+ do_check_eq(entry.size, TESTS[i].size);
+ do_check_eq(entry.CRC32, TESTS[i].crc);
+ do_check_eq(Math.floor(entry.lastModifiedTime / PR_USEC_PER_SEC),
+ Math.floor(source.lastModifiedTime / PR_MSEC_PER_SEC));
+
+ zipR.test(TESTS[i].name);
+ }
+
+ zipR.close();
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_undochange.js b/modules/libjar/zipwriter/test/unit/test_undochange.js
new file mode 100644
index 000000000..59647f9af
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_undochange.js
@@ -0,0 +1,42 @@
+/* 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/.
+ */
+
+// Values taken from using zipinfo to list the test.zip contents
+var TESTS = [
+ "test.txt",
+ "test.png"
+];
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+
+ for (var i = 0; i < TESTS.length; i++) {
+ var source = do_get_file(DATA_DIR + TESTS[i]);
+ zipW.addEntryFile(TESTS[i], Ci.nsIZipWriter.COMPRESSION_NONE, source,
+ false);
+ }
+
+ try {
+ var source = do_get_file(DATA_DIR + TESTS[0]);
+ zipW.addEntryFile(TESTS[0], Ci.nsIZipWriter.COMPRESSION_NONE, source,
+ false);
+ do_throw("Should not be able to add the same file twice");
+ }
+ catch (e) {
+ do_check_eq(e.result, Components.results.NS_ERROR_FILE_ALREADY_EXISTS);
+ }
+
+ // Remove all the tests and see if we are left with an empty zip
+ for (var i = 0; i < TESTS.length; i++) {
+ zipW.removeEntry(TESTS[i], false);
+ }
+
+ zipW.close();
+
+ // Empty zip file should just be the end of central directory marker
+ var newTmpFile = tmpFile.clone();
+ do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_zipcomment.js b/modules/libjar/zipwriter/test/unit/test_zipcomment.js
new file mode 100644
index 000000000..0bc111c6c
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_zipcomment.js
@@ -0,0 +1,34 @@
+/* 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 DATA = "ZIP WRITER TEST COMMENT";
+const DATA2 = "ANOTHER ONE";
+
+function run_test()
+{
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+ zipW.comment = DATA;
+ zipW.close();
+
+ // Should have created a zip file
+ do_check_true(tmpFile.exists());
+
+ // Empty zip file should just be the end of central directory marker
+ // and comment
+ do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA.length);
+
+ zipW.open(tmpFile, PR_RDWR);
+ // Should have the set comment
+ do_check_eq(zipW.comment, DATA);
+ zipW.comment = DATA2;
+ zipW.close();
+
+ // Certain platforms cache the file size so get a fresh file to check.
+ tmpFile = tmpFile.clone();
+
+ // Empty zip file should just be the end of central directory marker
+ // and comment. This should now be shorter
+ do_check_eq(tmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE + DATA2.length);
+}
diff --git a/modules/libjar/zipwriter/test/unit/test_zippermissions.js b/modules/libjar/zipwriter/test/unit/test_zippermissions.js
new file mode 100644
index 000000000..c3f276dfc
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/test_zippermissions.js
@@ -0,0 +1,83 @@
+/* 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 DATA = "ZIP WRITER TEST DATA";
+
+var TESTS = [];
+
+function build_tests() {
+ var id = 0;
+
+ // Minimum mode is 0o400
+ for (let u = 4; u <= 7; u++) {
+ for (let g = 0; g <= 7; g++) {
+ for (let o = 0; o <= 7; o++) {
+ TESTS[id] = {
+ name: "test" + u + g + o,
+ permission: (u << 6) + (g << 3) + o
+ };
+ id++;
+ }
+ }
+ }
+}
+
+function run_test() {
+ build_tests();
+
+ var foStream = Cc["@mozilla.org/network/file-output-stream;1"].
+ createInstance(Ci.nsIFileOutputStream);
+
+ var tmp = tmpDir.clone();
+ tmp.append("temp-permissions");
+ tmp.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, 0o755);
+
+ var file = tmp.clone();
+ file.append("tempfile");
+
+ zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
+ for (let i = 0; i < TESTS.length; i++) {
+ // Open the file with the permissions to match how the zipreader extracts
+ // This obeys the umask
+ foStream.init(file, 0x02 | 0x08 | 0x20, TESTS[i].permission, 0);
+ foStream.close();
+
+ // umask may have altered the permissions so test against what they really were.
+ // This reduces the coverage of the test but there isn't much we can do
+ var perm = file.permissions & 0xfff;
+ if (TESTS[i].permission != perm) {
+ dump("File permissions for " + TESTS[i].name + " were " + perm.toString(8) + "\n");
+ TESTS[i].permission = perm;
+ }
+
+ zipW.addEntryFile(TESTS[i].name, Ci.nsIZipWriter.COMPRESSION_NONE, file, false);
+ do_check_eq(zipW.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400);
+ file.permissions = 0o600;
+ file.remove(true);
+ }
+ zipW.close();
+
+ zipW.open(tmpFile, PR_RDWR);
+ for (let i = 0; i < TESTS.length; i++) {
+ dump("Testing zipwriter file permissions for " + TESTS[i].name + "\n");
+ do_check_eq(zipW.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400);
+ }
+ zipW.close();
+
+ var zipR = new ZipReader(tmpFile);
+ for (let i = 0; i < TESTS.length; i++) {
+ dump("Testing zipreader file permissions for " + TESTS[i].name + "\n");
+ do_check_eq(zipR.getEntry(TESTS[i].name).permissions, TESTS[i].permission | 0o400);
+ dump("Testing extracted file permissions for " + TESTS[i].name + "\n");
+ zipR.extract(TESTS[i].name, file);
+ do_check_eq(file.permissions & 0xfff, TESTS[i].permission);
+ do_check_false(file.isDirectory());
+ file.permissions = 0o600;
+ file.remove(true);
+ }
+ zipR.close();
+
+ tmp.remove(true);
+}
diff --git a/modules/libjar/zipwriter/test/unit/xpcshell.ini b/modules/libjar/zipwriter/test/unit/xpcshell.ini
new file mode 100644
index 000000000..a0a4a3ce1
--- /dev/null
+++ b/modules/libjar/zipwriter/test/unit/xpcshell.ini
@@ -0,0 +1,37 @@
+[DEFAULT]
+head = head_zipwriter.js
+tail = tail_zipwriter.js
+support-files =
+ data/test_bug446708/thumbs/st14-1.tiff
+ data/emptyfile.txt
+ data/smallfile.txt
+ data/test.png
+ data/test.txt
+ data/test.zip
+ data/test_bug399727.html
+ data/test_bug399727.zlib
+ data/test_bug717061.gz
+ data/test_bug717061.html
+
+[test_asyncadd.js]
+[test_asyncbadadd.js]
+[test_asyncbadremove.js]
+[test_asyncremove.js]
+[test_bug399727.js]
+[test_bug419769_1.js]
+[test_bug419769_2.js]
+[test_bug425768.js]
+[test_bug433248.js]
+[test_bug446708.js]
+[test_bug467740.js]
+[test_createempty.js]
+[test_deflatedata.js]
+[test_directory.js]
+[test_editexisting.js]
+[test_storedata.js]
+[test_sync.js]
+[test_undochange.js]
+[test_zipcomment.js]
+[test_zippermissions.js]
+[test_bug717061.js]
+[test_alignment.js]