test_corrupt_536911.js (1100B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 function wrapInputStream(input) { 6 var nsIScriptableInputStream = Ci.nsIScriptableInputStream; 7 var factory = Cc["@mozilla.org/scriptableinputstream;1"]; 8 var wrapper = factory.createInstance(nsIScriptableInputStream); 9 wrapper.init(input); 10 return wrapper; 11 } 12 13 // Check that files can be read from after closing zipreader 14 function run_test() { 15 // the build script have created the zip we can test on in the current dir. 16 var file = do_get_file("data/test_corrupt.zip"); 17 18 var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance( 19 Ci.nsIZipReader 20 ); 21 zipreader.open(file); 22 // var entries = zipreader.findEntries(null); 23 // the signature for file is corrupt, should not segfault 24 var failed = false; 25 try { 26 var stream = wrapInputStream(zipreader.getInputStream("file")); 27 stream.read(1024); 28 } catch (ex) { 29 failed = true; 30 } 31 Assert.ok(failed); 32 }