Bug 1264037 - Add testing for CRX reading. r=spohl
authorKirk Steuber <ksteuber@mozilla.com>
Wed, 13 Apr 2016 13:38:08 -0700
changeset 331214 3b3d8b016792eff1b67debd4dde55b976926a5fc
parent 331213 a732557d9efc0f243d7d0110f0a181069cf82f10
child 331215 2377dfe9e73cf6754c3ae1296869a4d31232ef79
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1264037
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264037 - Add testing for CRX reading. r=spohl MozReview-Commit-ID: 3uFTOUyvFtG
modules/libjar/test/unit/data/test_crx_dummy.crx
modules/libjar/test/unit/test_crx.js
modules/libjar/test/unit/xpcshell.ini
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..516e4ff8071d132dcfb0a76431954ffdba966479
GIT binary patch
literal 1102
zc${-CGBROeK!5;mW)=}3&B5?`rmfl8H5+Vem>C%I*clk)8AKU!^HWN5Qj7I-GLy0r
zi}XuUi%ax<6SGs(GILV(GV?-1I2o8F`}VnB>)q!XTEW8bW_~I|Z|M8{TLuDu_xur6
z-^Fhb>KUCGze`?=_1dCk4P1Ax)vlcLMB!e~+?#wof4^E=D=wXq**(Ey&hzs3_wHJ{
z9~9hEC?3PNu1&e4eeb~xtA^7RcXqG5C-BHP>+n>Y_S>F3%O7Tzxc*On=qVCzzWkuz
z!Zb^#RZCnmc~@B8m?J%-xbc8Vljh|2Gom(h#VOobbw7rKZL*P|P3w&18oYVRg3_&x
z+nl$(Dqnlf`o;>OX*tY6ks6%;M40NAMnpWAq@u%paHfyowL8yTo<?L%5|GQ{ni}Dj
z;r1gb_+)Ot0iE2_Yjw{p&e$8*e%dQ{#TO+dex>>EL(aavwRBoxvZ=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im:set ts=2 sw=2 sts=2 et: */
+/* 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 wrapInputStream(input)
+{
+  let nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
+  let factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
+  let wrapper = factory.createInstance(nsIScriptableInputStream);
+  wrapper.init(input);
+  return wrapper;
+}
+
+// Make sure that we can read from CRX files as if they were ZIP files.
+function run_test() {
+  const Cc = Components.classes;
+  const Ci = Components.interfaces;
+
+  // Note: test_crx_dummy.crx is a dummy crx file created for this test. The
+  // public key and signature fields in the header are both empty.
+  let file = do_get_file("data/test_crx_dummy.crx");
+
+  let zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
+                  createInstance(Ci.nsIZipReader);
+  zipreader.open(file);
+  // do crc stuff
+  function check_archive_crc() {
+    zipreader.test(null);
+    return true;
+  }
+  Assert.ok(check_archive_crc())
+  let entries = zipreader.findEntries(null);
+  let stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"))
+  let dirstream= wrapInputStream(zipreader.getInputStream("modules/libjar/test/"))
+  zipreader.close();
+  zipreader = null;
+  Components.utils.forceGC();
+  Assert.ok(stream.read(1024).length > 0);
+  Assert.ok(dirstream.read(100).length > 0);
+}
+
--- a/modules/libjar/test/unit/xpcshell.ini
+++ b/modules/libjar/test/unit/xpcshell.ini
@@ -10,16 +10,17 @@ support-files =
   data/test_bug379841.zip
   data/test_bug589292.zip
   data/test_bug597702.zip
   data/test_bug637286.zip
   data/test_bug658093.zip
   data/test_corrupt.zip
   data/test_corrupt2.zip
   data/test_corrupt3.zip
+  data/test_crx_dummy.crx
   data/test_umlaute.zip
   data/uncompressed.zip
 
 [test_jarchannel.js]
 [test_jarchannel_e10s.js]
 skip-if = os == "mac"
 [test_bug278262.js]
 [test_bug333423.js]
@@ -31,14 +32,14 @@ skip-if = os == "mac"
 [test_bug458158.js]
 [test_bug589292.js]
 [test_bug597702.js]
 [test_bug637286.js]
 [test_bug658093.js]
 [test_corrupt_536911.js]
 [test_corrupt_541828.js]
 [test_corrupt_1211262.js]
+[test_crx.js]
 [test_dirjar_bug525755.js]
 [test_jarinput_stream_zipreader_reference.js]
 [test_not_found.js]
 [test_uncompressed.js]
 [test_umlaute.js]
-